Install Lighttpd, MariaDB, and PHP
Configure PHP-FPM to Work with Lighttpd
Next, you will need to configure PHP-FPM to work with Lighttpd. To do so, edit the www.conf file:
$ nano /etc/php/8.2/fpm/pool.d/www.conf
listen = /run/php/php8.2-fpm.sock
And, replace it with the following line:
listen = 127.0.0.1:9000
$ nano /etc/lighttpd/conf-available/15-fastcgi-php.conf
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/var/run/lighttpd/php.socket",
And, replaced them with the following lines:
"host" => "127.0.0.1",
"port" => "9000",
Save and close the file, then enable the required modules with the following command:
$ lighty-enable-mod fastcgi
$ lighty-enable-mod fastcgi-php
Next, restart the Lighttpd and PHP-FPM service to apply the changes:
$ systemctl restart lighttpd
$ systemctl restart php8.2-fpm
Step 3 – Create a Database for WordPress
Next, log in to the MariaDB with the following command:
$ mysql
Once you are log in, create a database and user with the following command:
CREATE DATABASE wpdb;
GRANT ALL PRIVILEGES on wpdb.* TO 'wpuser'@'localhost' IDENTIFIED BY 'password';
Next, flush the privileges and exit from the MariaDB:
FLUSH PRIVILEGES;
EXIT;
Step 4 – Install WordPress
Next, change the directory to the Lighttpd web root directory and download the latest version of WordPress using the following command:
$ cd /var/www/html
wget https://wordpress.org/latest.tar.gz
Once the download is completed, extract the downloaded file with the following command:
$ tar -xvzf latest.tar.gz
Next, change the directory to WordPress and rename the sample configuration file:
$ cd wordpress
mv wp-config-sample.php wp-config.php
Next, edit the configuration file and define your database settings:
$ nano wp-config.php
Change the following lines:
/** The name of the database for WordPress */
define( 'DB_NAME', 'wpdb' );
/** MySQL database username */
define( 'DB_USER', 'wpuser' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
Save and close the file, then set proper permissions and ownership with the following command:
$ chown -R $USER:$USER /var/www/html/wordpress
$ chmod -R 755 /var/www/html/wordpress
Step 5 – Configure Lighttpd for WordPress
First, create a directory to store the virtual host configuration file:
$ mkdir -p /etc/lighttpd/vhosts.d/
Next, edit the Lighttpd configuration file:
$ nano /etc/lighttpd/lighttpd.conf
Add mod_rewrite in the following block:
server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_redirect",
"mod_rewrite",
)
And define the path of your virtual host configuration directory:
include_shell "cat /etc/lighttpd/vhosts.d/*.conf"
Save and close the file. Then, create a new virtual host configuration file for WordPress:
$ nano /etc/lighttpd/vhosts.d/wordpress.conf
Add the following lines:
$HTTP["host"] =~ "(^|.)wordpress.example.com$" {
server.document-root = "/var/www/html/wordpress"
server.errorlog = "/var/log/lighttpd/wordpress-error.log"
}
Save and close the file, then restart the Lighttpd service to apply the changes:
$ systemctl restart lighttpd
Step 6 – Access WordPress Dashboard
Now, open your web browser and access the WordPress installation wizard using the URL http://wordpress.example.com. You should see the following page: