WordPress is one of the most popular open-source Content Management Systems (CMS). It is based on PHP and MySQL and works pretty well on Ubuntu 18.04 server. Its development started in 2003 and it has been widely accepted by webmasters since then.
WordPress is great if you want to start a blog, a company website or a portal for your business. There are thousands of free themes that you can install on WordPress to create professional stunning website in minutes.
Unlike in shared hosting where WordPress is set up using script installers like softaculous, it requires manually installation on a VPS server.
In this guide, we are going to show you how to download the latest stable release of WordPress and install it on your Ubuntu 18.04 server to run a fully functional website.
- Ubuntu 18.04 server
- Apache, MySQl and PHP
- A non-root user with sudo privileges
Special Note: Consult with HostAdvice's Best Linux Hosting Services page to find the top Linux hosting services.
Step 1: Switch to the tmp folder and download the latest version of WordPress
We need to download the latest WordPress release from https://wordpress.org/latest.tar.gz. To do this, type the commands below on a terminal window:
$ cd /tmp $ curl -O https://wordpress.org/latest.tar.gz
Step 2: Unzip the tar archive
$ tar -xzvf latest.tar.gz
Once the unzipping process is completed, a WordPress folder will be created on the path /tmp/wordpress
Step 3: Move the directory to the root of your website
In order for WordPress to work, we will need to move its directory to the root folder of our website using the command below:
$ sudo mv wordpress /var/www/html/wordpress
Step 4: Change ownership and Set permissions for WordPress directory
In order for Apache to access WordPress, we need to change the ownership of the ownership of the directory to www-data using the command below:
$ sudo chown -R www-data:www-data /var/www/html/wordpress/
Then we need to set the right file permissions using the commands below:
$ sudo chmod -R 755 /var/www/html/wordpress/
Step 5: Open MySQL server and create a database for WordPress
WordPress relies on a MySQL database. So we need to create one using the commands below:
$ sudo mysql -u root -p
Enter your password and press Enter
Then enter the commands below, remember to replace the database, user and password with your preferred values:
CREATE DATABASE wp_database DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; GRANT ALL PRIVILEGES ON wp_database.* TO 'wp_user'@'localhost' IDENTIFIED BY 'enterpasswordhere'; FLUSH PRIVILEGES; EXIT;
When you installed WordPress, a default configuration file was created. We need to move the file and set the database configurations using the commands below:
$ sudo mv /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
Then we need to edit the file using our nano editor using the command below:
$ sudo nano /var/www/html/wordpress/wp-config.php
You will see a screen similar to the image below, enter the correct database name, user and password:
When you are done, press CTR+X and Y to save the changes.
Step 7: Finalize the WordPress Installation
Next, you need to visit the new WordPress site using the public IP address or domain name on your browser to finalize the configuration.
Since we installed our WordPress on a sub-folder, we will have to visit www.example.com/wordpress for our site to work.
A screen similar to the one below will be displayed and we can click continue to finish the installation:
If you get the error, Your PHP installation appears to be missing the MySQL extension which is required by WordPress”. You will need to install all PHP modules required for the smooth functioning of WordPress using the command below:
$ sudo apt-get install php-cli php-common php-mbstring php-gd php-intl php-xml php-mysql php-zip php-curl php-xmlrpc
Then, restart Apache using the command below:
$ sudo service apache2 restart
Then, visit your WordPress site one more time to finalize the installation.
That’s it; you have now installed the most popular content management system on your server. You can now select your preferred theme, plugins and start creating posts. Remember to update your WordPress once a new version is released. This will ensure that your site has the latest WordPress version with new features and bug fixes.
Check out the top 3 Linux hosting services