nginx+php5

aptgetinstallnginx apt-get install php5-fpm
修改配置文件:
/etc/nginx/sits-available/default
首先,在server下:

server {  
    listen 88 default_server;  
    listen [::]:88 default_server ipv6only=on;  

    root /usr/share/nginx/html;  
        #修改這裏,在 index 後添加 index.php  
    index index.php index.html index.htm;  

    # Make site accessible from http://localhost/  
    server_name localhost;  
        ....  

其次去掉部分註釋:

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  
#  
location ~ \.php$ {  
#   fastcgi_split_path_info ^(.+\.php)(/.+)$;  
#   # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini  
#  
#   # With php5-cgi alone:  
#   fastcgi_pass 127.0.0.1:9000;  
#   # With php5-fpm:  
    fastcgi_pass unix:/var/run/php5-fpm.sock;  
    fastcgi_index index.php;  
    include fastcgi_params;  
} 

最後重啓:

#重啓 php5-fpm  
sudo /etc/init.d/php5-fpm restart   
#重啓 nginx  
sudo /etc/init.d/nginx restart   

另外在/usr/share/nginx/html下添加index.php文件,內容爲:

<?php  

phpinfo();  

?> 

打開瀏覽器,在地址欄輸入:localhost或者localhost/inddex.php即可出現php頁面。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章