WordPress is the most popular content management systems… how do you install it on Ubuntu Servers?
Students who want to learn how to install WordPress on Ubuntu servers will find this tutorial helpful. This tutorial is going to be very simple, easy to read and understand.
Before one can run a WordPress blog or website, one must first install and configure WordPress. Most website providers make this process very easy. They build special tools to help users easily install and manage WordPress and other content management systems from one central panel.
Even with those fancy tools, some students just want to learn how to do it themselves, and this is the right tutorial to begin with.
To get WordPress running on Ubuntu server, your first task will be to configure and prepare the server so that WordPress can function. To do that, follow steps and run the commands below.
Step 1: Prepare Ubuntu Server
The first step is to update your Ubuntu servers so that all necessary packages are installed. This can be done by running the commands below.
sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove
Run the above commands as a root user to update the server, and reboot if necessary.
Step 2: Install Apache2 Web Server
Apache2 is the most popular web server in used today. A Web server is needed in order to run WordPress. To install Apache2 on Ubuntu server, run the commands below
sudo apt-get -y install apache2
After installing apache2, the below commands will allow you to stop, start or enable apache2 web server to start up everytime your server reboots
sudo systemctl stop apache2
sudo systemctl start apache2
sudo systemctl enable apache2
Step 3: Install MySQL Database Server
MySQL is also the most popular database server used by WordPress and other content manage systems today. And WordPress requires a database server to function. So, to install MySQL database server, run the commands below.
sudo apt-get -y install mysql-server mysql-client
When you run the command above, it will install MySQL packages and prompt you to setup a password for the root user to manage the database server. Type and confirm a new password for the root user on the screen that looks like the one below.
After installing MySQL server, the commands below allow you to stop, start, and enable the server to always start up when your server reboots.
sudo systemctl stop mysql
sudo systemctl start mysql
sudo systemctl enable mysql
Next, run the command below to secure the database server
You’ll be prompted after running the command. Use the guide below:
Enter current password for root (enter for none): Type root password
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?Press y|Y for Yes, any other key for No: N
Change the root password? N
Remove anonymous users? Y
Disallow root login remotely? Y
Remove test database and access to it? Y
Reload privilege tables now? Y
Step 4: Create WordPress Database
Now that you’ve installed MySQL database, the next step is to create the database WordPress will use to store its content. To do that, use the guide below.
Logon to the server. When prompted for password, type the password you created earlier.
mysql -u root -p
Create a database called wpdb. The database can be called anything you like.
CREATE DATABASE wpdb;
Create a user account called wpuser for the database. This account will have the necessary rights to store, retrieve and manage WordPress content.
CREATE USER wpuser@localhost IDENTIFIED BY 'type_new_password';
Grant the new account all rights to manage the database you just created.
GRANT ALL ON wpdb.* TO wpuser@localhost;
Finally, run the commands to flush and save your changes.
Step 5: Install PHP and other modules
The final packages and scripts that are required by WordPress are PHP and it’s modules. WordPress requires these to function. To install them, run the commands below.
sudo apt-get -y install php libapache2-mod-php php-mysql php-curl php-gd php-intl php-pear php-imagick php-imap php-mcrypt php-recode php-tidy php-xmlrpc
Step 6: Download WordPress content from online
Now that you’ve installed all the servers and packages that WordPress needs, it’s time to download WordPress content. To download the content, run the commands below.
cd /tmp/ && wget http://wordpress.org/latest.tar.gz
Next, extract the downloaded content by running the commands below.
tar -xvzf latest.tar.gz
Step 7: Configure WordPress to run
After extracting WordPress’ content, the first thing you’ll want to do is delete Apache2 default file in its root directory.
sudo rm /var/www/html/index.html
Next, move WordPress content to Apache2’s root directory by running the commands below.
sudo mv wordpress/* /var/www/html/
After moving WordPress content to its root directory, use the command below to make a copy of wp-config-sample.php file and name it wp-config.php.
The wp-config.php is the default configuration file for WordPress in its root folder.
sudo cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
Next, edit wp-config.php file and make the below changes.
sudo nano /var/www/html/wp-config.php
// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
Save your changes when done.
Finally, run the commands below to set the correct files and folders permissions for WordPress to function properly.
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html/
After all of the above, restart Apache2 web server.
sudo systemctl restart apache2
Step 8: Launch WordPress Installation
The final step is to open your web browser and browse to the server IP address or hostname. You should be prompt with WordPress default setup page.
If you see this page, then everything went perfect!
Continue with the setup and type your Site Name, create a username and password and install.
That’s it! Enjoy!