mac 安装 php nginx mysql

一、前话:
1.1、情况选用:
双重在mac上陈设php,原来mac上就自带有apach、php以致pgsql,要是图简单的话,直接用就可以了,可是在装置前笔者留神考虑了意气风发晃多少个难题:
选apache照旧nginx:七个本人精通的都相当少,相对来讲小编接触nginx比很多,服务器用的也是nginx,不能够哪个人叫nginx负载高呢。为了更加好的触发nginx的际遇,笔者调整也许统一下遭逢,方便以往使用,那是这一次的重要关键;
安装php:Mac
os自带了php,好疑似5.3.8,版本比较落后,但是那不碍事,因为在此以前笔者都以通过php-osx
by Liip来管理php,所以置之不顾虑版本难点。可是php-osx by
Liip好像从没fmp相关的布置,那样品身自身要和nginx一同用的话就相对比较劳苦了,那笔者一定要选取任何方案了
安装mysql:那几个就从不什么样好难点的了,如今自己必然不会去用pgsql,终究没接触过,要求有学习花销的,所以笔者在此篇记录中把有关pgsql的有的都去掉了
1.2、那该如何设置:
既然小编否定了系统自带的条件,那么快要通过其他艺术去安装了,比方说手动编写翻译。若是是手动编写翻译的话,那么就会遇见上边多少个难点:
编写翻译费力,php信任那么多程序,一个个设置,太累!
假若未来更新怎么办?患难!!
可是幸亏mac下有本人的第三方管理程序:homebrew,何况相对来讲笔者认为他或者在一些地点更非凡于linux下的apt-get、yum。若是通过homebrew来设置、处理运作条件的话,起码能够缓和本人多少个难题:
安装难题,笔者决不繁缛的去安装注重程序
升级难点,只要求brew update一遍晋级具备程序
本子难点,homebrew版本更新相比及时,而apt-get、yum来说,今年用的核心是N年前的稳定性版本了
OK,上面的设置都以基于 homebrew,假若不熟知或然尚未设置有 homebrew
的话,能够查阅那篇关于:Mac开拓者利器-Homebrew介绍及安装。
二、安装nginx
2.1、安装:
用 brew 风流罗曼蒂克键安装 nignx:
1
brew install nginx
万生龙活虎急需设置任何 nginx 的本子,能够 “brew edit nginx” 张开改进 nginx
的安装消息包 formula,默许会用 vi 展开,在文书初阶处校勘 nginx
相应版本的下载地址就能够。
2.2、配置
brew 实践完后,nginx 就安装好了。能够用以下指令对 nginx 实行操作:
复制代码 代码如下:
#打开 nginx
sudo nginx
 
