cd /usr/local/ tar zxvf nginx-x.x.x.tar.gz cd nginx-x.x.x
./configure make make install
nginx
nginx -h
tar zxf php-x.x.x
在此步骤您可以使用很多选项自定义 PHP,例如启用某些扩展等。 运行 ./configure --help 命令来获得完整的可用选项清单。 在本示例中,我们仅进行包含 PHP-FPM 和 MySQL 支持的简单配置。
cd ../php-x.x.x ./configure --enable-fpm --with-mysql make sudo make install
cp php.ini-development /usr/local/php/php.ini cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf
在启动服务之前,需要修改 php-fpm.conf 配置文件,确保 php-fpm 模块使用 www-data 用户和 www-data 用户组的身份运行。
vim /usr/local/etc/php-fpm.conf
找到以下内容并修改:
; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. user = www-data group = www-data
然后启动 php-fpm 服务:
php-fpm
本文档未涵盖对 php-fpm 进行进一步配置的信息,如果您需要更多信息,请查阅相关文档。
vim /usr/local/nginx/conf/nginx.conf
修改默认的 location 块,使其支持 .php 文件:
location / { root html; index index.php index.html index.htm; }
下一步配置来保证对于 .php 文件的请求将被传送到后端的 PHP-FPM 模块, 取消默认的 PHP 配置块的注释,并修改为下面的内容:
location ~* \.php$ { fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; }
sudo nginx -s stop sudo nginx
rm /usr/local/nginx/html/index.html echo "<?php phpinfo(); ?>" >> /usr/local/nginx/html/index.php
打开浏览器,访问 http://localhost
1. 先检车 wp_users 数据库表中是否有用户,没有则添加,ID一般为 1 。
2. 编辑 wp-includes/user.php 找到 wp_check_password ,把if条件判断相关几行注释掉。登陆之后修改密码,再打开注释。
在 wp-config.php 最后新增 下面的代码
if(is_admin()) { add_filter('filesystem_method', create_function('$a','return "direct";' )); define('FS_CHMOD_DIR', 0751); }
本文对PHP的安装部分稍有省略,详见官网文档。
PHP + Nginx 官方安装:http://php.net/manual/zh/install.unix.nginx.php