Ubuntu Installation Lnmp

Source: Internet
Author: User
Tags fpm install php mysql tutorial vps ssl certificate virtual private server

How to Install Linux, Nginx, MySQL, PHP (LEMP) stacks on Ubuntu 12.04PostedJune, 802.8k views LEMP NGINX MYSQL PHP UBUNTU This tutorial are for Ubuntu 12.04 is your server also running Ubuntu 12.04? This tutorial may also is available for Ubuntu 14.04 and 16.0412.04 (this tutorial) Go to 14.04Go to 16.04 about Lemp

LEMP Stack is a group of open source software to get Web servers up and running. The acronym stands for Linux, nginx (pronounced Engine x), MySQL, and PHP. Since the server is already running Ubuntu, the Linux part was taken care of. Here's how to install the rest.

Setup

The steps tutorial require the user to has root privileges. You can see how to set the-in-Initial Server Setup Tutorial in steps 3 and 4.

Step one-update Apt-get

Throughout this tutorial we'll be using Apt-get as a installer for all the server programs. On could 8th, a serious PHP vulnerability was discovered, and it's important that we download all of the latest patch Ed software to protect the virtual private server.

Let's do a thorough update.

sudo apt-get update
Step Two-install MySQL

MySQL is a powerful database management system used for organizing and retrieving data

To install MySQL, open terminal and type in these commands:

sudo apt-get install mysql-server php5-mysql

During the installation, MySQL would ask you to set a root password. If you miss the chance to set the password and the program is installing, it's very easy-to-set the password later from Within the MySQL shell.

Once you has installed MySQL, we should activate it with the This command:

sudo mysql_install_db

Finish up by running the MySQL set up script:

Sudo/usr/bin/mysql_secure_installation

The prompt would ask you to your current root password.

Type it in.

Enter current password to root (enter for none): OK, successfully used password, moving on ...

Then the prompt would ask if you want the root password. Go ahead and choose N and move on to the next steps.

It ' s easiest just to say Yes to the options. At the end, MySQL would reload and implement the new changes.

By default, a MySQL installation had an anonymous user, allowing Anyoneto logs into MySQL without had to had a user ACC  Ount created Forthem.  This was intended only for testing, and the Installationgo a bit smoother. You should remove them before moving into aproduction environment. Remove anonymous users? [y/n] Y ... success!  Normally, Root should only is allowed to connect from ' localhost '. Thisensures that someone cannot guess at the root of password from the network. Disallow Root login remotely? [y/n] Y ... success!  By default, MySQL comes with a database named ' test ' that anyone canaccess. This was also intended only for testing, and should was removedbefore moving into a production environment. Remove test database and access to it? [y/n] y-dropping Test Database ... success! -Removing privileges on test database ... success! Reloading the privilege tables would ensure that all changes made so farwill take effect immediately. REload privilege tables now? [y/n] Y ... success! Cleaning up ...

Once you ' re do with that can finish up by installing PHP.

Step Three-install Nginx

Once MySQL is all set up and we can move on to installing Nginx on the VPS.

echo "Deb Http://ppa.launchpad.net/nginx/stable/ubuntu $ (LSB_RELEASE-SC) main" | sudo tee/etc/apt/sources.list.d/nginx-stable.listsudo apt-key adv--keyserver keyserver.ubuntu.com--recv-keys C300ee8csudo apt-get updatesudo apt-get Install Nginx

Nginx does not-start on its own. To get Nginx running, type:

sudo service nginx start

You can confirm this nginx has installed a your Web server by directing your browser to your IP address.

You can run the following command to reveal your VPS ' s IP address.

Ifconfig eth0 | grep inet | awk ' {print $} '
Step Four-install PHP

To install the PHP-FPM, open terminal and type in these commands. We'll configure the details of Nginx and PHP details in the next step:

sudo apt-get install PHP5-FPM
Step five-configure Phpwe need to make one small change in the PHP configuration. Open up php.ini:
sudo nano/etc/php5/fpm/php.ini
Find the line, cgi.fix_pathinfo=1, and change the 1 to 0.
Cgi.fix_pathinfo=0
If This number is kept as 1, the PHP interpreter would do it best to process the file, which is as near to the requested Fil e as possible. This is a possible security risk. If This number was set to 0, conversely, the interpreter would only process the exact file path-a much safer alternative. Save and Exit. We need to make another small change in the PHP5-FPM configuration. Open up www.conf:
sudo nano/etc/php5/fpm/pool.d/www.conf
Find the line, listen = 127.0.0.1:9000, and change the 127.0.0.1:9000 to/var/run/php5-fpm.sock.
Listen =/var/run/php5-fpm.sock

Save and Exit.

Restart PHP-FPM:

sudo service php5-fpm restart
Step six-configure Nginx

Open up the default virtual host file.

sudo nano/etc/nginx/sites-available/default

The configuration should include the changes below (the details of the changes are under the config information):

Update:newer Ubuntu versions Create a directory called ' HTML ' instead of ' www ' by default. If/usr/share/nginx/www does not exist, it ' s probably called HTML. Make sure update your configuration appropriately.

[...] server {        listen   ;             root/usr/share/nginx/www;        Index index.php index.html index.htm;        server_name example.com;        Location/{                try_files $uri $uri//index.html;        }        Error_page 404/404.html;        Error_page 502 503 504/50x.html;        Location =/50x.html {              root/usr/share/nginx/www;        }        # Pass the PHP scripts to FastCGI server listening on the PHP-FPM socket location        ~ \.php$ {                try_files $uri =404 ;                Fastcgi_pass Unix:/var/run/php5-fpm.sock;                Fastcgi_index index.php;                Fastcgi_param script_filename $document _root$fastcgi_script_name;                Include Fastcgi_params;                        }} [...]

Here is the details of the changes:

    • ADD index.php to the index line.
    • Change the server_name from local host to your domain name or IP address (replace the example.com in the configuration)
    • Change the correct lines in ' location ~ \.php$ {' section

Save and Exit

Step seven-create a php Info Page

We can quickly see all of the details of the new PHP configuration.

To set the this up, first create a new file:

sudo nano/usr/share/nginx/www/info.php
ADD in the following line:
<?phpphpinfo ();? >

Then Save and Exit.

Restart Nginx

sudo service nginx restart

You can see the Nginx and PHP-FPM configuration details by visiting http://youripaddress/info.php

Your LEMP Stack is now set up and configured on Your virtual Private server.

See more

After installing LEMP, you can Install the WordPress, go on to does more with MySQL (A Basic MySQL Tutorial) or Install Phpmyadm In, Create a SSL Certificate, or Install an FTP Server.

Ubuntu Installation Lnmp

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.