1. 安装
sudo apt-get update
sudo apt-get install nginx php5-fpm php5-cli php5-curl php5-gd php5-mcrypt php5-mysql php5-cgi mysql-server'
2. 配置
进入/etc/nginx/sites-enabled,删除原default,新建一个文件,名字随意,输入以下
# Upstream to abstract backend connection(s) for php
upstream php {
server unix:/var/run/php5-fpm.sock;
}
server {
## Your only path reference.
root /home/pi/wordpress;
listen 80;
## Your website name goes here. Change to domain.ltd in VPS
server_name _;
access_log /home/pi/wordpress/logs/access.log;
error_log /home/pi/wordpress/logs/error.log;
## This should be in your http block and if it is, it's not needed here.
index index.html index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
try_files $uri =404;
fastcgi_intercept_errors on;
fastcgi_pass php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
unix:/var/run/php5-fpm.sock 为php-fpm的链接,其位置定义在/etc/php5/fpm/pool.d/www.conf的listen中
当php启动后,在/var/run中会产生这么一个sock文件
然后 复制一份到/etc/nginx/sites-available中
其他配置参考
http://www.w3c.com.cn/%E6%A0%91%E8%8E%93%E6%B4%BE-%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AAnginxphpmysqldnspod%E5%8A%A8%E6%80%81%E8%A7%A3%E6%9E%90-%EF%BC%88%E8%BD%AC%EF%BC%89
3. 权限
网页的目录需要赋予给www-data这个用户,首先可以 将这个用户 加入到root组
<span style="white-space:pre"> </span>gpasswd -a user root
<span style="white-space:pre"> </span>chown root:www-data wordpress/ -R
<span style="white-space:pre"> </span>chmod 755 wordpress/ -R
使用su www-data 切换用户后,如果能正常访问网页目录就可以了
CGI配置:/etc/php5/fpm/pool.d/www.conf
PS: 如果不能访问,可能是低级目录限制,也要考虑
3. 重启
service nginx restart
service php5-fpm restart
4. mysql
配置参看
http://blog.csdn.net/csharpgame/article/details/9386799
忘记密码
http://blog.sina.com.cn/s/blog_759a5a7c01017dj0.html
参考
http://www.guokr.com/post/332043/