首先感謝這篇文章:Mac 下 Nginx、PHP昼汗、MySQL 和 PHP-fpm 的安裝和配置
由于我的PHP7是通過brew安裝的。
brew安裝的東西都在目錄/usr/local/opt/? 下了鬼雀。這是我知識(shí)的盲點(diǎn)顷窒。所以找了很久沒找到。
看到這篇文章后源哩,到了/usr/local/opt/php71/sbin/ 目錄下果然看到了php-fpm
接下來(lái)的事情很容易了
sudo ln -s /usr/local/opt/php71/sbin/php-fpm /usr/sbin/php-fpm? 將它軟連接過去鞋吉,
沒有使用cp ,因?yàn)?usr/sbin/已經(jīng)有個(gè)5.6了,我想以后可以做切換使用励烦。
有人說(shuō)mac不支持 多個(gè)PHP版本切換谓着,我證明了,是可以的坛掠。
實(shí)現(xiàn)配置2個(gè)版本PHP赊锚,
修改php7的php-fmp服務(wù)端口號(hào)
進(jìn)入到目錄:/usr/local/etc/php/php7.1/php-fpm.d/www.conf
修改 www.conf這個(gè)文件的監(jiān)聽端口listen = 127.0.0.1:9009
可以了。
現(xiàn)在的情況是:
PHP5.6的php-fpm監(jiān)聽的是?127.0.0.1:9000
PHP7.1的php-fpm監(jiān)聽的是?127.0.0.1:9009
有了這兩個(gè)那就可以在nginx上干活了
進(jìn)入nginx配置目錄
/usr/local/etc/nginx/nginx.conf
一下是nginx配置:(注意看兩個(gè)server 的 fastcgi_pass:后面監(jiān)聽的端口)
9987->?127.0.0.1:9000 ->PHP5.6
9988->?127.0.0.1:9009 ->PHP7.1
server {
? ? ? ? listen? ? ?? 9987;
? ? ? ? server_name? localhost;
? ? ? ? #charset koi8-r;
? ? ? ? #access_log? logs/host.access.log? main;
? ? ? ? location / {
? ? ? ? ? ? root?? /Volumes/data/DockerTools/code/advanced_dev/frontend/web;
? ? ? ? ? ? index? index.php,index.html index.htm;
? ? ? ? ? ? try_files $uri $uri/ /index.php?$args;
? ? ? ? }
? ? ? ? #error_page? 404? ? ? ? ? ? ? /404.html;
? ? ? ? # redirect server error pages to the static page /50x.html
? ? ? ? #
? ? ? ? error_page?? 500 502 503 504? /50x.html;
? ? ? ? #location = /50x.html {
? ? ? ? #? ? root?? html;
? ? ? ? #}
? ? ? ? # proxy the PHP scripts to Apache listening on 127.0.0.1:80
? ? ? ? #
? ? ? ? #location ~ \.php$ {
? ? ? ? #? ? proxy_pass?? http://127.0.0.1;
? ? ? ? #}
? ? ? ? # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
? ? ? ? #
? ? ? ? location ~ \.php$ {
? ? ? ? ? ? root? ? ? ? ?? /Volumes/data/DockerTools/code/advanced_dev/frontend/web;
? ? ? ? ? ? fastcgi_pass?? 127.0.0.1:9000;
? ? ? ? ? ? fastcgi_index? index.php;
? ? ? ? ? ? fastcgi_param? SCRIPT_FILENAME? $document_root$fastcgi_script_name;
? ? ? ? ? ? include? ? ? ? fastcgi_params;
? ? ? ? }
? ? ? ? # deny access to .htaccess files, if Apache's document root
? ? ? ? # concurs with nginx's one
? ? ? ? #
? ? ? ? #location ~ /\.ht {
? ? ? ? #? ? deny? all;
? ? ? ? #}
? ? }
? ? server {
? ? ? ? listen 9988;
? ? ? ? server_name? boo.local.anlewo.com;
? ? ? ? #access_log? /log/frontend.local.anlewo.access.log? main;
? ? ? ? location / {
? ? ? ? ? ? root?? /Volumes/data/DockerTools/code/advanced_dev/frontend/web;
? ? ? ? ? ? index? index.php index.html index.htm;
? ? ? ? ? ? try_files $uri $uri/ /index.php?$args;
? ? ? ? }
? ? ? ? location ~ \.php$ {
? ? ? ? ? ? root? ? ? ? ?? /Volumes/data/DockerTools/code/advanced_dev/frontend/web;
? ? ? ? ? ? fastcgi_pass?? 127.0.0.1:9009;
? ? ? ? ? ? fastcgi_index? index.php;
? ? ? ? ? ? fastcgi_param? SCRIPT_FILENAME? $document_root$fastcgi_script_name;
? ? ? ? ? ? include? ? ? ? fastcgi_params;
? ? ? ? }
? ? }
截圖認(rèn)證: