编译参数:
./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --with-curl --with-mcrypt --enable-mbstring --enable-pdo --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --with-openssl --with-imap-ssl --with-gd --with-jpeg-dir=/usr/lib/ --with-png-dir=/usr/lib/ --enable-exif --enable-zip
sudo cp php.ini-development /usr/local/php/lib/php.ini
sudo ln -s /usr/local/php/bin/php /usr/bin/php
sudo cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
设置php-fpm.conf,去掉以下参数前面的;
sudo vi /usr/local/php/etc/php-fpm.conf
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
pm.start_servers=
pm.min_spare_servers=
pm.max_spare_servers=
设置开机自启动
sudo cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
sudo chmod 755 /etc/init.d/php-fpm
sudo update-rc.d php-fpm defaults
sudo /usr/local/php/sbin/php-fpm
编辑nginx配置文件
sudo vi /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name localhost;
rewrite_log on;
#rewrite ^/(([0-9]+.)+[0-9]+)/ /$1/www/index.php last;
location / {
root html;
index index.html index.htm index.php;
autoindex on;
}
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}
}
sudo killall nginx
sudo /etc/init.d/nginx
nginx服务器解析不了php,报404错误,解决方法:
修改nginx/conf/nginx.conf文件中对应的php配置部分
fastcgi_param这个参数默认的是$fastcgi_script_name;最好改为$document_root$fastcgi_script_name;我在实际配置中出 现了php找不到需要解析文件而返回404或者500错误的问题。所以最好是带上网站根目录的路径变量$document_root。