Advance

Tutorial Install LEMP on Arch Linux

Tutorial Install LEMP on Arch Linux
1
(1)

LEMP is one of the programs that work as a group to serve dynamic websites or web applications. It includes Linux (server operating system), Nginx (web server application), MySQL (database management system) and PHP (programming language). In this article, we are going to teach you How to Install LEMP on Arch Linux. If you want to buy a Linux VPS server, you can visit the plans offered on the Eldernode website.

How to Setup LEMP on Arch Linux

Recommended Article: What is the difference between different Linux distributions?

What is LEMP?

LEMP is a popular alternative to LAMP, except that LAMP uses Apache instead of Nginx and is used for static web pages. There are also WAMP and MAMP services that are designed for Windows and macOS operating systems instead of Linux.

The LEMP stack, derived from the first words Linux, NGINX, MariaDB, and PHP, is a popular configuration for servers used to develop and host web applications. The four components of this stack have been chosen in such a way that other technologies can be used instead of each of them. LEMP stack is one of the common and practical options where Apache web server is replaced with NGINX.

Installing LEMP on Arch Linux

In the first step of the continuation of this article, we will teach How to Install Nginx Web Server. Then we will teach How to Install MariaDB Database Engine. After doing this, in the next step, we will teach you How to Install PHP & PHP-FPM. Finally, we will teach you How to Configure the UFW Firewall.

How to Install Nginx Web Server on Arch Linux

In this section, we want to teach you step by step how to install Nginx web server. To do this, just follow the steps below. In the first step, you must update the system packages by running the following command:

sudo pacman -Syy

Now you can run the following command to install Nginx:

sudo pacman -S nginx

If you encounter a question about continuing the installation process, you need to type the “Y” key and press enter.

To start the Nginx service, you need to use the following command:

sudo systemctl start nginx

You can also run the following command to enable the Nginx service:

sudo systemctl enable nginx

Finally, you can run the following command to check the installation status:

sudo systemctl status nginx

If you have successfully completed the mentioned steps, you can type the IP address of your server in your browser to see if Nginx is up:

http://server-ip

 

Nginx-Web-Server

Note that Nginx is listening on port 80. Therefore, you need to use the following command to confirm this:

sudo netstat -plntu

How to Install MariaDB on Arch Linux

In this section, we are going to teach you How to Install MariaDB on Arch Linux. To do this, just follow the steps below. In the first step, it is necessary to install MariaDB database engine by running the following command:

sudo pacman -S mariadb

In the next step, it is necessary to start the MariaDB data directory using the following command:

sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

After completing the mentioned steps, you can start MariaDB by running the following command:

sudo systemctl start mariadb

You can also enable MariaDB using the following command:

sudo systemctl enable mariadb

To secure the database and apply a list of restrictions, it is necessary to type and execute the following command as the root user:

mysql_secure_installation

If you encounter the switch to unix_socket authentication question, you must type “Y” and press enter. Then, when asked if you want to change the root password, hit “Y” and provide a strong password.

In response to other questions, you can type “Y” and press enter.

If you have followed all the steps correctly, you can enter your database sample using the following command:

mysql -u root -p

How to Install PHP & PHP-FPM on Arch Linux

In this section, we intend to teach you how to install PHP and PHP-FPM. To do this, just follow the steps below. In the first step, it is necessary to install PHP-FPM using the following command:

sudo pacman -S php php-fpm

You can run the following command to start PHP-FPM:

sudo systemctl start php-fpm

To enable PHP-FPM, you can use the following command:

sudo systemctl enable php-fpm

Finally, you can check the installation status by running the following command:

sudo systemctl status php-fpm

Open the configuration file to make some settings by running the following command:

sudo vim /etc/nginx/nginx.conf

Then add the following settings to the configuration file:

location / {  root /usr/share/nginx/html;  index index.html index.htm index.php;  }  location ~ \.php$ {  fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;  fastcgi_index index.php;  root /usr/share/nginx/html;  include fastcgi.conf;  }

Save the configuration file and exit. Then restart nginx and php-fpm by running the following commands to apply the changes:

sudo systemctl restart nginx
sudo systemctl restart php-fpm

To verify that PHP is working and that PHP-FPM can serve nginx web pages without any problems, now you verify that PHP and PHP-FPM are working without problems. To do this, you need to open the configuration file by running the following command:

sudo vim /usr/share/nginx/html/info.php

Now you can add the following commands to it and then save and exit:

<?php  phpinfo();  ?>

Finally, you can open the browser and enter the IP address of your server as below:

http://server-ip/info.php

 

php info Lemp stack

 

To check the status of the PHP version, you can run the following command:

php -v

How to Configure the UFW Firewall

Finally, we reach the last section, the ufw firewall configuration section. First, it is necessary to install ufw firewall by running the following command:

sudo pacman -S ufw

To allow ports 80 and 443 across the firewall, you can use the following commands:

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

Enable ufw by running the following command:

sudo ufw enable

And finally, run the following command to check the installation status:

sudo ufw status

Next, you can install phpMyAdmin to easily manage MariaDB/MySQL databases:

sudo pacman -S phpmyadmin

To enable access to phpMyAdmin, you can create a symlink by running the following command:

sudo ln -s /usr/share/webapps/phpMyAdmin/ /usr/share/nginx/html/

Now to finish the work, you can restart Nginx and PHP-FPM by running the following commands:

sudo systemctl restart nginx
sudo systemctl restart php-fpm

Open the browser and enter the following address with your server IP and run:

http://server-ip/phpMyAdmin

 

phpmyadmin_login_blank

 

After successful login, you will see the phpMyadmin dashboard as shown below:

phpmyadmin dashboard - Install LEMP on Arch Linux

 

Recommended Article: 5 Reasons OpenVPN Is Better Than PPTP VPN

Conclusion

LEMP is a popular alternative to LAMP, except that LAMP uses Apache instead of Nginx and is used for static web pages. There are also WAMP and MAMP services that are designed for Windows and macOS operating systems instead of Linux. In this article, we tried to teach you How to Install LEMP on Arch Linux. If you have any questions, you can ask us in the comment section.

How useful was this post?

Click on a star to rate it!

Average rating 1 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day