In this tutorial, we will guide you through the step-by-step process of installing WordPress on Ubuntu Server latest version. You'll need to follow the below steps:
Before starting, we need to make sure that our Ubuntu server meets the following prerequisites:
To download the latest version of WordPress, type the following command on your Ubuntu server's terminal:
wget https://wordpress.org/latest.tar.gz
Now, extract the downloaded file using the following command:
tar -xvzf latest.tar.gz
Now, move the extracted WordPress directory to the Apache root directory (/var/www/html) using the following command:
sudo mv wordpress /var/www/html/
We need a MySQL database and user account for WordPress to store its data. We will create a new user account with a password and a database with the same name. To do that, run the following command:
mysql -u root -p
After entering the MySQL shell, run following commands to create the new database and user:
CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;
Make sure to replace the password with a strong password of your own choosing.
WordPress needs to know the database details, username, password, and server name to work properly. We need to configure the WordPress configuration file (wp-config.php) for this purpose. First, rename the sample configuration file using the following command:
cd /var/www/html/wordpress/
sudo mv wp-config-sample.php wp-config.php
Then, open the configuration file using a text editor of your choice:
sudo nano wp-config.php
Configure the following parameters in the wp-config.php file according to your database and server details:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );
/** MySQL database username */
define( 'DB_USER', 'wordpress' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
Save and close the configuration file.
We need to configure Apache web server to host WordPress, we have to create a virtual host file for our WordPress site. Run following command to create a new virtual host file:
sudo nano /etc/apache2/sites-available/wordpress.conf
Add the following code to wordpress.conf file:
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html/wordpress/
<Directory /var/www/html/wordpress/>
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Make sure to replace example.com with your domain name, save and close the file.
To enable the newly created WordPress virtual host file, run the following command:
sudo a2ensite wordpress.conf
Then, restart Apache so the changes can take effect:
sudo systemctl restart apache2
Now open your web browser and enter your server's IP address or domain name, followed by /wordpress. For example, http://example.com/wordpress. You will be directed to WordPress installation page.
Select your language and click on the continue button.
Then, enter the required information and click on the Install WordPress button.
Once you have successfully installed WordPress, you can log in to the WordPress dashboard and start creating posts and pages for your website.
Congratulations! You have successfully installed WordPress on Ubuntu Server Latest.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!