When Ubuntu 18.04 LTS was released, the first chance I had was to install it on my lab computer running VMware Workstation Pro… the steps below is how I got WordPress with Lighttpd, MariaDB and PHP 7.1 Support….
In many cases, you’re going to see webmasters installing WordPress on Ubuntu 18.04 LTS with Apache2 or Nginx and MariaDB with PHP support… Well, this post shows you how to use an alternative HTTP server called Lighttpd HTTP server instead…
Lighttpd is a secure, fast and flexibly HTTP server with a small memory footprint compared to other web-servers… Its event-driven architecture is optimized for a large number of parallel connections (keep-alive) which is important for high performance dynamic applications..
WordPress, the most powerful and popular content management systems (CMS) is the right tool to develop and build powerful and dynamic websites based on PHP is flexible and can be run on variety or HTTP servers..
This brief tutorial is going to show students and new users how to install WordPress on Ubuntu 18.04 LTS with Lighttpd, MariaDB and PHP 7.1 Support
When you’re ready to setup WordPress with Lighttpd support, follow the steps below:
Step 1: Install Lighttpd HTTP Server
sudo apt install lighttpd
After installing Lighttpd, the commands below can be used to stop, start and enable Lighttpd service to always startup when the server boots up.
sudo systemctl stop lighttpd.service sudo systemctl start lighttpd.service sudo systemctl enable lighttpd.service
Step 2: Install MariaDB Database Server
OrangeHRM also requires a database server.. and MariaDB database server is a great place to start. To install it run the commands below.
sudo apt install mariadb-server mariadb-client
After installing, the commands below can be used to stop, start and enable MariaDB service to always start up when the server boots.
sudo systemctl stop mariadb.service sudo systemctl start mariadb.service sudo systemctl enable mariadb.service
After that, run the commands below to secure MariaDB server.
When prompted, answer the questions below by following the guide.
- Enter current password for root (enter for none): Just press the Enter
- Set root password? [Y/n]: Y
- New password: Enter password
- Re-enter new password: Repeat password
- Remove anonymous users? [Y/n]: Y
- Disallow root login remotely? [Y/n]: Y
- Remove test database and access to it? [Y/n]: Y
- Reload privilege tables now? [Y/n]: Y
Restart MariaDB server
sudo systemctl restart mariadb.service
Step 3: Install PHP 7.1 FastCGI and Related Modules
PHP 7.1 may not be available in Ubuntu default repositories… in order to install it, you will have to get it from third-party repositories.
Run the commands below to add the below third party repository to upgrade to PHP 7.1
sudo apt-get install software-properties-common sudo add-apt-repository ppa:ondrej/php
Then update and upgrade to PHP 7.1
sudo apt update
Finally, run the commands below to install PHP 7.1 and related modules..
sudo apt install php7.1-cgi php7.1-mcrypt php7.1-cli php7.1-mysql php7.1-gd php7.1-imagick php7.1-recode php7.1-tidy php7.1-xmlrpc
After installing PHP7.1-FastCGI, you can enable PHP-FastCGI modules by running the commands below
sudo sudo lighttpd-enable-mod fastcgi sudo lighttpd-enable-mod fastcgi-php
If the commands above fail, install the package below.
sudo apt install libterm-readline-gnu-perl
Then run the commands to enable the modules again, this time they should work.
sudo /etc/init.d/lighttpd force-reload
Step 4: Create WordPress Database
Now that you’ve install all the packages that are required, continue below to start configuring the servers. First run the commands below to create a blank WordPress database.
To logon to MariaDB database server, run the commands below.
sudo mysql -u root -p
Then create a database called wpdb
CREATE DATABASE wpdb;
Create a database user called wpdbuser with new password
CREATE USER 'wpdbuser'@'localhost' IDENTIFIED BY 'new_password_here';
Then grant the user full access to the database.
GRANT ALL ON wpdb.* TO 'wpdbuser'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;
Finally, save your changes and exit.
FLUSH PRIVILEGES; EXIT;
Step 5: Configure Lighttpd PHP-FastCGI Settings
Next, you may want to configure Lighttpd to use PHP server scripting properly. The default PHP-FastCGI configuration file is located at /etc/php/7.1/cgi/php.ini
Open PHP Lighttpd configuration file by running the commands below
sudo nano /etc/php/7.1/cgi/php.ini
Then edit the file to suit your environments. Some important lines to consider:
file_uploads = On allow_url_fopen = On memory_limit = 256M upload_max_filesize = 100M cgi.fix_pathinfo=0 date.timezone = America/Chicago
Next, open the Lighttpd site configuration file… by default it’s stored at /etc/lighttpd/lighttpd.conf
They configure the highlighted lines below to enable its rewrite module and create a VirtualHost for our site and save the file. Remember to replace example.com with your own domain name..
Next, run the commands below to open FastCGI default configuraiton file for Lighttpd..
sudo nano /etc/lighttpd/conf-available/15-fastcgi-php.conf
Then confirm that PHP-FastCGI is configured as shown in the highlighted portion below to use PHP 7.1...
# -*- depends: fastcgi -*- # /usr/share/doc/lighttpd/fastcgi.txt.gz # http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions#mod_fastcgi-fastcgi ## Start an FastCGI server for php (needs the php7.1-cgi package) fastcgi.server += ( ".php" => (( "bin-path" => "/usr/bin/php-cgi7.1", "socket" => "/var/run/lighttpd/php.socket", "max-procs" => 1, "bin-environment" => ( "PHP_FCGI_CHILDREN" => "4", "PHP_FCGI_MAX_REQUESTS" => "10000" ), "bin-copy-environment" => ( "PATH", "SHELL", "USER" ), "broken-scriptfilename" => "enable" )) )
Step 6: Download WordPress Latest Release
Next, visit WordPress site and download the latest version….
After downloading, run the commands below to extract the downloaded file and move it into a new WordPress root directory.
cd /tmp && wget https://wordpress.org/latest.tar.gz tar -zxvf latest.tar.gz sudo mv wordpress /var/www/html/wordpress
Then run the commands below to set the correct permissions for WordPress to function.
sudo chown -R www-data:www-data /var/www/html/wordpress/ sudo chmod -R 755 /var/www/html/wordpress/
STEP 7: CONFIGURE WORDPRESS
Now that Lighttpd is configured, run the commands below to create WordPress wp-config.php file.
sudo mv /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
Then run the commands below to open WordPress configuration file.
sudo nano /var/www/html/wordpress/wp-config.php
Enter the highlighted text below that you created for your database and save.
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'wpdb'); /** MySQL database username */ define('DB_USER', 'wpdbuser'); /** MySQL database password */ define('DB_PASSWORD', 'user_password_here'); /** MySQL hostname */ define('DB_HOST', 'localhost'); /** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8'); /** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', '');
Restart Lighttpd services
sudo systemctl restart lighttpd.service
After that, open your browser and browse to your domain name to launch WordPress configuration wizard.
You should see WordPress setup wizard to complete. Please follow the wizard carefully.
Then type the WordPress website name and create a new admin user and password.. the click install.
This should install WordPress.
Congratulations! You’ve successfully installed WordPress on Ubuntu.
You may also like the post below: