hankcs写的test.php竟然直接被浏览器下载了下来,没有被解析。回顾一下我的做法,从零开始,运行下列命令:
1
2
3
4
5
6
|
sudo add-apt-repository
ppa:nginx /stable
sudo apt-get
update
sudo apt-get install nginx
sudo /etc/init .d /nginx start
sudo apt-get install php5-cli
php5-cgi php5-fpm php5-mcrypt php5-mysql
sudo vi /etc/nginx/sites-available/default
|
修改了/etc/nginx/sites-available/default
1
2
3
4
5
6
7
8
|
index
index.html index.htm index.php;
location
~ .php$ {
fastcgi_pass
127.0.0.1:9000;
fastcgi_index
index.php;
include
fastcgi_params;
}
|
去掉了location ~ .php$ {这一段的注释,然后访问http://localhost/test.php,发现弹出下载框框。于是找了无数前人留下的解决方法,发现都无法解决问题。就在自己要暴走的时候灵光一闪,看了看自己开的端口:
1
2
3
4
5
6
7
8
9
10
|
root@ubuntu: /home/hankcs
激活Internet连接
(仅服务器)
Proto
Recv-Q Send-Q Local Address Foreign Address State PID /Program name
tcp
0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1060 /nginx
tcp
0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1081 /dnsmasq
tcp
0 0 127.0.0.1:631 0.0.0.0:* LISTEN 834 /cupsd
tcp
0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1442 /php-fpm .conf)
tcp
0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 987 /mysqld
tcp6
0 0 :::80 :::* LISTEN 1060 /nginx
tcp6
0 0 ::1:631 :::* LISTEN 834 /cupsd
|
妹的看到没有!1442/php-fpm.conf用的根本就不是9000端口,这注释是在玩我呢。下面的解决方法就很简单了,把fastcgi_pass 127.0.0.1:9000;改成fastcgi_pass 127.0.0.1:3306;(当然你的机器上不一定就是3306,自己对号入座),保存刷新:

0 0