Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Install Lighttpd with PHP and MariaDB on RockyAlmaLinux
RockyAlmaLinux is a robust and secure Linux distribution that serves as a perfect replacement for CentOS. This article will guide you through installing a complete web server stack with Lighttpd, PHP, and MariaDB, providing detailed instructions with examples and expected output for each command.
Prerequisites: Administrative access to your RockyAlmaLinux system and an active internet connection.
Step 1: Update the System
First, update the system's package repositories and upgrade installed packages to their latest versions
sudo dnf update
$ sudo dnf update Last metadata expiration check: 0:20:47 ago on Mon 15 Nov 2021 02:30:15 PM UTC Dependencies resolved. ================================================================================ Package Arch Version Repo Size ================================================================================ Upgrading: kernel x86_64 5.14.12-300.fc35 updates 10 M kernel-core x86_64 5.14.12-300.fc35 updates 21 M ... Transaction Summary ================================================================================ Upgrade 21 Packages Total download size: 103 M Is this ok [y/N]: y ... Complete!
Step 2: Install Lighttpd
Install the Lighttpd web server using the following command
sudo dnf install lighttpd
Last metadata expiration check: 0:15:01 ago on Mon 15 Nov 2021 02:45:15 PM UTC Dependencies resolved. ================================================================================ Package Architecture Version Repo Size ================================================================================ Installing: lighttpd x86_64 1.4.59-1.fc34 updates 439 k Installing dependencies: libattr x86_64 2.4.48-7.fc34 fedora 29 k libev x86_64 4.33-1.fc34 fedora 70 k ... Transaction Summary ================================================================================ Install 6 Packages Total download size: 791 k Installed size: 2.1 M Is this ok [y/N]: y ... Complete!
Step 3: Start and Enable Lighttpd
Start the Lighttpd service and enable it to start automatically on system boot
sudo systemctl start lighttpd sudo systemctl enable lighttpd
$ sudo systemctl enable lighttpd Created symlink /etc/systemd/system/multi-user.target.wants/lighttpd.service ? /usr/lib/systemd/system/lighttpd.service.
Step 4: Install PHP
Install PHP and necessary modules for dynamic content processing
sudo dnf install php php-fpm php-mysqlnd
Last metadata expiration check: 0:15:01 ago on Mon 15 Nov 2021 03:00:15 PM UTC Dependencies resolved. ================================================================================ Package Architecture Version Repo Size ================================================================================ Installing: php x86_64 7.4.26-1.fc35 updates 3.3 M php-fpm x86_64 7.4.26-1.fc35 updates 1.7 M php-mysqlnd x86_64 7.4.26-1.fc35 updates 195 k ... Transaction Summary ================================================================================ Install 3 Packages Total download size: 5.7 M Installed size: 23 M Is this ok [y/N]: y ... Complete!
Step 5: Configure PHP for Lighttpd
Configure the FastCGI process manager by editing the PHP-FPM configuration file
sudo nano /etc/php-fpm.d/www.conf
Locate the line that starts with listen = and change it to
listen = /var/run/php-fpm/php-fpm.sock
Save the changes and exit the text editor.
Step 6: Start and Enable PHP-FPM
Start the PHP-FPM service and enable it to launch on system boot
sudo systemctl start php-fpm sudo systemctl enable php-fpm
Step 7: Install MariaDB
Install MariaDB, a popular open-source relational database management system
sudo dnf install mariadb-server
$ sudo dnf install mariadb-server Last metadata expiration check: 0:15:01 ago on Mon 15 Nov 2021 03:15:15 PM UTC Dependencies resolved. ================================================================================ Package Architecture Version Repo Size ================================================================================ Installing: mariadb-server x86_64 10.6.5-1.fc35 updates 19 M Installing dependencies: mariadb-connector-c x86_64 3.1.14-1.fc35 updates 215 k mariadb-server-utils x86_64 10.6.5-1.fc35 updates 736 k perl-DBI x86_64 1.643-1.fc35 updates 803 k ... Transaction Summary ================================================================================ Install 5 Packages Total download size: 23 M Installed size: 116 M Is this ok [y/N]: y ... Complete!
Step 8: Start and Enable MariaDB
Start the MariaDB service and enable it to run at system startup
sudo systemctl start mariadb sudo systemctl enable mariadb
Step 9: Secure MariaDB Installation
Secure your MariaDB installation by running the security script
sudo mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Remove anonymous users? [Y/n] Y
... Success!
Disallow root login remotely? [Y/n] Y
... Success!
Remove test database and access to it? [Y/n] Y
... Success!
Reload privilege tables now? [Y/n] Y
... Success!
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
Step 10: Test the Setup
Create a PHP test file to verify that Lighttpd, PHP, and MariaDB are working correctly
sudo nano /var/www/html/info.php
Add the following PHP code to the file
<?php phpinfo(); ?>
Save the file and exit the text editor.
Step 11: Access the PHP Info Page
Open a web browser and navigate to http://your_server_ip/info.php. You should see a page displaying detailed information about your PHP installation, confirming that the web server stack is working properly.
Conclusion
You have successfully installed Lighttpd, PHP, and MariaDB on RockyAlmaLinux, creating a powerful foundation for hosting websites and web applications. This LLMP stack provides excellent performance and reliability for web development projects.
