Local WordPress development on Ubuntu is super easy

December 5, 2017 - Linux

If you are tired of changing localhost domain to the correct one before the siteis published this tutorial is for you. We will create a local domain so that your site will be available on project.com during development – only on your local machine.

First download the latest WordPress from https://wordpress.org/download/ and then follow the instructions below.

# Move the downloaded zip to `/var/www/`
mv /home/XXX/Downloads/wordpress-4.9.1.zip

# unzip it
unzip wordpress-4.9.1.zip

# rename the directory to a project name 
mv wordpress project

# setup the apache host 

cd /etc/apache2/sites-available 
cp 000-default.conf project.conf 

# edit the conf file 
vi project.conf

# change the following lines to match your project
ServerName www.project.com
DocumentRoot /var/www/project

# enable the page 
a2ensite project.conf

# restart the server 
systemctl restart apache2 

# check the local ip
ip a

# add the domain name to the hosts file 
echo "<LOCAL IP> domain.com" >> /etc/hosts

Before the installation change the wp-config.php file and include mysql data (host, database name, username, password).

Then go to project.com in your browser and start the installation.