您的位置:首页 > 运维架构 > Nginx

【ubuntu】 nginx配置php&wordpress

2014-06-12 14:43 435 查看


安装nginx


sudo su

apt-get install nginx
安装php

apt-get install php5
安装php5-cgi

apt-get install  php5-cgi


安装spawn-fcgi

apt-get install spawn-fcgi
启动fastcgi

/usr/bin/spawn-fcgi.standalone -a 127.0.0.1 -p 9000 -C 8 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid
启动成功则显示:spawn-fcgi: child spawned successfully: PID: 17686

修改nginx配置 我的nginx配置文件在(/opt/nginx/conf/nginx.conf)

vim /opt/nginx/conf/nginx.conf
其中有一段配置php的被注释掉了,取消掉注释。

location ~ \.php$ {
#  root           html;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME  <span style="background-color: rgb(255, 0, 0);">/opt/nginx/html</span>$fastcgi_script_name;  (红色部分为html文件的路径即根目录)
include        fastcgi_params;
}


测试php

cd /opt/nginx/html
vim test.php
<?php phpinfo(); ?>   '将这句话写在文件test.php文件中 http://localhost/test.php '在浏览器中输入此路径,可看到php信息页面

安装wordpress

cp /var/www/wordpress /opt/nginx/html   '就是将wordpress文件复制到html文件中去
 http://localhost/wordpress//wp-admin/install.php '浏览器中输入该网址进行安装


安装好后若报错 an error occured    Sorry, the page you are looking for is currently unavailable. Please try again later

解决:看 php-fpm是否有开启

netstat -lnp | grep php-fpm
若没有启动,启动php-fpm

/etc/init.d/php-fpm start
重启好后刷新页面会显示wordpress安装成功。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux php5 nginx php wordpress