#再也加载|重启|停止|退出 nginx
nginx -s reload|reopen|stop|quit
开荒 nginx 后,私下认可的拜谒端口 8080,假设要改为常用的 80 端口,则要纠正“/usr/local/etc/nginx/nginx.conf” 下监听(listen卡塔尔国端口值。
私下认可的文书访谈目录(rootState of Qatar是
“/usr/local/Cellar/nginx/1.4.2/html”(这里的1.4.2是设置的nginx的本子,文件夹名以安装的nginx版本为准)。
2.3、把 nginx 设置为开机运行运作:
复制代码 代码如下:
mkdir -p ~/Library/LaunchAgents/

 

1、关闭并剔除系统自带的Apache

安装Nginx

实行如下命令

brew install nginx

结果如下:

$brew install nginx
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/nginx-1.12.0_1.sierra.bottl
Already downloaded: /Users/xxx/Library/Caches/Homebrew/nginx-1.12.0_1.sierra.bottle.tar.gz
==> Pouring nginx-1.12.0_1.sierra.bottle.tar.gz
Warning: This keg was marked linked already, continuing anyway
==> Using the sandbox
==> Caveats
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

To have launchd start nginx now and restart at login:
  brew services start nginx
Or, if you don't want/need a background service you can just run:
  nginx
==> Summary
🍺  /usr/local/Cellar/nginx/1.12.0_1: 23 files, 1MB

Homebrew官网 

cp /usr/local/Cellar/nginx/1.4.2/homebrew.mxcl.nginx.plist
~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

mac上边设置php nginx
mysql根linux下边大致,建议咱们使用brew管理工具包安装。

sudo apachectl stop  #关闭apache,如果事先没开启过,可以忽略报错信息

sudo rm /usr/sbin/apachectl sudo rm /usr/sbin/httpd sudo rm -r /etc/apache2/

升级Nginx

推行如下命令

brew upgrade nginx

结果如下:

$brew upgrade nginx
==> Upgrading 1 outdated package, with result:
nginx 1.12.0_1
==> Upgrading nginx
==> Installing dependencies for nginx: pcre, openssl@1.1
==> Installing nginx dependency: pcre
==> Downloading https://homebrew.bintray.com/bottles/pcre-8.40.sierra.bottle.tar
######################################################################## 100.0%
==> Pouring pcre-8.40.sierra.bottle.tar.gz
==> Using the sandbox
🍺  /usr/local/Cellar/pcre/8.40: 204 files, 5.4MB
==> Installing nginx dependency: openssl@1.1
==> Downloading https://homebrew.bintray.com/bottles/openssl@1.1-1.1.0f.sierra.b
######################################################################## 100.0%
==> Pouring openssl@1.1-1.1.0f.sierra.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@1.1/certs

and run
  /usr/local/opt/openssl@1.1/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl@1.1/lib
    CPPFLAGS: -I/usr/local/opt/openssl@1.1/include
For pkg-config to find this software you may need to set:
    PKG_CONFIG_PATH: /usr/local/opt/openssl@1.1/lib/pkgconfig

==> Summary
🍺  /usr/local/Cellar/openssl@1.1/1.1.0f: 6,421 files, 15.5MB
==> Installing nginx
==> Downloading https://homebrew.bintray.com/bottles/nginx-1.12.0_1.sierra.bottl
######################################################################## 100.0%
==> Pouring nginx-1.12.0_1.sierra.bottle.tar.gz
==> Caveats
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

To have launchd start nginx now and restart at login:
  brew services start nginx
Or, if you don't want/need a background service you can just run:
  nginx
==> Summary
🍺  /usr/local/Cellar/nginx/1.12.0_1: 23 files, 1MB

Homebrew是神马

唯独试了一下,不是一级客户登入,而是普通客商登录,并且监听的端口在1024以下的(举个例子把暗许的8080端口改为了80端口),nginx
开机是开发银行不了。因而,要 nginx 开机运维以来,要求予以它管理员权限:
复制代码 代码如下:
2
sudo chown root:wheel /usr/local/Cellar/nginx/1.4.2/bin/nginx
sudo chmod u+s /usr/local/Cellar/nginx/1.4.2/bin/nginx

 

修改php-fpm文件

  1. 实行命令:

sudo cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf
  1. 找到目录下的php-fpm文件
    /private/etc/php-fpm.conf

  2. 找到32行的 error_log ,改为(正行替换,注意 ‘;’ 和空格):

error_log = /usr/local/var/log/php-fpm.log

要不然 php-fpm 时会报错:

ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such
file or directory (2)

linux系统有个令人蛋疼的症结,软件包重视,幸而当下主流的两大批判发版本都自带了缓慢解决方案,Red
hat有yum,Ubuntu有apt-get

三、安装mysql
3.1、安装:
复制代码 代码如下:
brew install mysql

1,安装homebrew

2、删除自带的php

修改 Nginx 配置

  1. 打开 nginx.config 文件

/usr/local/etc/nginx/nginx.conf
  1. 找到 server 的 location 配置,给 index加一个index.php

location / {
    root   html;
    index  index.html index.htm index.php;
}
  1. 并张开 server 下被讲授的 location ~.php$(即除去代码后面的‘#’),如下:

location ~ \.php$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    include        fastcgi_params;
}

 神马,你用mac os,不佳意Mac
os木有像样的东东,泪奔中多次经过折腾总算找到了第三方协助:Homebrew,Homebrew简单称谓brew,是Mac
OSX上的软件包管理工科具,能在Mac中有益的装置软件依旧卸载软件,能够说Homebrew正是mac下的apt-get、yum神器

homebrew安装的本子雷同是日前洋气的稳固版,安装的长河比较轻易,不太早先化就相对劳苦非常多了,这里小编失利了很频仍。
3.2、配置:
3.2.1、初始化
千帆竞发安装 mysql 的有个别构造数据库(举例:information_schema、mysql)
复制代码 代码如下:
sudo mysql_install_db \
–verbose –user=`whoami` \
–basedir=”$(brew –prefix mysql)” \
–datadir=/usr/local/var/mysql \
–tmpdir=/tmp \
–explicit_defaults_for_timestamp

sudo rm -r /usr/bin/php

修改 fastcgi_param 参数

fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

改为

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

 

此处本人遇到了多少个难题,进程都没纪录,这里大致提下技术方案:
系统建议笔者加多“–explicit_defaults_for_timestamp”;
设置进度中会碰到多少个error,说是db的多少个公文子虚乌有;
网络找出了下,多数是提出将/usr/local/var/mysql这几个目录校勘下放权力限;
作者操作后意识大概不是那般的,形成这几个主题材料在于本身在事情未发生前操作遭遇了不个中止了,生成了二个不完全var目录,所以每一趟安装失败作者就删除以下文件,重新开端化就好了
复制代码 代码如下:
sudo rm /usr/local/opt/mysql/my.cnf
sudo rm -R /usr/local/var/mysql/

安装方法会改换的,所以安装官方上边的格局来装。安装 homebrew-cask

创建index.php

在 /usr/local/var/www 目录下,删除 index.html,创建 index.php,输入

<?php phpinfo(); ?>

Homebrew安装

待安装收尾后,会现身一大段mysql相关新闻,运维上面包车型客车命令运营mysql
复制代码 代码如下:
/usr/local/opt/mysql/bin/mysqld_safe &

  1. $ brew tap caskroom/cask  

3、安装 Command Line Tools

开发银行相关服务

brew services start nginx
sudo php-fpm

下一场访谈localhost:8083,看见 php 配置新闻,就认证 ok 了

Homebrew的装置特别轻松,张开终端复制、粘贴以下命令,回车,化解(请放心使用,原汁原味的合法安装方式搬运)

实行完后,就足以在终点里运行“mysql”,直接步向mysql数据Curry。对,不用输入密码,能够一贯连接,初步默许是能够无名访谈的。
3.2.2、订正密码
精品客户 “root” 也是没设密码,要设密码的话能够实行上面发号布令
复制代码 代码如下:
/usr/local/opt/mysql/bin/mysqladmin -u root password ‘new-password’

homebrew-cask安装的东西,更加的多。

xcode-select --install

启动Nginx

brew services start nginx
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

到现在访谈 mysql
照旧毫不密码就足以连接,假若要设置有个别登入密码的自贡访谈限定,则需执行上边的mysql安全设置指令
复制代码 代码如下:
/usr/local/opt/mysql/bin/mysql_secure_installation

2,换源也许加代理

重启Nginx

brew services restart nginx

Last login: Mon Feb  8 18:00:37 on ttys000

注重是设置改革root密码(设置过了可以毫无安装,略过)、删除佚名访谈、删除root互连网访谈、删除test数据库。指令推行完后,登入mysql就供给密码验证了
复制代码 代码如下:
mysql -u root -p

brew管理工科具包,默许是从github上边下载,github日常被墙。何况龟速。

4、安装brew

测试

在浏览器中输入以下地点:
http://localhost:8083/

yangchaodeMacBook-Air:~ yangchao$ ruby -e “$(curl -fsSL
)”

3.3、开机运维mysql
复制代码 代码如下:
mkdir -p ~/Library/LaunchAgents/

查看复制打印?

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew doctor

brew update brew upgrade 

参照他事他说加以考察资料

 

cp /usr/local/Cellar/mysql/5.6.13/homebrew.mxcl.mysql.plist
~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

  1. $ brew install git  
  2. $ cd /usr/local/Homebrew  
  3. $ git remote set-url origin   

Mac下Nginx情状安顿

http://www.cnblogs.com/cheemon/p/5638394.html

curl: (35) Server aborted the SSL handshake

时至后天,mysql安装收尾。
四、安装php、php-fpm…
4.1、安装
Mac是预装了php,但是超级多扩大都没安装,目测最两只好在终极里进行下php指令,所以小编接纳重新安装php。由于
brew 暗中同意是未有 php 安装,所以要使用 “brew tap” 来设置 brew
的第三方程序包,这里运用 josegonzalez 的php安装包,具体操作如下:
复制代码 代码如下:
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php

尽管不想换源话,能够加代理,前提是您的代理,不被墙,并且十分的快

5、安装php

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin15/rbconfig.rb:213:
warning: Insecure world writable dir /Applications/Cocos/tools/ant/bin
in PATH, mode 040777

实施完后,就能够用 brew
安装php了。这里php有多少个本子能够设置,具体能够实行 “brew search php”
查看一下有哪些php版本能够设置,日常会有“php52、php53、php54、php55”版本,作者设置的是时髦的php5.5版本。由于PHP5.5版本现已内嵌了
FPM(FastCGI Process Manager),在设置选项里申明就可以,本人 php
的安装配备指令如下:
复制代码 代码如下:
sudo brew install php55 \
–with-debug \
–with-fpm \
–with-gmp \
–with-homebrew-openssl \
–with-imap –with-intl \
–with-libmysql \
–without-bz2 \
–without-mysql \
–without-pcntl \
–without-pear

查看复制打印?

brew tap homebrew/dupes brew tap homebrew/php

brew install php56 --without-apache --with-fpm --with-mysql

yangchaodeMacBook-Air:~ yangchao$ 

越来越多的安装选项能够透过 “brew options php55″ 查看。
唤醒:–with-cgi不能够和–with-fpm一齐安装,相互冲突
命令推行完后,php 跟 php-fpm 就安装好了。
4.2、配置
是因为是重装php,早先系统预装的php还未卸载,由此在终点调用php时,依旧以早前系统的php版本做剖判,所以这里必要改进path,内定php 的深入分析路线。在~/.bashrc(未有则开创)最后参与风流倜傥行:
复制代码 代码如下:
export PATH=”$(brew –prefix php54)/bin:$PATH”
[html]
[code]
source ./.profile

  1. zhangyingdeMacBook-Pro:Homebrew zhangying$ cat ~/.curlrc  
  2. socks5=”127.0.0.1:1080″  

加多自运维

yangchaodeMacBook-Air:~ yangchao$ ruby -e “$(curl -fsSL
)”

不设有这一个文件的对象请参见这片小说实行配备:Mac系统终端命令行不试行命令
总现身command not found消除方式
OK,php-fpm安装完结。
要改善配置 php 或许 php-fpm 的话,可以改善“/usr/local/etc/php/5.5/php.ini” 、
“/usr/local/etc/php/5.5/php-fpm.conf”。
详细布署格局能够参照相关资料:
php-fpm 运营参数及入眼安排精解
Linux平滑编写翻译进级php至5.5.0
起步 php-fpm 的话就平素在终点里执行 “php-fpm”,暗中认可展开 php-fpm
会呈现多少个状态 shell 出来,也得以把 php-fpm 的配备文件里的 “daemonize =
no” 改为 “daemonize =
yes”,就能够现在台守护进程的主意运维,对Yu Gang更正的构造文件,能够施行“php-fpm -t” 来检查评定配置有未有标题。
4.3、开机启动
开机运维 php-fpm(上边包车型地铁 5.5.3 是当前设置 php 的现实性版本号):
复制代码 代码如下:
mkdir -p ~/Library/LaunchAgents/

3,安装nginx mysql

mkdir -p ~/Library/LaunchAgents

ln -sfv /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin15/rbconfig.rb:213:
warning: Insecure world writable dir /Applications/Cocos/tools/ant/bin
in PATH, mode 040777

cp /usr/local/Cellar/php54/5.5.3/homebrew-php.josegonzalez.php55.plist
~/Library/LaunchAgents/
launchctl load -w
~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist

  1. $ brew install nginx mysql  

为了后边管理有助于,将下令 alias 下

==> This script will install:

为了便利,写了个运维、关闭、重启 php-fpm 的 shell 脚本:
复制代码 代码如下:
#!/bin/sh

4,安装php

nano ~/.bash_aliases

alias php-fpm.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist" alias php-fpm.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist" alias php-fpm.restart='php-fpm.stop && php-fpm.start'

nano ~/.bash_profile

[[ -f ~/.bash_aliases ]] && . ~/.bash_aliases 

source .bash_profile //更新文件 

/usr/local/bin/brew

param=$1

查看复制打印?

如此那般就可以用便捷命令来管理php-fpm了

/usr/local/Library/…

start()
{
    fpms=`ps aux | grep -i “php-fpm” | grep -v grep | awk ‘{print
$2}’`
    if [ ! -n “$fpms” ]; then
        php-fpm
        echo “PHP-FPM Start”
    else
        echo “PHP-FPM Already Start”
    fi
}

  1. //增多增加库  
  2. $ brew tap homebrew/dupes  
  3. $ brew tap homebrew/versions  
  4. $ brew tap homebrew/php  
  5.   
  6. $ brew search php //查看php的可用版本  
  7. $ brew install php54 //安装所需版本  
  8.   
  9. //暗中认可是有php的,所以php的条件要指向新的  
  10. $ echo ‘export PATH=”$(brew –prefix homebrew/php/php54)/bin:$PATH”‘ >> ~/.bash_profile  
  11. $ echo ‘export PATH=”$(brew –prefix homebrew/php/php54)/sbin:$PATH”‘ >> ~/.bash_profile  
  12. $ echo ‘export PATH=”/usr/local/bin:/usr/local/sbin:$PATH”‘ >> ~/.bash_profile  
  13. $ source ~/.bash_profile //更新配置  
php-fpm.start php-fpm.stop php-fpm.restart

/usr/local/share/man/man1/brew.1

stop()
{
    fpms=`ps aux | grep -i “php-fpm” | grep -v grep | awk ‘{print
$2}’`
    echo $fpms | xargs kill -9

5,配置文件目录

==> The following directories will be made group writable:

    for pid in $fpms; do
        if echo $pid | egrep -q ‘^[0-9]+$’; then
            echo “PHP-FPM Pid $pid Kill”
        else
            echo “$pid IS Not A PHP-FPM Pid”
        fi
    done
}

  1. /usr/local/etc/nginx  
  2. /usr/local/etc/php  
  3. /usr/local/Cellar/mysql/5.7.16  

6、安装php扩展

/usr/local/.

case $param in
    ‘start’)
        start;;
    ‘stop’)
        stop;;
    ‘restart’)
        stop
        start;;
    *)
        echo “Usage: ./phpfpm.sh start|stop|restart”;;
esac

6,开机运营,以nginx为例

brew install php56-redis brew install php56-amqp

/usr/local/bin

五、设置 nginx 的 php-fpm 配置
在server块中增添深入分析文件类型“index index.html index.htm index.php;”
复制代码 代码如下:
server {
        listen       80;
        server_name  localhost;
        index index.html index.htm index.php;
        ……
}

查看复制打印?

==> The following directories will have their owner set to
yangchao:

开采 nginx 暗中同意注释掉的php
location设置,改革如下(具体配置参数,比方路线,这里以作者本地安装为准):
复制代码 代码如下:
location ~ .*\.(php|php5)?$ {
        #fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME 
/Library/WebServer/public_html$fastcgi_script_name;
        include /usr/local/etc/nginx/fastcgi_params;
        #include fcgi.conf;
}

  1. $ ln -s /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents/  
  2. $ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist   //加载  
  3. $ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist     //撤销加载  

7、安装nginx

/usr/local/.

修改目录顾客、客商组:
复制代码 代码如下:
sudo chown www:www /Library/WebServer/public_html

7,sudo无密码

brew install nginx

/usr/local/bin

OK,那样就足以在做客目录下(默许是/Library/WebServer/public_html)实践php 文件了。嗯,急速输出一下 “phpinfo(State of Qatar” 吧~
复制代码 代码如下:
phpinfo();

查看复制打印?

配置nginx

==> The following directories will have their group set to
admin:

  1. $ sudo su  
  2. # visudo  
  3. %admin   ALL = NOPASSWD:ALL  //admin组的积极分子,sudo不用输入密码了  
nano /usr/local/etc/nginx/nginx.conf

<pre name="code" class="html">user wby staff;

worker_processes  1;

events {

    worker_connections  128;

}

http {

    include       mime.types;

    include       vhost/*.conf;

    default_type  application/octet-stream;     sendfile       on;

    tcp_nopush     on;

    tcp_nodelay    on;     keepalive_timeout  65;     gzip  on;

}



添加vhost

/usr/local/.

8,假如不想自运维,能够用运营脚本

mkdir/usr/local/etc/nginx/vhost

/usr/local/bin

查看复制打印?

nano /usr/local/etc/nginx/vhost/default.conf

server {         listen       80;         server_name  zjy;          #charset koi8-r;          #access_log  logs/host.access.log  main;          location / {             root   /Users/wby/Documents/PHPProjects/operator_sz_web/public;             index  index.html index.htm index.php;             try_files $uri $uri/ /index.php?$query_string;         }          #error_page  404              /404.html;         error_page   500 502 503 504  /50x.html;         location = /50x.html {             root   /Users/wby/Documents/PHPProjects/public;         }          # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000         location ~ \.php$ {                 fastcgi_intercept_errors on;                 fastcgi_pass   127.0.0.1:9000;                 fastcgi_index  index.php;                 fastcgi_param  SCRIPT_FILENAME  /Users/wby/Documents/PHPProjects/operator_sz_web/public$fastcgi_script_name;                 fastcgi_param  SCRIPT_NAME    $fastcgi_script_name;                 include        /usr/local/etc/nginx/fastcgi_params;         }     }

nginx //启动

nginx -s stop   //停止

nginx -s reload  //重新加载

 

  1. #!/bin/bash  
  2.   
  3. param=$1  
  4.   
  5. start()  
  6. {  
  7.   
  8.  #启动nginx  
  9.  sudo nginx    //nginx要求root客户来运营  
  10.  #启动mysql  
  11.  mysql.server start  
  12.  #启动php-fpm  
  13.  fpms=`ps aux | grep -i “php-fpm” | grep -v grep | awk ‘{print $2}’`  
  14.  if [ ! -n “$fpms” ]; then  
  15.  php-fpm  
  16.  echo “PHP-FPM Start”  
  17.  else  
  18.  echo “PHP-FPM Already Start”  
  19.  fi  
  20. }  
  21.   
  22. stop()  
  23. {  
  24.   
  25.  #停止nginx  
  26.  sudo nginx -s stop  
  27.  #停止mysql  
  28.  mysql.server stop  
  29.  #停止php-fpm  
  30.  fpms=`ps aux | grep -i “php-fpm” | grep -v grep | awk ‘{print $2}’`  
  31.  echo $fpms | xargs kill -9  
  32.   
  33.  for pid in $fpms; do  
  34.  if echo $pid | egrep -q ‘^[0-9]+$’; then  
  35.  echo “PHP-FPM Pid $pid Kill”  
  36.  else  
  37.  echo “$pid IS Not A PHP-FPM Pid”  
  38.  fi  
  39.  done  
  40. }  
  41.   
  42. case $param in  
  43.  ‘start’)  
  44.  start;;  
  45.  ‘stop’)  
  46.  stop;;  
  47.  ‘restart’)  
  48.  stop  
  49.  start;;  
  50.  *)  
  51.  echo “Usage: ./web.sh start|stop|restart”;;  
  52. esac  

【注意大概会波及到有个别文本和文书夹的客商和权力难题】

Press RETURN to continue or any other key to abort

【数据库是平素连的服务器,所以我就不装mysql了】

==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/.
/usr/local/bin

参照了以下内容:

Password:

==> /usr/bin/sudo /usr/sbin/chown yangchao /usr/local/.
/usr/local/bin

版权表明:本文为博主原创小说,未经博主允许不得转发。

==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/.
/usr/local/bin


==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew

==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew

==> /usr/bin/sudo /usr/sbin/chown yangchao
/Library/Caches/Homebrew

==> Downloading and installing Homebrew…

 

remote: Counting objects: 4007, done.

remote: Compressing objects: 100% (3852/3852), done.

remote: Total 4007 (delta 35), reused 2031 (delta 23), pack-reused 0

Receiving objects: 100% (4007/4007), 3.26 MiB | 128.00 KiB/s, done.

Resolving deltas: 100% (35/35), done.

From

 * [new branch]      master     -> origin/master

HEAD is now at b3eed85 rtags: add 2.1 bottle.

==> Installation successful!

==> Next steps

Run `brew help` to get started

 

Homebrew使用

Homebrew使用没啥好说的了,常用的

探究软件:brew search 软件名,如brew search wget

设置软件:brew install 软件名,如brew install wget

卸载软件:brew remove 软件名,如brew remove wget

 

 

安装php-fpm

未完,上边的失误了

发表评论

电子邮件地址不会被公开。 必填项已用*标注