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信息和用户名密码即可使用了。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律