Check this Out!Visit our social network pages for recent updates!

Installing WordPress with Lighttpd, MySQL PHP Support on Ubuntu 17.04

Recently we showed students and new users how to install Lighttpd with MySQL and PHP support on Ubuntu 17.04. We also said Lighttpd is an event-based webserver alternative to Nginx, and because of its small memory footprint, it’s a great for high traffic websites on low end servers.

This brief tutorial is going to show you how to install WordPress with Lighttpd and support for MySQL, PHP 7 on Ubuntu 17.04 server.

Just like Apache2 and Nginx, WordPress can run on Lighttpd as well. WordPress might function efficiently with Lighttpd because it’s a light-weight, secure and efficient webserver.

To get started with configuring WordPress on Lighttpd, continue with the steps below:

Step 1: Install Lighttpd on Ubuntu 17.04

To install Lighttpd on Ubuntu, please run the commands below

sudo apt-get update
sudo apt-get install lighttpd

After installing, run the commands below to stop, start and enable the webserver to always start up when the computer boots up.

sudo systemctl stop lighttpd.service
sudo systemctl start lighttpd.service
sudo systemctl enable lighttpd.service

Step 2: Install MySQL Database Server

After installing Lighttpd, run the commands below to install MySQL database server.

sudo apt-get install mysql-server mysql-client

During the installation, you’ll be prompted to create and confirm a MySQL root user password. Please do.

You’ll always need the password to manage MySQL server so don’t forget.

You can also stop, start and enable MySQL server by running the commands below.

sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service

Step 3: Install PHP 7 and Related Modules

Now that Lighttpd and MySQL are installed, the final packages to install are PHP and related modules. To do that, run the commands below.

sudo apt-get install php7.0 php7.0-cgi php7.0-mysql php7.0-gd php-pear php7.0-mcrypt php7.0-xmlrpc

At this point all the required server and packages should be installed. Continue below to configure each.

STEP 4 CREATE WORDPRESS DATABASE AND USER

Now that MySQL server is installed.. your next task is to create a database for WordPress to use. You’ll also create a database user to manage the database.

Run the commands below to logon unto the database server

sudo mysql -u root -p

When prompted for the root password, type the password you created above.

Then run the commands below to create a new database called wpdb.

CREATE DATABASE wpdb;

Run the commands below to create a new database user called wpuser and grant the account full access to the wpdb database.

GRANT ALL ON wpdb.*  TO 'wpuser'@'localhost'  IDENTIFIED BY 'type_new_password_here';

Finally, run the commands below to save your changes and exit.

FLUSH PRIVILEGES;
exit

Next, continue below to configure Lighttpd

Step 5: Configure Lighttpd Server

Now that Lighttpd is installed, continue below to install it. First enable these modules by running the commands below.

sudo lighty-enable-mod fastcgi
sudo lighty-enable-mod fastcgi-php
sudo lighty-enable-mod accesslog

Then enable rewrite in Lighttpd by opening its default configuration file and changing the highlighted value.

sudo nano /etc/lighttpd/lighttpd.conf

Then make sure the block code looks like the one below

server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
        "mod_rewrite",
)

Save the file and close out.

The entire configuration file should look like this:

server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
        "mod_rewrite",
)

server.document-root        = "/var/www/html"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80


index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
## Use ipv6 if available
#include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

 

STEP 6: CONFIGURING WORDPRESS

Now that WordPress database and user are created, go and download WordPress latest content. To do that, run the commands below

cd /tmp/ && wget http://wordpress.org/latest.tar.gz

Next, extract the downloaded content and copy it to Lighttpd default root directory on Ubuntu.

tar -xzvf latest.tar.gz
sudo cp -R wordpress/* /var/www/html

Make sure to remove Ubuntu default index.html test file from default root directory. This can cause issues for new users.

sudo rm -rf /var/www/html/*.index.html

After that, create WordPress configuration file from its sample file by running the commands below.

sudo cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php

Then open wp-config.php file and make the following highlighted changes to reference the database and user you created above.

sudo nano /var/www/html/wp-config.php

When the file opens, make the changes 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', 'wpuser');

/** MySQL database password */
define('DB_PASSWORD', 'type_new_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', '');

Continue to below to change WordPress content directory permissions

STEP 7: CHANGE WORDPRESS CONTENT FILE PERMISSIONS

After configuring WordPress settings, your next step will be to change the directory permissions so WordPress can function properly. To do that, run the below commands

sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/

Finally, restart Lighttpd webserver and open your browser and go to the server IP address or hostname.

sudo systemctl restart lighttpd.service

Disable Apache2 web server so it never runs.

sudo systemctl stop apache2.service
sudo systemctl disable apache2.service

Open your browser and go to the server hostname and you should see WordPress default setup page.

http://localhost

Continue with WordPress wizard to setup your new site.

WordPress default setup page

Continue with the setup wizard and create a WordPress administration to manage the site online. Don’t forget to name the site appropriately.

wordpress nginx setup

Click Install WordPress when done.

Summary:

This post shows you how to install WordPress on Ubuntu 17.04 with Lighttpd, MySQL and PHP7 support. If you follow the steps above correctly, you should have WordPress functioning on Lighttpd.

You may also like the post below:

Install Lighttpd with PHP7 and MySQL Support on Ubuntu 17.04