This article will take you through how to install Lighttpd on Rocky Linux. Lighttpd, which is pronounced “lighty,” is an open-source web server designed for environments where performance is crucial while still being secure, versatile, and compatible with standards. It has features such as FastCGI, CGI, basic and digest HTTP authentication, output compression, and URL rewriting.
How to Install Lighttpd on Rocky Linux
- Update your packages.
sudo dnf update
- Then upgrade your packages.
sudo dnf upgrade
- Add an Epel repository to your system.
sudo dnf install epel-release
- Next, install Lighttpd on Rocky Linux.
sudo dnf install lighttpd
Sample output
Last metadata expiration check: 0:00:04 ago on Fri 08 Jul 2022 12:40:11 PM EAT. Dependencies resolved. ==================================================================== Package Arch Version Repo Size ==================================================================== Installing: lighttpd x86_64 1.4.55-3.el8 epel 470 k Installing dependencies: compat-lua-libs x86_64 5.1.5-15.el8 epel 167 k gamin x86_64 0.1.10-32.el8 baseos 126 k lighttpd-filesystem noarch 1.4.55-3.el8 epel 24 k mariadb-connector-c x86_64 3.1.11-2.el8_3 appstream 199 k mariadb-connector-c-config noarch 3.1.11-2.el8_3 appstream 14 k Transaction Summary ==================================================================== Install 6 Packages Total download size: 1.0 M Installed size: 2.7 M Is this ok [y/N]: y Downloading Packages: (1/6): mariadb-connector-c-config-3 48 kB/s | 14 kB 00:00 (2/6): gamin-0.1.10-32.el8.x86_64.r 182 kB/s | 126 kB 00:00 (3/6): compat-lua-libs-5.1.5-15.el8 201 kB/s | 167 kB 00:00 (4/6): lighttpd-filesystem-1.4.55-3 155 kB/s | 24 kB 00:00 (5/6): mariadb-connector-c-3.1.11-2 140 kB/s | 199 kB 00:01 (6/6): lighttpd-1.4.55-3.el8.x86_64 445 kB/s | 470 kB 00:01 -------------------------------------------------------------------- Total 158 kB/s | 1.0 MB 00:06 Extra Packages for Enterprise Linux 1.6 MB/s | 1.6 kB 00:00 Importing GPG key 0x2F86D6A1: Userid : "Fedora EPEL (8) " Fingerprint: 94E2 79EB 8D8F 25B2 1810 ADF1 21EA 45AB 2F86 D6A1 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 Is this ok [y/N]: y Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: lighttpd-filesystem-1.4.55-3.el8.noarch 1/6 Installing : lighttpd-filesystem-1.4.55-3.el8.noarch 1/6 Installing : compat-lua-libs-5.1.5-15.el8.x86_64 2/6 Installing : gamin-0.1.10-32.el8.x86_64 3/6 Running scriptlet: gamin-0.1.10-32.el8.x86_64 3/6 Installing : mariadb-connector-c-config-3.1.11-2.el8_ 4/6 Installing : mariadb-connector-c-3.1.11-2.el8_3.x86_6 5/6 Installing : lighttpd-1.4.55-3.el8.x86_64 6/6 Running scriptlet: lighttpd-1.4.55-3.el8.x86_64 6/6 Verifying : mariadb-connector-c-3.1.11-2.el8_3.x86_6 1/6 Verifying : mariadb-connector-c-config-3.1.11-2.el8_ 2/6 Verifying : gamin-0.1.10-32.el8.x86_64 3/6 Verifying : compat-lua-libs-5.1.5-15.el8.x86_64 4/6 Verifying : lighttpd-1.4.55-3.el8.x86_64 5/6 Verifying : lighttpd-filesystem-1.4.55-3.el8.noarch 6/6 Installed: compat-lua-libs-5.1.5-15.el8.x86_64 gamin-0.1.10-32.el8.x86_64 lighttpd-1.4.55-3.el8.x86_64 lighttpd-filesystem-1.4.55-3.el8.noarch mariadb-connector-c-3.1.11-2.el8_3.x86_64 mariadb-connector-c-config-3.1.11-2.el8_3.noarch Complete!
- Start Lighttpd service on your system using the command below.
sudo systemctl start lighttpd
- Then enable the Lighttpd service to start on boot.
sudo systemctl enable lighttpd
- Check Lighttpd status using the following command.
sudo systemctl status lighttpd
Sample output
● lighttpd.service - Lightning Fast Webserver With Light System Requirements Loaded: loaded (/usr/lib/systemd/system/lighttpd.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2022-07-08 12:41:28 EAT; 15s ago Main PID: 134542 (lighttpd) Tasks: 1 (limit: 23373) Memory: 1.1M CGroup: /system.slice/lighttpd.service └─134542 /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf Jul 08 12:41:28 localhost.localdomain systemd[1]: Started Lightning Fast Webserver With Light System Requirements. Jul 08 12:41:28 localhost.localdomain lighttpd[134542]: 2022-07-08 12:41:28: (server.c.1404) can't have more connections than fds/2: 1024 1024
- Allow ports 80 and 443 on your system firewall. Run the command below to allow port 80.
sudo firewall-cmd --zone=public --add-port=80/tcp
- Then allow port 443 using the following command.
sudo firewall-cmd --zone=public --add-port=443/tcp
- Reload the firewall to apply changes.
sudo firewall-cmd --reload
- Check the Lighttpd test page if it’s working by entering your server IP or domain name on the browser.
Installing PHP on RockyLinux
- Run the following command to install PHP, PHP-FPM, and FastCGI on Rocky Linux.
sudo yum -y install php php-mysqlnd php-pdo php-gd php-mbstring php-fpm lighttpd-fastcgi
Sample output
Last metadata expiration check: 0:08:33 ago on Fri 08 Jul 2022 12:40:11 PM EAT. Dependencies resolved. ==================================================================== Package Arch Version Repo Size ==================================================================== Installing: lighttpd-fastcgi x86_64 1.4.55-3.el8 epel 41 k php x86_64 7.2.24-1.module+el8.4.0+413+c9202dda appstream 1.5 M php-fpm x86_64 7.2.24-1.module+el8.4.0+413+c9202dda appstream 1.6 M php-gd x86_64 7.2.24-1.module+el8.4.0+413+c9202dda appstream 83 k php-mbstring x86_64 7.2.24-1.module+el8.4.0+413+c9202dda appstream 579 k php-mysqlnd x86_64 7.2.24-1.module+el8.4.0+413+c9202dda appstream 189 k php-pdo x86_64 7.2.24-1.module+el8.4.0+413+c9202dda appstream 121 k Installing dependencies: apr x86_64 1.6.3-12.el8 appstream 128 k apr-util x86_64 1.6.1-6.el8.1 appstream 104 k httpd x86_64 2.4.37-47.module+el8.6.0+985+b8ff6398.2 appstream 1.4 M httpd-filesystem noarch 2.4.37-47.module+el8.6.0+985+b8ff6398.2 appstream 40 k httpd-tools x86_64 2.4.37-47.module+el8.6.0+985+b8ff6398.2 appstream 107 k mod_http2 x86_64 1.15.7-5.module+el8.6.0+823+f143cee1 appstream 153 k nginx-filesystem noarch 1:1.14.1-9.module+el8.4.0+542+81547229 appstream 23 k php-cli x86_64 7.2.24-1.module+el8.4.0+413+c9202dda appstream 3.1 M php-common x86_64 7.2.24-1.module+el8.4.0+413+c9202dda appstream 660 k rocky-logos-httpd noarch 86.2-1.el8 baseos 24 k spawn-fcgi x86_64 1.6.3-17.el8 epel 24 k Installing weak dependencies: apr-util-bdb x86_64 1.6.1-6.el8.1 appstream 23 k apr-util-openssl x86_64 1.6.1-6.el8.1 appstream 26 k Enabling module streams: httpd 2.4 nginx 1.14 php 7.2 Transaction Summary ==================================================================== Install 20 Packages
Configure Lighttpd and PHP-FPM on Rocky Linux
- Open the PHP-FPM configuration file using the command below.
sudo nano /etc/php-fpm.d/www.conf
- Change user and group to Lighttpd, check the sample file below.
; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default$ ; will be used. ; RPM: apache user chosen to provide access to the same directories$ user = lighttpd ; RPM: Keep a group allowed to write in log dir. group = lighttpd
- Next, in the same config file replace
listen = /run/php-fpm/www.sock
withlisten = 127.0.0.1:9000
check the sample file below.
;listen = /run/php-fpm/www.sock
listen = 127.0.0.1:9000
After making the changes, save(ctrl+s) and close(ctrl+x) the file.
- Start PHP-FPM service using the command below.
sudo systemctl start php-fpm.service
- Next, enable PHP-FPM to start on boot using the following command.
sudo systemctl enable php-fpm.service
- Check PHP-FPM status.
sudo systemctl status php-fpm.service
Sample output
● php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2022-07-08 14:16:33 EAT; 2min 23s ago Main PID: 136800 (php-fpm) Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0, Traffic: 0req/sec" Tasks: 6 (limit: 23373) Memory: 26.5M CGroup: /system.slice/php-fpm.service ├─136800 php-fpm: master process (/etc/php-fpm.conf) ├─136809 php-fpm: pool www ├─136810 php-fpm: pool www ├─136811 php-fpm: pool www ├─136812 php-fpm: pool www └─136813 php-fpm: pool www Jul 08 14:16:32 localhost.localdomain systemd[1]: Starting The PHP FastCGI Process Manager... Jul 08 14:16:33 localhost.localdomain systemd[1]: Started The PHP FastCGI Process Manager.
- Enable FastCGI, open the config file below.
sudo nano /etc/php.ini
- Search for
cgi.fix_pathinfo=1
and uncomment it by removing the semicolon (;) then save and close the file.
cgi.fix_pathinfo=1
- Next, open the config file below.
sudo nano /etc/lighttpd/modules.conf
- Uncomment the line
include "conf.d/fastcgi.conf"
by removing the # symbol then save and close the file.
include "conf.d/fastcgi.conf"
- Open the config file
/etc/lighttpd/conf.d/fastcgi.conf
sudo nano /etc/lighttpd/conf.d/fastcgi.conf
- Add the following lines inside the config file above.
fastcgi.server += ( ".php" => (( "host" => "127.0.0.1", "port" => "9000", "broken-scriptfilename" => "enable" )) )
- Save and close the file the restart Lighttpd to apply changes.
sudo systemctl restart lighttpd
- Next test if PHP is working by creating a test file using the command below.
sudo nano /var/www/lighttpd/info.php
Paste the code below.
<?php
phpinfo();
?>
- Open your favorite browser and enter your domain name or server IP followed by the file created e.g.
http://localhost/info.php
orhttp://127.0.0.1/info.php
Installing MariaDB on Rocky Linux
- Run the command below to install MariaDB.
sudo yum -y install mariadb mariadb-server
Sample output
Last metadata expiration check: 1:48:43 ago on Fri 08 Jul 2022 01:45:14 PM EAT. Dependencies resolved. ===================================================================== Package Arch Version Repo Size ===================================================================== Installing: mariadb x86_64 3:10.3.32-2.module+el8.5.0+777+18007c86 appstream 6.0 M mariadb-server x86_64 3:10.3.32-2.module+el8.5.0+777+18007c86 appstream 16 M Installing dependencies: mariadb-common x86_64 3:10.3.32-2.module+el8.5.0+777+18007c86 appstream 63 k mariadb-errmsg x86_64 3:10.3.32-2.module+el8.5.0+777+18007c86 appstream 233 k perl-DBD-MySQL x86_64 4.046-3.module+el8.6.0+904+ef468285 appstream 155 k perl-DBI x86_64 1.641-4.module+el8.6.0+891+677074cb appstream 739 k perl-Math-BigInt noarch 1:1.9998.11-7.el8 baseos 194 k perl-Math-Complex noarch 1.59-421.el8 baseos 108 k Installing weak dependencies: mariadb-backup x86_64 3:10.3.32-2.module+el8.5.0+777+18007c86 appstream 6.1 M mariadb-gssapi-server x86_64 3:10.3.32-2.module+el8.5.0+777+18007c86 appstream 50 k mariadb-server-utils x86_64 3:10.3.32-2.module+el8.5.0+777+18007c86 appstream 1.1 M Enabling module streams: mariadb 10.3 perl-DBD-MySQL 4.046 perl-DBI 1.641 Transaction Summary ===================================================================== Install 11 Packages Total download size: 31 M Installed size: 156 M Downloading Packages: (1/11): mariadb-common-10.3.32-2.mod 37 kB/s | 63 kB 00:01 (2/11): mariadb-errmsg-10.3.32-2.mod 192 kB/s | 233 kB 00:01 (3/11): mariadb-gssapi-server-10.3.3 213 kB/s | 50 kB 00:00 (4/11): mariadb-backup-10.3.32-2.mod 72 kB/s | 6.1 MB 01:26 (5/11): mariadb-10.3.32-2.module+el8 71 kB/s | 6.0 MB 01:26 (6/11): perl-DBD-MySQL-4.046-3.modul 44 kB/s | 155 kB 00:03 (7/11): mariadb-server-utils-10.3.32 72 kB/s | 1.1 MB 00:16 (8/11): perl-DBI-1.641-4.module+el8. 59 kB/s | 739 kB 00:12 (9/11): perl-Math-Complex-1.59-421.e 40 kB/s | 108 kB 00:02 (10/11): perl-Math-BigInt-1.9998.11- 51 kB/s | 194 kB 00:03 (11/11): mariadb-server-10.3.32-2.mo 110 kB/s | 16 MB 02:30 --------------------------------------------------------------------- Total 198 kB/s | 31 MB 02:39
- Start MariaDB.
sudo systemctl start mariadb.service
- Enable MariaDB to start on boot.
sudo systemctl enable mariadb.service
- Check MariaDB status.
sudo systemctl status mariadb.service
Sample output
● mariadb.service - MariaDB 10.3 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) Active: active (running) since Fri 2022-07-08 15:38:47 EAT; 1min 42s ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Process: 141835 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS) Process: 141700 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service (code=exited, status=0/SUCCESS) Process: 141668 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS) Main PID: 141803 (mysqld) Status: "Taking your SQL requests now..." Tasks: 30 (limit: 23373) Memory: 104.4M CGroup: /system.slice/mariadb.service └─141803 /usr/libexec/mysqld --basedir=/usr Jul 08 15:38:46 localhost.localdomain mysql-prepare-db-dir[141700]: See the MariaDB Knowledgebase at http://mariadb.com/kb or the Jul 08 15:38:46 localhost.localdomain mysql-prepare-db-dir[141700]: MySQL manual for more instructions. Jul 08 15:38:46 localhost.localdomain mysql-prepare-db-dir[141700]: Please report any problems at http://mariadb.org/jira Jul 08 15:38:46 localhost.localdomain mysql-prepare-db-dir[141700]: The latest information about MariaDB is available at http://mariadb.org/. Jul 08 15:38:46 localhost.localdomain mysql-prepare-db-dir[141700]: You can find additional information about the MySQL part at: Jul 08 15:38:46 localhost.localdomain mysql-prepare-db-dir[141700]: http://dev.mysql.com Jul 08 15:38:46 localhost.localdomain mysql-prepare-db-dir[141700]: Consider joining MariaDB's strong and vibrant community: Jul 08 15:38:46 localhost.localdomain mysql-prepare-db-dir[141700]: https://mariadb.org/get-involved/ Jul 08 15:38:46 localhost.localdomain mysqld[141803]: 2022-07-08 15:38:46 0 [Note] /usr/libexec/mysqld (mysqld 10.3.32-MariaDB) starting as process 141803 ... Jul 08 15:38:47 localhost.localdomain systemd[1]: Started MariaDB 10.3 database server.
- Next, secure MariaDB.
sudo mysql_secure_installation
Sample output
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. 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 MariaDB root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB 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, MariaDB 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 MariaDB installation should now be secure. Thanks for using MariaDB!
- Connect to MariaDB using the command below.
sudo mysql -u root -p
- You have made it to the end of our article, congratulations. We have gone through how to install Lighttpd on Rocky Linux.
Read more on Lighttpd Documentation
Other Tutorials
Install LAMP Stack on OpenSUSE