The LNMP environment is a website server architecture consisting of Nginx, MySQL or MariaDB, and PHP running on Linux. This document describes how to manually set up the LNMP environment on a Tencent Cloud CVM.
To manually set up the LNMP environment, you should familiarize yourself with common Linux commands such as installing software via YUM in CentOS, and understand the usage and version compatibility of the software to be installed.
In this example, the following software versions are used to build the LNMP environment:
CentOS is a distribution of the Linux operating system. This document uses CentOS 6.9 as an example.
Nginx is a web server. This document uses Nginx 1.17.5 as an example.
MySQL is a database software. This document uses MySQL 5.1.73 as an example.
PHP is a scripting language. This document uses PHP 7.1.32 as an example.
Setting up a LNMP environment requires a Linux CVM. If you have not purchased a Linux CVM yet, see Customizing Linux CVM Configurations.
nginx.repo
under /etc/yum.repos.d/
.vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=https://nginx.org/packages/mainline/centos/6/$basearch/
gpgcheck=0
enabled=1
yum install -y nginx
nginx.conf
.vim /etc/nginx/nginx.conf
nginx.conf
file.server{...}
and replace the content inside the curly brackets with the following. This is to cancel the listening of the IPv6 address and configure Nginx to realize linkage with PHP.server {
listen 80;
root /usr/share/nginx/html;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
#
location / {
index index.php index.html index.htm;
}
#error_page 404 /404.html;
#redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
#pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
If you cannot find server{...}
in the nginx.conf
file, add the content of the server{...}
at the top of include /etc/nginx/conf.d/*conf;
, as shown below:service nginx start
chkconfig --add nginx
chkconfig nginx on
http://[Public IP address of the CVM instance]
If the following appears, Nginx has been successfully installed and configured.rpm -qa | grep -i mysql
yum -y remove [Package name]
yum install -y mysql-devel.x86_64 mysql-server.x86_64 mysql-libs.x86_64
service mysqld start
chkconfig --add mysqld
chkconfig mysqld on
mysql
If the following appears, MySQL has been successfully installed.\q
rpm -Uvh https://mirrors.cloud.tencent.com/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
yum -y install mod_php71w.x86_64 php71w-cli.x86_64 php71w-common.x86_64 php71w-mysqlnd php71w-fpm.x86_64
service php-fpm start
chkconfig --add php-fpm
chkconfig php-fpm on
echo "<?php phpinfo(); ?>" >> /usr/share/nginx/html/index.php
service nginx restart
http://[Public IP address of the CVM instance]
If the following appears, the environment has been successfully configured.After the LNMP environment is built, you can manually build a WordPress website to familiarize yourself with CVM and its features.
If you encounter a problem when using CVM, refer to the following documents for troubleshooting as needed:
Was this page helpful?