ubuntu安装nginx+php

1.安装nginx

 

aptitude search nginx
sudo apt-get install nginx

 

2.安装php

sudo apt-get install php5
sudo apt-get install php5-fpm

 

3.配置nginx

我的nginx安装路径为/etc/nginx

sudo gedit /etc/nginx/sites-available/default

增加php fastcgi的配置:把php解析发送给本机的9000端口

location ~ \.php$ {
        root /var/www;
        fastcgi_pass 127.0.0.1:9000;
    #    # With php5-fpm:
    #    fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

 

4.配置php-fpm

我的php5-fpm安装在/etc/php5/fpm

 sudo gedit /etc/php5/fpm/pool.d/www.conf 

修改listener配置为

; listen = /var/run/php5-fpm.sock
listen = 127.0.0.1:9000

 

5.启动nignx

sudo service nginx start
或
sudo service nginx restart

访问127.0.0.1或者localhost,能正常访问说明nginx正常启动了

 

6.启动php-fpm

sudo service php5-fpm start
或
sudo service php5-fpm restart

 

7.新建php文件,保存为/var/www/test/first.php

<?php
/**
 * Created by JetBrains PhpStorm.
 * To change this template use File | Settings | File Templates.
 */
phpinfo();

 

8.测试

访问localhost/test/first.php

如正常访问则配置成功

posted @ 2013-09-02 16:24  iaac  阅读(299)  评论(0编辑  收藏  举报