Ubuntu14.04LTS install LNMPNginx \ PHP5 (PHP-FPM) \ MySQL

Source: Internet
Author: User
Recently, an error occurred while installing the LNMP one-key installation package in Ubuntu14.04LTS. The PHP5 service was not started, so we had to use Ubuntu official source for installation: Nginx (pronunciation & ldquo; enginex & rdquo ;) free, open-source, and efficient HTTP Services. Nginx is known for its stability, rich functions, simple structure, and low resource consumption. This tutorial demonstrates how to install nginx and PHP5 (p

Recently, an error occurred while installing the LNMP one-key installation package in Ubuntu 14.04 LTS. The PHP 5 service was not started, so you had to use the Ubuntu official source for installation:

Nginx is a free, open-source, and efficient HTTP service. Nginx is known for its stability, rich functions, simple structure, and low resource consumption. This tutorial demonstrates how to install nginx, PHP5 (php-fpm), and MySQL on the ubuntu 14.04 server.

---------------------------------------- Split line ----------------------------------------

Install LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and set http://www.linuxidc.com/Linux/2013-06/86250.htm in Ubuntu 13.04

LNMP production environment construction and installation script http://www.linuxidc.com/Linux/2013-11/92428.htm under CentOS 6.4

Practical Production Environment: LNMP architecture compilation and installation + SSL encryption for http://www.linuxidc.com/Linux/2013-05/85099.htm

LNMP full-featured compilation installation for CentOS 6.3 note http://www.linuxidc.com/Linux/2013-05/83788.htm

CentOS 6.3 install LNMP (PHP 5.4, MyySQL5.6) http://www.linuxidc.com/Linux/2013-04/82069.htm

Http://www.linuxidc.com/Linux/2013-03/81120.htm of two problems with Nginx startup failure when deploying LNMP

Ubuntu install Nginx php5-fpm MySQL (LNMP environment setup) http://www.linuxidc.com/Linux/2012-10/72458.htm

---------------------------------------- Split line ----------------------------------------

1 prompt before installation

The host name used in this article is server1.example.com and IP address is 192.168.0.100. It may be different from your host. Modify it on your own.

During installation, we use the root account to switch users first:

Sudo su

2. Install MySQL 5 Database

Run the following command to install MySQL:

Apt-get install mysql-server mysql-client

During the installation process, you will be asked to create a Root account password and enter the password twice in a row:

New password for the MySQL "root" user: <-enter your password
Repeat password for the MySQL "root" user: <-enter it again

3. Install Nginx

Before installing Nginx, if you have already installed Apache2, delete it before installing nginx:

Service apache2 stop
Update-rc.d-f apache2 remove
Apt-get remove apache2

Apt-get install nginx

Start the nginx service:

Service nginx start

Check whether the installation is successful. Enter the IP address or host address (e.g. http: // 192.168.0.100) in the browser, as shown in. The installation is successful:

In Ubuntu 14.04, the default root directory is/usr/share/nginx/html.

4. Install PHP5

We must pass the PHP-FPM to make PHP5 work properly, install the command:

Apt-get install php5-fpm

Php-fpm is a daemon.

5 configure nginx

Use Vi to open the configuration file/etc/nginx. conf:

Vi/etc/nginx. conf

Configuration is not easy to understand, refer to: http://wiki.nginx.org/nginxfullexampleand http://wiki.nginx.org/NginxFullExample2

We need to adjust the Worker Process count settings, as shown in the following values:

[...]worker_processes  4;[...]    keepalive_timeout   2;[...]

The default virtual host setting file/etc/nginx/sites-available/default is set as follows:

Vi/etc/nginx/sites-available/default

[...]server {        listen 80;        listen [::]:80 default_server ipv6only=on;        root /usr/share/nginx/html;        index index.php index.html index.htm;        # Make site accessible from http://localhost/        server_name _;        location / {                # First attempt to serve request as file, then                # as directory, then fall back to displaying a 404.                try_files $uri $uri/ /index.html;                # Uncomment to enable naxsi on this location                # include /etc/nginx/naxsi.rules        }        location /doc/ {                alias /usr/share/doc/;                autoindex on;                allow 127.0.0.1;                allow ::1;                deny all;        }        # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests        #location /RequestDenied {        #       proxy_pass http://127.0.0.1:8080;        #}        #error_page 404 /404.html;        # redirect server error pages to the static page /50x.html        #        error_page 500 502 503 504 /50x.html;        location = /50x.html {                root /usr/share/nginx/html;        }        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000        #        location ~ .php$ {                try_files $uri =404;                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;        }        # deny access to .htaccess files, if Apache's document root        # concurs with nginx's one        #        location ~ /.ht {                deny all;        }}[...]

Cancel listening for IPv4 addresses at the same timeAndPort 80 of IPv6.

Server_name _; default Host Name (you can modify it, for example, www.example.com ).

Index. php is added to the line on the index homepage.

Important PHP configuration location ~ The. php $ {} line needs to be started and commented out. Add another row: try_files $ uri = 404.

(Other configuration viewing http://wiki.nginx.org/Pitfalls#Passing_Uncontrolled_Requests_to_PHP and http://forum.nginx.org/read.php? 2, 88845, page = 3 ).

Save the file and reload the nginx command:

Service nginx reload

If loading fails, delete all configurations and replace them with the preceding information.

For more details, refer to the highlights on the next page.: Http://www.linuxidc.com/Linux/2014-05/102351p2.htm

Related Article

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.