ubuntu安裝nginx+php

1.安裝nginxphp

 

aptitude search nginx
sudo apt-get install nginx

 

2.安裝phpnginx

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

 

3.配置nginxphp-fpm

個人nginx安裝路徑爲/etc/nginx測試

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

增長php fastcgi的配置:把php解析發送給本機的9000端口this

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-fpmspa

個人php5-fpm安裝在/etc/php5/fpmunix

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

修改listener配置爲rest

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

 

5.啓動nignxcode

sudo service nginx start
或
sudo service nginx restart

訪問127.0.0.1或者localhost,能正常訪問說明nginx正常啓動了orm

 

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

如正常訪問則配置成功

相關文章
相關標籤/搜索