If developing websites from scratch is not a thing for you, you should know about the content management systems (CMSs). One of the most popular CMS is WordPress. With it, you can set up your personal blog or even a whole, complete business website by just doing a few clicks. In this article, we will guide you on how to deploy WordPress on Ubuntu.
WordPress is an open-source, free, high pluggable, powerful, and customizable CMS which millions of people use. For persons who do not have any web development or web design knowledge, WordPress is a very helpful one. You can easily learn and create a website. It comes with a vast number of themes and plugins. It comes from active and as well as a dedicated community of fellow developers and users. You can freely apply them to your website or blog to however you want. It can be deployed on a LEMP or LAMP stack.
See also: Managed WordPress Hosting Comparison
Preliminaries
- You should already have a dedicated VPS with a registered domain name. Our top pick for hosting is Bluehost. It offers one free domain name and SSL with a high discount rate.
We will start with the installation of LAMP stack first before diving in to deploy WordPress on Ubuntu. Alright, let’s start!
Step #1 Installing Apache Web Server
In order for you to install Apache web server, be sure to correctly issue this command:
$ sudo apt-get install apache2 apache2-utils
Then, you have to enable the Apache2 web server in order for you to start at system boot time, as well as the service with these lines:
$ sudo systemctl enable apache2
$ sudo systemctl start apache2
For us to be able to make sure that the server is officially running, begin by opening your web browser and go to http://yourserveraddresshere. The Apache2 default index page will show if the web server is already up and running.
Reminder: All your web files will be stored in /var/www/html. It is the Apache default root directory.
Step #2: Installing MySQL Database Server
After installing the Apache web server, you have to install the MySQL database server with the following code:
$ sudo apt-get install mysql-client mysql-server
You can also install MariaDB with the following command:
$ sudo apt-get install mariadb-server mariadb-client
In the middle of package installation, you will have to set the root user password for mysql. You have to choose a very secure password then click OK button twice for you to be able to proceed.
In this moment, the database server deployment security is not yet ensured. You will have to issue this command:
$ sudo mysql_secure_installation
You have to install the validate_password plugin. Type Y/Yes to do so and press Enter. Also, choose the default password strength level.
Importantly, if you do not want to change the root password, then type N/No when prompted to do so. Answer Y/Yes for the rest of the subsequent questions.
Step #3: Installing PHP and Modules
Last but not least, we shall install PHP and a few modules for it to work with the web and database servers using the command below:
$ sudo apt-get install php7.0 php7.0-mysql libapache2-mod-php7.0 php7.0-cli php7.0-cgi php7.0-gd
Furthermore, to test if php is working in collaboration with the web server, we need to create a info.php file inside /var/www/html.
$ sudo vi /var/www/html/info.php
And paste the code below into the file, save it and exit.
<?php phpinfo(); ?>
When that is done, open your web browser and type in the this address http://server_address/info.php. You should be able to view the php info page below as a confirmation.
Step #4: Installing WordPress CMS
Download the latest WordPress package and extract it by issuing the commands below on the terminal:
$ wget -c http://wordpress.org/latest.tar.gz $ tar -xzvf latest.tar.gz
Then move the WordPress files from the extracted folder to the Apache default root directory, /var/www/html/:
$ sudo rsync -av wordpress/* /var/www/html/
Next, set the correct permissions on the website directory, that give ownership of the WordPress files to the web server as follows:
$ sudo chown -R www-data:www-data /var/www/html/ $ sudo chmod -R 755 /var/www/html/
Step #5: Creating WordPress Database
Execute the command below and provide the root user password, then hit Enter to move to the mysql shell:
$ mysql -u root -p
At the mysql shell, type the following commands, pressing Enter after each line of a mysql command. Remember to use your own, valid values for database_name, databaseuser, and also use a strong and secure password as databaseuser_password:
mysql> CREATE DATABASE wp_myblog;
mysql> GRANT ALL PRIVILEGES ON wp_myblog.* TO 'your_username_here'@'localhost' IDENTIFIED BY 'your_chosen_password_here';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
Go the /var/www/html/ directory and rename existing wp-config-sample.php to wp-config.php:
$ sudo mv wp-config-sample.php wp-config.php
then update it with your database information under the MySQL settings section (refer to the highlighted boxes in the image below):
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here'); /** MySQL database username */ define('DB_USER', 'username_here'); /** MySQL database password */ define('DB_PASSWORD', 'password_here'); /** MySQL hostname */ define('DB_HOST', 'localhost'); /** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8'); /** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', '');Afterwards, restart the web server and mysql service using the commands below:
$ sudo systemctl restart apache2.service $ sudo systemctl restart mysql.service
Open your web browser, then enter your server address: http://server-address to get the welcome page below. Read through the page and click on “Let’s go!” to proceed further and fill all requested on screen information.
There you have it! Did this guide on how to deploy WordPress on Ubuntu helped you somehow? You can now enjoy WordPress on your system. If you have any additional concerns, you may comment down below and let us know.
Comments
comments