The simplest way to build Ubuntu+Nginx+PHP

  

Foreword: Baidu's results are very good, and some articles say that others are pitted, but he himself is also pitted. Seek the conscience of the industry. Still Google is reliable.

System Environment: Both Ubuntu 13 and Linux Mint 15 pass.

The default installation is nginx 1.2.5, php5.4.9

Install first:

sudo apt-get install nginx php5-fpm

I am Tested on the newly installed Ubuntu13, really only install these two things is enough.

Then edit the configuration file.

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

Note that if you edit with gedit instead of vi, you should edit the default file under site-available, if it is edit The default under site-enabled, because gedit saves by default will generate a backup of "default" & rdquo; this backup will also be used as an enabled configuration file by nginx and error can not be started. The insurance practice is to manually delete the backup file after editing the file under site-available.

Find the location ~ \\.php$, 5 lines uncomment, become like this:


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;}This becomes! 


Starting nginx:

sudo service nginx start

Extension:

1. In the default file, find index index.html index.html ;

This line is added to

index index.html index.htm index.php;

This allows you to use the php file as the default home page

In the 2.default file, in the location{ { indicator of the server{} indicator, add

autoindex on;

When there is no index file in the folder, the file will be automatically indexed. .

3. The root line of the server{} indicator is the root directory of the file. You can modify that folder as the root directory of the website.

Reference: http://ubuntuhandbook.org/index .php/2013/10/install-nginx-php5-mysql-lemp-ubuntu-1310/

Please indicate the source: http://blog.csdn.net/hursing

Copyright © Windows knowledge All Rights Reserved