Mac install Php and Wordpress
一、安装php 并配置nginx
参考:https://kittmedia.com/en/2021/macos-install-nginx-mysql-and-php-via-brew/
https://ecom-guru.com/setting-up-nginx-php-and-mysql-on-mac/
brew install php@7.4
below is the finish output:
To enable PHP in Apache add the following to httpd.conf and restart Apache: LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> Finally, check DirectoryIndex includes index.php DirectoryIndex index.php index.html The php.ini and php-fpm.ini file can be found in: /usr/local/etc/php/8.2/ To restart php after an upgrade: brew services restart php Or, if you don't want/need a background service you can just run: /usr/local/opt/php/sbin/php-fpm --nodaemonize
配置文件在这里:/usr/local/etc/php/8.2/
php和nginx可以用unix domain socket或TCP IP端口通讯,两者的区别和优缺点见:https://www.tecmint.com/connect-nginx-to-php-fpm/
这里我采用tcp/ip网络端口的方式。
修改nginx配置文件:vi /usr/local/etc/nginx/nginx.conf
a) 把server的port从8080改成80
b)把location / 中的index加上index.php
c) 添加如下配置:
location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
d) 可以在/usr/local/var/www 中添加index.php 测试下。
e) 启动nginx和php
brew services start nginx ; brew services start php
二、安装wordpress
1. 创建mysql数据库。省略
2. 直接输入:localhost/wordpress,即可进入wordpress的配置,设置了db信息和用户名密码即可使用了。