Debian installs LEMP (Linux/Nginx/MySQL/PHP) to build a website environment

888u

Last update at :2024-07-05,Edit by888u

Generally, we use more Apache to build a VPS environment. There are more tutorials for compilation and application reference, and it is slightly easier to use. Snail has shared two articles about LAMP (Linux/Apache/MySQL/PHP) before. Installation environment (Debian7 configures the LAMP environment and builds the website and configures CentOS6 to install the LAMP environment and build the tutorial). Although the installation method with this step is not as fast as the one-click package, it is better than the one-click package in terms of security, stability and resource saving to a certain extent. Yes, if you are not afraid of trouble, it is recommended to use the step-by-step installation method.

Today, what Snail wants to share is the use of Linux/Nginx/MySQL/PHP scripting environment, referred to as LEMP. Our webmasters in mainland China like to call it LNMP (Brother Jun’s installation package NGINX=N), but it is also called abroad. It is LEMP, because the English reading and writing of Nginx is similar to the abbreviation of Engine = E.

Environment: The environment used in the demonstration tutorial is Debian 6 32-bit, building LEMP (Linux/Nginx/MySQL/PHP)

First, update the installation environment

Before starting the installation of this web application, we need to update the system packages to the latest version and run the following command line.

sudo apt-get updatesudo apt-get upgrade

Second, install Nginx WEB server environment

sudo apt-get install nginx

Third, configure Nginx virtual host

Create a directory similar to /etc/nginx/sites-available/laozuo.org under the /etc/nginx/sites-available/ directory to place the configuration file

server {listen 80;server_name www.laozuo.orglaozuo.org;access_log /srv/www/laozuo.org/logs/access.log;error_log /srv/www/laozuo.org/logs/error.log;< /p>

location / {root /srv/www/laozuo.org/public_html;index index.html index.htm;}}

The above file is saved as laozuo.org file and uploaded to the /etc/nginx/sites-available/ directory.

Create directory:

sudo mkdir -p /srv/www/laozuo.org/public_htmlsudo mkdir -p /srv/www/laozuo.org/logs

Used to store the files and logs of the corresponding website. If it is another domain name, it will be created similarly. Then run the following commands to enable creating websites and restart the web server.

sudo ln -s /etc/nginx/sites-available/laozuo.org/etc/nginx/sites-enabledsudo /etc/init.d/nginx restart

If there is an error when starting Nginx, you need to solve it by \\"Solving the problem of port being occupied when starting Nginx\\".

If we need to delete the site, we can do it with the following command:

sudo rm /etc/nginx/sites-enabled/laozuo.orgsudo /etc/init.d/nginx restart

Fourth, deploy FastCGI

Deploy FASTCGI through commands

sudo apt-get install php5-cli php5-cgi spawn-fcgi php-pear

Configuration file package

cd /opt/sudo wget -O php-fastcgi-deb.sh https://soft.laozuo.org/lemp/1548-php-fastcgi-deb.shsudo mv /opt/php-fastcgi-deb.sh /usr/bin/php-fastcgisudo chmod +x /usr/bin/php-fastcgisudo wget -O init-php-fastcgi-deb.sh https://soft.laozuo.org/lemp/1549-init-php-fastcgi -deb.shsudo mv /opt/init-php-fastcgi-deb.sh /etc/init.d/php-fastcgisudo chmod +x /etc/init.d/php-fastcgisudo /etc/init.d/php-fastcgi startsudo update-rc.d php-fastcgi defaults

Modify the site configuration file, the same as above, you need to modify /etc/nginx/sites-available/laozuo.org accordingly

server {server_name www.laozuo.org laozuo.org;access_log /srv/www/laozuo.org/logs/access.log;error_log /srv/www/laozuo.org/logs/error.log;root /srv /www/laozuo.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/laozuo.org/public_html$fastcgi_script_name;}}

Restart NGINX.

/etc/init.d/nginx restart

We can use phpinfo(); to drop it into the /srv/www/laozuo .org/public_html directory to see if the environment is normal.

It seems to be relatively smooth (in fact, Snail has been studying it for a few days), and then we need to create a MYSQL database.

Fifth, install the MYSQL database server

A – Install MYSQL service pack

sudo apt-get install mysql-server php5-mysql

B – Set MYSQL ROOT password

It needs to be set twice. This password is the ROOT password of MYSQL. If we need to reset the ROOT MYSQL password, use the dpkg-reconfigure mysql-server-5.0 command

C – Setting up MYSQL basics

sudo mysql_secure_installation

D – Create MYSQL user

mysql -u root -p

Enter the ROOT MYSQL password to enter, and then set the corresponding settings.

CREATE DATABASE laozuo;CREATE USER \\’laozuouser\\’ IDENTIFIED BY \\’laozuo.org\\’;GRANT ALL PRIVILEGES ON laozuo.* TO \\’laozuouser\\’;exit

From the above we can see that laozuo is the database name, laozuouser is the user name, and laozuo.org is the database password.

E – Restart PHP

sudo /etc/init.d/php-fastcgi restart

In this way, we can upload the website program and build a PHP+MYSQL site with the created database information.

Recommended site searches: server hosting price, Guangdong server rental, IP check, domain name transfer, Hong Kong virtual host space, IP address check, Henan registration, anti-attack IP, corporate email registration application for registered domain names,

Debian installs LEMP (Linux/Nginx/MySQL/PHP) to build a website environment

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码