Install WordPress

If you completed Apache, MySQL and PHP installation you have all the blocks needed to install WordPress and start building quality websites with as much effort as typing a word document. WordPress installation on Ubuntu can be done using apt-get just as we have installed Apache, MySQL and PHP. However, this is not the preferred process. Downloading the WordPress package and manually installing will make your life easier in the future.

Let’s begin! First login to your webserver on which you have installed Apache, MySQL and PHP and start Terminal. Become root using “sudo su”. Change the current folder to /var/www/html using the command

cd /var/www/html

In this folder you probably still have the files we created in the previous how-to-s. You can delete them, since we will not need them anymore. For this you can use the command “rm *”. Make sure you are in the correct folder before you do this, so you don’t delete important files in other folders. You can verify what folder you are in using the command “pwd” which as output will display the current folder, and “ls -a” which will display the files in the current folder. You should probably find index.html, info.php and probably index_bkup.html if you made a copy of the original index.php.

Download the latest wordpress package using the command:

wget https://wordpress.org/latest.tar.gz

Once the download completed, you can verify the package is present on your server by typing “ls -l”. You should see a file named latest.tar.gz. A .tar.gz file is a linux compressed archive. You can decompress it and extract the contents using the commands:

gunzip latest.tar.gz
tar -xvf latest.tar

The first command will decompress the file and the second will extract its contents. You can also perform both actions in the same time using the command.

tar -xvzf latest.tar.gz

At this point, if you execute “ls -l” you will see in your folder a new folder named wordpress. We do not need the package anymore so we will just delete it:

rm latest.*

Go to the wordpress folder using

cd wordpress

Move all files to the /var/www/html folder (this folder is the root folder from where your website is served. You can skip this part but if you do, the url used to access your wordpress site will be http://xxx.xxx.xxx.xxx/wordpress instead of http://xxx.xxx.xxx.xxx . . Also, we need to change the owner of the files to the user Apache runs under. To move the files and change the owner type

chown -R www-data:www-data /var/www/html
mv * ../

Return to /var/www/html folder and remove the wordpress folder that you do not need any more.

cd ..
rmdir wordpress

You can verify what we have done until now opening ap browser and going to your website. If you are doing this on your server locally just enter the address http://127.0.0.1 . You should see a page like the one in the next image:

WordPress Installation Verification

Why are we getting this page? It’s simply because we need to install a package that will allow php to connect to your MySQL database. For this run the commands:

apt-get -y update
apt-get -y install php-mysql
systemctl restart apache2

The first 2 commands will install the package. The last command restarts the Apache server. Once the package is installed and Apache restarted you can refresh the page and you should get a page similar to the following:

WordPress Installation

Click “Let’s go!”

The next page you will be presented with will look like this:

WordPress Configuration

I usually use the following info to fill out this screen. But you can choose your own configuration:

Database Name: wordpress
Username: wordpress
Password: A very strong password that I remember somehow
Table Prefix: wp_

Then click “Submit” (even though this operation will fail). You will get the following page:

How do we fix this? We need to edit the WordPress configuration file with the info you have entered on the previous screen. For this go to your terminal and make sure you are in the /var/www/html folder.

cd /var/www/html

Copy the wp-config-sample.php file to wp-config.php and open it using nano.

cp wp-config-sample.php wp-config.php
nano wp-config.php

Look for the following lines:

// ** 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' );

Change the words database_name_here, username_here and password_here with the information you have entered on the previous screen (make sure you keep the ‘ since they are part of the syntax. Deleting them will create a configuration error):

database_name_here becomes wordpress
username_here becomes wordpress
password_here becomes A very strong password that I remember somehow

Then save the file using <CTRL>-O and pressing enter and exit using <CTRL>-X.

Once the configuration has been changed click “Try Again” in your browser. Refill the fields with the same information as before and click “Submit!” You will get a page like the one below:

WordPress Configuration

Clicking “installing now” will not help. You can try, and you can use the back button once you tried to get back to this page . The problem that we face is that we did not create a wordpress database and a wordpress user on the MySQL server. To do this type the following commands:

mysql

You should now see the mysql> prompt. Type the following ( change my-strong-password-here with your password. Also make sure that you do not copy paste into Word and from Word to your configuration file. Word might change the ‘ character into something else and those commands will not work ):

CREATE DATABASE wordpress;
CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'change my-strong-password-here';
GRANT ALL ON wordpress.* TO 'wordpress'@'localhost';

Reopen your browser go to http://127.0.0.1. You will be presented with a “Choose Language” form. I use English (United States), so, I just click “Continue”.

WordPress Configuration – Language Selection

On the next screen you will fill your site information. For the username and password you should use different information than for the database, and once you filled all the information you should click “Install WordPress”

WordPress Configuration – Site and User Information

And finally, we get the success page:

WordPress Configuration – Success

You can either click login, to login to your account and start publishing, or you can go to http://127.0.0.1 and see how the website looks like once the installation has been completed:

WordPress Default View

To go to the login page in the future and start publishing go to: http://127.0.0.1/wp-admin you will be presented with a login page similar to the next image.

WordPress Login

Further Reading

WordPress for Beginners: The complete dummies guide to start your own blog from zero to advanced development and customization. Includes plugin and … your business. (WordPress Programming)
1-Hour WordPress 2019: A visual step-by-step guide to building WordPress websites in one hour or less!
WordPress for Beginners: A Visual Step-by-Step Guide to Creating your Own WordPress Site in Record Time, Starting from Zero! (Webmaster Series Book 3)
WordPress installation Guide
WordPress Installation from the beginning.: Covering the basics of installation and getting started with using WordPress

1.00$5.00$10.00$25.00$50.00$
999999.99$

Leave a Reply

Your email address will not be published. Required fields are marked *