Overview
The LNMP environment represents the Nginx + MySQL + PHP web server architecture on a Linux system. This document provides instructions for setting up the LNMP environment on openSUSE 42.3.
This document includes software installation steps. Make sure you are familiar with the software installation methods. For more information, see Installing Software on openSUSE Using Zypper.
LNMP Components and Versions:
- Linux: Operating system, using openSUSE 42.3 in this document.
- Nginx: Web server program for parsing web programs, using Nginx 1.14.2.
- MySQL: Database management system, using MySQL 5.6.43.
- PHP: Program for generating web pages on the web server, using PHP 7.0.7.
Directions
Configure Image Sources
Log in to the CVM.
Execute the following commands to add mirror sources.
zypper ar https://mirrors.convergecloud.com/opensuse/distribution/leap/42.3/repo/oss suseOss zypper ar https://mirrors.convergecloud.com/opensuse/distribution/leap/42.3/repo/non-oss suseNonOssExecute the following commands to update mirror sources.
zypper ref
Install and configure Nginx
Execute the following command to install Nginx.
zypper install -y nginxExecute the following commands in sequence to start the Nginx service and set it to start automatically on boot.
systemctl start nginx systemctl enable nginxRun the following command to modify the Nginx configuration file.
vim /etc/nginx/nginx.confPress "i ” to switch to edit mode.
Locate the server{...} and replace it with the following content.
server { listen 80; server_name localhost; #access_log /var/log/nginx/host.access.log main; location / { root /srv/www/htdocs/; 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 /srv/www/htdocs/; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php$ { root /srv/www/htdocs/; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }After inputting, press Esc, input ":wq" to save the file and return.
Execute the following command to restart the Nginx service.
systemctl restart nginxExecute the following command to create
index.htmlHomepage.vi /srv/www/htdocs/index.htmlPress "i to switch to edit mode and enter the following content:
<p> hello world!</p>After inputting, press Esc, input ":wq" to save the file and return.
In the browser, access the public IP address of the openSUSE CVM instance to check whether the Nginx service is running normally.
As shown in the figure below, it indicates that Nginx has been successfully installed and configured.
Install and configure MySQL
Execute the following command to install MySQL.
zypper install -y mysql-community-server mysql-community-server-toolsExecute the following commands in sequence to start the MySQL service and set it to start automatically on boot.
systemctl start mysql systemctl enable mysqlExecute the following command to log in to MySQL for the first time. > Note: When you log in to MySQL for the first time, the system will prompt you to enter a password. If you do not want to enter a password, you can directly press "Enter" to log in to MySQL.
mysql -u root -pSuccessfully entering MySQL will a screen similar to the image below.

4. Execute the following command to change the root password.
update mysql.user set password = PASSWORD('Enter your new password here') where user='root';
Execute the following command to apply the configuration.
flush privileges;Execute the following command to exit MySQL.
\q
Install and configure PHP
Execute the following command to install.
zypper install -y php7 php7-fpm php7-mysql
Integrate Nginx with PHP-FPM
Execute the following commands in sequence to enter
/etc/php7/fpmDirectory, copy the filephp-fpm.conf.defaultand rename it tophp-fpm.conf.cd /etc/php7/fpm cp php-fpm.conf.default php-fpm.confExecute the following commands in sequence to enter
/etc/php7/fpm/php-fpm.dDirectory, copy the filewww.conf.defaultand rename it towww.conf.cd /etc/php7/fpm/php-fpm.d cp www.conf.default www.confExecute the following commands in sequence to start the service and set it to start automatically on boot.
systemctl start php-fpm systemctl enable php-fpm
Validate the Environment Configuration
Execute the following command to create a test file "index.php".
vim /srv/www/htdocs/index.phpPress "i to switch to edit mode and input the following content:
<?php echo "hello new world!"; ?>Press "Esc", input ":wq" to save the file and return.
Open a web browser and access the public IP of your openSUSE CVM.
If you see a page similar to the one below, it indicates that the LNMP environment has been successfully set up.

