Debian to install the LNMP (Linux/Nginx/MySQL/PHP) environment

Source: Internet
Author: User
Tags chmod create directory mkdir create database mysql database
1. Update the installation environment
Before installing this Web application, we need to update the latest system software package and run the following command line.
The code is as follows: Copy code
Sudo apt-get update
Sudo apt-get upgrade

2. Install the Nginx WEB server environment

The code is as follows: Copy code
Sudo apt-get install nginx
3. Configure the Nginx virtual host
Create a directory similar to/etc/nginx/sites-available/111cn. org in the/etc/nginx/sites-available/directory to store the configuration file.
The code is as follows: Copy code
Server {
Listen 80;
Server_name www.111cn.net;
Access_log/srv/www/111cn. org/logs/access. log;
Error_log/srv/www/111cn. org/logs/error. log;
Location /{
Root/srv/www/111cn. org/public_html;
Index index.html index.htm;
}
}
The above files are saved as 111cn. org files and uploaded to the/etc/nginx/sites-available/directory.
Create directory:
The code is as follows: Copy code
Sudo mkdir-p/srv/www/111cn. org/public_html
Sudo mkdir-p/srv/www/111cn. org/logs
It is used to store the files and logs of the corresponding website. If it is another domain name, it is also similar to the creation. Run the following command to enable website creation and restart the Web server.
The code is as follows: Copy code
Sudo ln-s/etc/nginx/sites-available/111cn. org/etc/nginx/sites-enabled
Sudo/etc/init. d/nginx restart
If an error occurs when starting Nginx, you need to solve the problem by "resolving the problem of port occupation during Nginx startup.
To delete a site, run the following command:
The code is as follows: Copy code
Sudo rm/etc/nginx/sites-enabled/111cn. org
Sudo/etc/init. d/nginx restart
4. Deploy FastCGI
Deploy FASTCGI using commands
The code is as follows: Copy code
Sudo apt-get install php5-cli php5-cgi spawn-fcgi php-pear
Configuration Package
The code is as follows: Copy code
Cd/opt/
Sudo wget-O php-fastcgi-deb.sh http: // soft.111cn. org/lemp/1548-php-fastcgi-deb.sh
Sudo mv/opt/php-fastcgi-deb.sh/usr/bin/php-fastcgi
Sudo chmod + x/usr/bin/php-fastcgi
Sudo wget-O init-php-fastcgi-deb.sh http: // soft.111cn. org/lemp/1549-init-php-fastcgi-deb.sh
Sudo mv/opt/init-php-fastcgi-deb.sh/etc/init. d/php-fastcgi
Sudo chmod + x/etc/init. d/php-fastcgi
Sudo/etc/init. d/php-fastcgi start
Sudo update-rc.d php-fastcgi defaults
Modify the site configuration file. The same as above, you must modify/etc/nginx/sites-available/111cn. org accordingly.
The code is as follows: Copy code
Server {
Server_name www.111cn. org 111cn. org;
Access_log/srv/www/111cn. org/logs/access. log;
Error_log/srv/www/111cn. org/logs/error. log;
Root/srv/www/111cn. org/public_html;
Location /{
Index index.html index.htm index. php;
}
Location ~ . Php $ {
Include/etc/nginx/fastcgi_params;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/srv/www/111cn. org/public_html $ fastcgi_script_name;
}
}
Restart NGINX.
The code is as follows: Copy code
/Etc/init. d/nginx restart
We can use phpinfo () to view the normal environment in the/srv/www/www.111cn.net/public_htmldirectory.
It seems that it is still relatively smooth (in fact, the old Left has been studying for a few days), and then we need to create a MYSQL database.
Fifth, install the MYSQL database server
A-install the MYSQL service package
The code is as follows: Copy code
Sudo apt-get install mysql-server php5-mysql
B-set the MYSQL ROOT password
You need to set the password twice. This password is the ROOT password of MYSQL. If we need to reset the root mysql password with the dpkg-reconfigure mysql-server-5.0 command
C-set MYSQL basics
The code is as follows: Copy code
Sudo mysql_secure_installation
D-create a MYSQL User
The code is as follows: Copy code
Mysql-u root-p
Enter the root mysql password and set it accordingly.
The code is as follows: Copy code
Create database 111cn;
Create user '111cn user' identified by '111cn. org ';
Grant all privileges on 111cn. * TO '111cn user ';
Exit
From the above we can see that 111cn is the database name, 111cn user is the user name, and 111cn. org is the database password.
E-restart PHP
The code is as follows: Copy code
Sudo/etc/init. d/php-fastcgi restart
In this way, we can upload website programs and build a PHP + MYSQL site with the created database information.
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.