OSETC TECH

Linux: How To Install Linux, Nginx, MySQL And PHP (LEMP) On Ubuntu 14.04 LTS

I would like to set up a web service server so I want to install nginx, MySQL, and PHP statck on my ubuntu linux 14.04 LTS. How do I install the LEMP statck under my ubuntu linux system? How Can I install Ngnix web server, MySQL server and PHP server on linux system? this post will guide you how to install nginx, MySQL and PHP on ubuntu linux 14.04 LTS.

Nginx Installation


​You can run the following command to install Nginx package ,type:

sudo apt-get install nginx

After installed it, run the following command to start Nginx service ,tyep:

sudo service nginx start

Test Nginx

Open your firefox browser, and input the following address: http://127.0.0.1/, you will see the welcome page of nginx server.just like below:

MySQL Installation


Type the following command to install mysql server on ubuntu system:

sudo apt-get install mysql-server mysql-client php5-mysql

You will be asked to enter the pasword for mysql root user while mysql installation.

Then issue the following command to check the MySQL server status,type:

sudo service mysql status

Last steps, running the MySQL setup script for securing mysql,type:

sudo /usr/bin/mysql_secure_installation

The prompt will ask you to enter your current root password.

Just say yes for all others prompt options, at the end , MySQL will reload and implement the new changes.

By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them.  This is intended only for testing, and to make the installation go a bit smoother.  You should remove them before moving into a production environment.

Remove anonymous users? [Y/n] y                                            

 ... Success!

Normally, root should only be allowed to connect from ‘localhost’.  This ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y

... Success!

By default, MySQL comes with a database named ‘test’ that anyone can access.  This is also intended only for testing, and should be removed before 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 will ensure that all changes made so far will take effect immediately.

Reload privilege tables now? [Y/n] y

 ... Success!

Cleaning up...

PHP Installation


Type the following command to download and install PHP package,enter:

sudo apt-get install php5 php5-fpm php5-mysql

Configure PHP

open php.ini configuration file via vim command:

sudo vim /etc/php5/fpm/php.ini

find the line “cgi.fix_pathinfo=1‘, and uncomment it and change it’s value to 0.

cgi.fix_pathinfo=0

restart php-fpm service by issue the following command:

sudo service php5-fpm restart

done …