| Home » Categories » Multiple Categories |
How To Install (LEMP) nginx, MySQL, PHP stack on Arch Linux |
|
Article Number: 218 | Rating: Unrated | Last Updated: Tue, Sep 23, 2025 at 11:23 PM
|
About LempLEMP stack is a group of open source software to get web servers up and running. The acronym stands for Linux, nginx (pronounced Engine x), MySQL, and PHP. Since the server is already running Arch Linux, the linux part is taken care of. Here is how to install the rest.Step One—PacmanBecause pacman, the arch package manager, has a rolling package release, we should update Arch and its repositories before proceeding with any other steps:sudo pacman -Syu Step Two—Install MySQLOnce everything is fresh and up to date, we can start to install the server software, beginning with MySQL.sudo pacman -S mysqlOnce MySQL installs, start both mysql and the secure installation process. You will also be able to set the MySQL root password during the installation. sudo systemctl start mysqld && mysql_secure_installationWhen initially prompted for the MySQL root password, you can go ahead and press enter, as it has not yet been set. Your installation should look like this: Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorization. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL! Follow up by restarting MySQL: sudo systemctl restart mysqld Step Three—Install nginxOnce MySQL is all set up, we can move on to installing nginx on the server.sudo pacman -S nginxnginx does not start on its own. To get nginx running, type: sudo systemctl start nginxYou can confirm that nginx has installed an your web server by directing your browser to your IP address. You can run the following command to reveal your server's IP address. curl -s icanhazip.com Step Four—Install PHP-FPMIn order to process php application, we will need to install php-fpm.sudo pacman -S php-fpmOnce its installed, start it up. sudo systemctl start php-fpmFinally, we need to tell nginx to run php using php-fpm. To accomplish this, first open up the nginx configuration file: sudo nano /etc/nginx/nginx.confFind the location block that deals with php applications and replace the text in the section with the following: location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
root /srv/http;
include fastcgi.conf;
}Save, exit, and restart nginx:
sudo systemctl restart nginx Step Five—Create a PHP Info PageWe can quickly see all of the details of the new php configuration.To set this up, first create a new file: sudo nano /srv/http/info.phpAdd in the following line: <?php phpinfo(); ?>Then Save and Exit. Restart nginx sudo systemctl restart nginxYou can see the nginx and php-fpm configuration details by visiting http://youripaddress/info.php Your LEMP stack is now set up and configured on your virtual private server. Step Six—Configure the Daemons to Start at BootTo ensure that all of the LEMP programs start automatically after any server restarts:sudo systemctl enable nginx mysqld php-fpmWith that, LEMP is installed. |
Attachments
There are no attachments for this article.
|
Installing and Using the Vim Text Editor on a Cloud Server
Viewed 3228 times since Fri, Dec 27, 2013
Initial Server Setup with Debian 7
Viewed 4303 times since Fri, Dec 27, 2013
How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Debian
Viewed 8422 times since Thu, Dec 26, 2013
How To Install And Run A Node.js App On Centos 6.4 64bit
Viewed 11122 times since Sun, Dec 29, 2013
How To Install LAMP (Linux, Apache, MySQL, PHP) on Fedora
Viewed 4455 times since Thu, Jan 2, 2014
The Basics of Using the Sed Stream Editor to Manipulate Text in Linux
Viewed 7196 times since Fri, Dec 27, 2013
How to Install Piwik on an Ubuntu 12.04 Cloud Server
Viewed 3833 times since Sat, Jan 4, 2014
How To Install Wordpress with nginx on CentOS 6
Viewed 9808 times since Sat, Jan 4, 2014
How to Get Started With mod_pagespeed with Apache on an Ubuntu and Debian Cloud Server
Viewed 4414 times since Thu, Dec 26, 2013
How To Import and Export Databases and Reset a Root Password in MySQL
Viewed 3567 times since Thu, Dec 26, 2013
|
