The easiest way to build a nginx and PHP environment in Ubuntu

Source: Internet
Author: User
Tags fpm php file

This article mainly introduced the Ubuntu constructs the Nginx, the PHP environment simplest method, this article explained is uses the Apt-get tool to install Nginx, the PHP environment, and explained the basic configuration, needs the friend may refer to under

-->

Foreword: The result of Baidu comes out good pit daddy, and some articles say others pit father, but he also pit father himself. Ask the industry's conscience. Google is still a reliable.

System environment: Ubuntu 13 and Linux Mint 15 are all through.

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 it really was enough to just install these two things.

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 editing, you should edit the default file under Site-available, if you are under Edit site-enabled default, because Gedit save will generate a "default~" Backup, This backup will also be nginx as an enabled profile and an error cannot be started. The insurance practice is to edit the files under site-available and still manually delete the backup files.

Find location ~. php$ Place, 5 lines uncomment, become this:

The code is as follows:
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;
}

That's it!

Start Nginx:

The code is as follows:
sudo service nginx start
Extended:

1. Default file, find

The code is as follows:
Index index.html index.htm;
This line, joined into
The code is as follows:
Index index.html index.htm index.php;
This can be done with PHP file default home page

2.default file, in the location/{} designator of the server{} designator, join

The code is as follows:
AutoIndex on;
When there is no index file in the folder, the file is automatically indexed.

3. The root row of the server{} indicator is the root of the file, and can be modified to take that folder as the root of the site

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.