赞
踩
先执行安装nginx+php8
mac电脑安装nginx+php_laocaibulao的博客-CSDN博客
后面发现还需要一个php7.4版本的
- #先看看php版本列表
- brew search php
-
- #安装php7.4
- brew install php@7.4
php8默认安装好了,php7.4安装后
php配置目录:/usr/local/etc/php/7.4/
php安装目录:/usr/local/opt/php@7.4/
php
1、创建目录
- cd ~/
- mkdir php_program
- cd php_program
- mkdir bin
- cd bin
php8安装目录:/usr/local/opt/php@8.1
php7安装目录:/usr/local/opt/php@7.4
2、创建软链接
- #看看安装目录下是否存在该版本
- ls /usr/local/opt/
-
- ln -s /usr/local/opt/php@7.4/bin/php ./php74
-
- ln -s /usr/local/opt/php@8.1/bin/php ./php81
3、将该目录写入环境变量
- echo 'export PATH="/Users/boolean/php_program/bin:$PATH"' >> ~/.bash_profile
- source ~/.bash_profile
-
-
- php74 -v
-
- php81 -v
修改配置
- #
- vim /usr/local/etc/php/7.4/php-fpm.d/www.conf
启动php7.4
brew services restart php@7.4
配置nginx
/usr/local/etc/nginx/servers/www.myphp7.com
- server {
- listen 80;
- server_name www.myphp7.com;
-
- location / {
- root /Users/boolean/myphp/www.myphp7.com;
- index index.html index.htm index.php;
- }
-
- #error_page 404 /404.html;
-
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
-
- #
- location ~ \.php$ {
- root /Users/boolean/myphp/www.myphp7.com;
- fastcgi_pass 127.0.0.1:9001;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
-
- }
- }

参考地址:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。