The simplest way to build an nginx and PHP environment in Ubuntu
This article mainly introduces the simplest way to build nginx and PHP environment in Ubuntu, this article explains the use of Apt-get tools to install Nginx, PHP environment, and explain the basic configuration, the need for friends can refer to the next
Preface: Baidu came out of the results good pit Dad, and some articles said others pit dad, but he also pit dad. Seek the conscience of the industry. Google is still a reliable.
System environment: Ubuntu 13 and Linux Mint 15 are all passed.
The default installation is Nginx 1.2.5,php5.4.9
Install First:
The code is as follows:
sudo apt-get install Nginx php5-fpm
I tested it on the newly installed Ubuntu13, and really just installed these two things just enough.
Then edit the configuration file.
The code is as follows:
sudo gedit/etc/nginx/site-available/default
Note that if you are using gedit instead of VI to edit, you should edit the default file under Site-available, if it is the default under Edit site-enabled, because gedit save will generate a "default~" backup. This backup will also be treated as an enabled configuration file and the error cannot be started. It is an insurance practice to manually delete the backup files after editing the files under Site-available.
Find Location ~ \.php$, 5 lines uncomment, change to this:
The code is as follows:
Location ~ \.php$ {
# Fastcgi_split_path_info ^ (. +\.php) (/.+) $;
# # Note:you should has "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;
}
That's it!
Start Nginx:
The code is as follows:
sudo service nginx start
Extended:
1. In the default file, locate
The code is as follows:
Index index.html index.htm;
This line, added into
The code is as follows:
Index index.html index.htm index.php;
This allows you to use PHP files as the default home page.
2.default file, within the location/{} indicator of the server{} indicator, add
The code is as follows:
AutoIndex on;
When there is no index file in the folder, the file is automatically indexed.
3. The root line of the server{} indicator is the root of the file and can be used as the root directory of the Web site by modifying itself
http://www.bkjia.com/PHPjc/963979.html www.bkjia.com true http://www.bkjia.com/PHPjc/963979.html techarticle The simplest way to build an nginx and PHP environment in Ubuntu This article mainly introduces the simplest way to build nginx and PHP in Ubuntu, and this article explains the installation of Nginx using the Apt-get tool 、...