This article assumes you are starting from a clean installation of Ubuntu
Installing the “AMP”
Before installing WordPress, we need to install the requisite software. For this article, we will be using the LAMP stack (Linux, Apache, MySQL, PHP).
Apache is an open source web server that’s been around for decades. This is required for your server to understand what to do with incoming web requests (URL’s). More on this later, just install it.
sudo apt-get update sudo apt-get install apache2
MySQL is a widely used open source relational database management system. This is the software that manages WordPress’s database.
sudo apt-get install mysql-server
Enter a root MySQL user password when requested. You will need this later.
WordPress is written in PHP, a popular general-purpose scripting language that is especially suited to web development. It powers everything from your blog to the most popular websites in the world.
sudo apt-get install php7.0 libapache2-mod-php7.0 php7.0-mysql
WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, configure multisite installs and much more, without using a web browser.
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar chmod +x wp-cli.phar sudo mv wp-cli.phar /usr/local/bin/wp
Configuring LAMP for WordPress
A clean installation of Apache doesn’t come with all mods enabled, so make sure the following are:
sudo a2enmod rewrite
Next we create a configuration file in Apache’s sites-available folder.
cd /etc/apache2/sites-available touch my-website.conf
Now open my-website.conf using your preferred editor like vim or nano.
Paste in the following, and modify it to suit your needs:
<Virtualhost *:80> DocumentRoot /var/www/ ServerName mywebsite.com DirectoryIndex index.php <Directory "/var/www/"> AllowOverride All </Directory> </VirtualHost>
After saving the file, run the following to enable the configuration file:
sudo a2ensite my-website.conf
Make sure your web root (in this case “/var/www/”) exists.
Edit your hosts File for sites hosted locally
Edit /etc/hosts. Paste in the following, and modify it to suit your needs: