之前使用Ubuntu Server 12.04.成功安装了LNMP,并且用得不错。然后我就在我得本机环境上安装了Ubuntu 12.10 desktop版本。
按照我这篇文章来安装LNMP。见 http://www.linuxidc.com/Linux/2012-12/75438.htm
可是等我安装成功之后发现http://localhost能够正常出现 welcome to nginx 的画面,然后我就写了个php的探针文件,可是这下报错了。502.。。
这下我就郁闷了。。。为什么呢?
首先来让我们看看之前得配置。关于PHP一块的配置。
- location ~ \.php$ {
- try_files $uri =404;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- include fastcgi_params;
- }
问题其实出现在 fastcgi_pass得配置上面。
在ubuntu 12.10安装了php5-fpm之后。我们可以去
- /etc/php5/fpm/pool.d/www.conf
里面找到这样一条代码:
- listen = /var/run/php5-fpm.sock
这个是使用unix得方式来使用php5-fpm得。
这个时候。我们得php配置要改成
- location ~ \.php$ {
- fastcgi_pass unix:/var/run/php5-fpm.sock;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
- }
这里fastcgi_pass的地址要改成这个。。这样你的lnmp就正常了。
