There are some tutorials on the internet, such as LNMP configuration 1, LNMP configuration 2, I myself refer to the experience of the great God, I downloaded an Ubuntu kylin15.10 version, and configured from beginning to end, fill in a few possible pits, write down this is a detailed tutorial, suitable for Linux novice reference.
First, there are a few Linux commands to be familiar with, the next configuration to improve efficiency, personally recommended 20 common Linux commands, ls,find,cd,cat,vim,gedit,touch,mkdir,mv,rm These commands can be familiar with or recall.
Often start with sudo to ensure security, if you feel bored, you can use the sudo su command to switch to the highest privilege.
Note that here is the Ubuntu yklin15.10 version, the online reference is also more, 16.10 of the source to install PHP is php7.0, and will be installed apache2. This article takes Ubuntu yklin15.10 as an example.
First step: Enter the command sudo apt-get update
Just download a good Ubuntu kylin15.10 general source is no problem, first updated with the command.
If the source has a problem, go to sudo vim/etc/apt/sources.list to modify the source.
Step Two: Install Nginx
Run sudo apt-get install Nginx (nginx version 1.9.3),
Run Sudo/etc/init.d/nginx start (or service Nginx start) to start the Nginx service.
After this step is completed, you can use the command dpkg-s nginx to view the version information, and the URL input localhost, you will see the Welcome to nginx! page.
If prompted Upable to locate the package Nginx, carefully check if there is a wrong word.
Step Three: Install PHP
Run sudo apt-get install php5 php5-cli php5-cgi php5-mysql (PHP 5.6.11 version).
Similarly, after installation, you can use the command dpkg-s PHP to view the version information.
Fourth step: Install MySQL
Running sudo apt-get install mysql-server mysql-client (MySQL 5.6.27) Prompts for the root account password.
After installation, enter the command mysql-u root-p, enter the password to enter the MySQL database.
Here, there may be a situation where there is no way to go, denied for user ' root ' @ ' localhost '.
Cause: MySQL generated a random password for the user.
The workaround is to run/ETC/MYSQL/DEBIAN.CNF first, using the user name it provides, typically debian-sys-main, and note the random password, which is a string of characters.
Run Mysql-u debian-sys-maint-p and enter the Welcome page with the password provided.
The next step is to change the password:
Use MySQL table:
mysql> use MySQL;
Modify the root user's password:mysql> update user set Password=password (' root ') where user= ' root ';
To make effective:
mysql> flush Privileges;
Quit with a quit command.
This way, the next time you go in, use mysql-u root-p command and root password to go in.
Run Grant all on * * to [email protected] '% ' identified by ' 123456 '; Change the permissions of the database user.
Run flush privileges; Refresh lets permissions take effect.
Run sudo vim/etc/mysql/mysql.conf.d/mysqld.cnf the bind-address = 127.0.0.1 preceded by a # number to comment out, you can connect to the database remotely.
Fifth Step: Install PHP5-FPM
Run sudo apt-get install PHP5-FPM
If the version of 16.10 is installed, the input command is sudo apt-get install php7.0
Finally, the configuration and testing, the direct copy can be:
Sixth Step: Configure nginx.conf
Configure/etc/nginx/nginx.conf
sudo cp/etc/nginx/nginx.conf/etc/nginx/nginx.conf.bak
sudo gedit/etc/nginx/nginx.conf
Search text worker_processes find worker_processes auto; worker_processes 4;
Search text keepalive_timeout find keepalive_timeout 65; change to Keepalive_timeout 2;
Seventh Step: Configure Nginx to use the PHP-FPM process
sudo cp/etc/nginx/sites-available/default/etc/nginx/sites-available/default.bak
sudo gedit/etc/nginx/sites-available/default
Change as follows, direct copy replace
server {
Listen default_server;
Listen [::]:80 default_server Ipv6only=on;
root/usr/share/nginx/html;
Index index.php index.html index.htm;
server_name server_domain_name_or_ip;
Location/{
Try_files $uri $uri/= 404;
}
Error_page 404/404.html;
Error_page 502 503 504/50x.html;
Location =/50x.html {
root/usr/share/nginx/html;
}
Location ~ \.php$ {
Try_files $uri = 404;
Fastcgi_split_path_info ^ (. +\.php) (/.+) $;
Fastcgi_pass Unix:/var/run/php5-fpm.sock;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
}
}
Reload Nginx
Service Nginx Reload
Eighth Step: Configure PHP, modify the php.ini file
sudo gedit/etc/php5/fpm/php.ini
Set, cancel semicolon; change 1 to 0
Cgi.fix_pathinfo=0:
Reload PHP-FPM:
Service PHP5-FPM Reload
Next is the test:
1. Test PHP
Create the probe file info.php to the/usr/share/nginx/html directory
sudo gedit/usr/share/nginx/html/info.php
<?php
Phpinfo ();
?>
Browser access probe file http://127.0.0.1/info.php
If a PHP version message appears stating that the configuration was successful
2. Test MySQL
Create the test file sqltest.php to the/usr/share/nginx/html directory
sudo gedit/usr/share/nginx/html/sqltest.php
<?php
$link =mysql_connect ("localhost", "root", "root");
if (! $link) echo "faild!";
else echo "ok!";
?>
Visit http://127.0.0.1/sqltest.php
If the OK character appears, the MySQL configuration succeeds.
Generally this way down, you can successfully build Lnmp on Ubuntu kylin15.10.
If you do not use the command line, you can use Phpstudy.
CentOS is generally built with Yum, and the online information is quite complete.
Virtual machine software is recommended for VMware Workstation and Oracle VM VirtualBox are installed, in the event of an unresolved problem, consider a different image before you can consider a different virtual machine software to try.
This article is from the "Flying Potato God teach" blog, please be sure to keep this source http://1105190775.blog.51cto.com/10048144/1873279
From scratch: Ubuntu kylin15.10 installation LNMP Environment detailed tutorial