How to Install WordPress on Self-Hosted Server

By

The instructions from the WordPress website for installation are pretty good, but here I’ve shortened and expanded some of the instructions and made it specifically for self-hosting with a MySQL database.

These instructions assume you already have a LAMP stack (Linux, Apache, MySQL, PHP/Perl/Python).

This guide starts off with an overview of the basic instructions before going into the detailed instructions to setup WordPress on a self-hosted server.

Basic Instructions

  1. Download and extract the WordPress package to the desired location.
  2. Create the WordPress database on your webserver and create a MySQL user with privileges for accessing and modifying the database.
  3. Rename wp-config-sample.php to wp-config.php, then edit the file and add the appropriate database information.
  4. Run the WordPress installation script by accessing the URL in a web browser.

Detailed Instructions

Download and Extract WordPress Package

Connect to shell on your web server.

Change to the directory where you want to download and extract the WordPress package. For Apache on Ubuntu, you will probably want it to be in /var/www/html/ if you want WordPress in the root of your domain.

Go to the appropriate directory:

cd /var/www/html

Download WordPress using the following command:

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

Extract the package:

tar -xzvf latest.tar.gz

The files will be extracted into a folder called “wordpress” in the same directory where you downloaded the WordPress package.

Create Database and User

Create the MySQL user and database by running the below MySQL commands from shell. The syntax is shown below and the dollar sign is the command prompt:

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5340 to server version: 3.23.54

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE DATABASE wordpress_db;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON wordpress_db.* TO "wordpress_user"@"hostname"
-> IDENTIFIED BY "password";
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec) 

mysql> EXIT
Bye
$ 

The above example shows:

root is the admin username to connect to MySQL

wordpress_user is the username for the MySQL user.

wordpress_db is the name of the database.

localhost is the hostname, and it’s generally okay to use ‘localhost’ as the hostname.

password is whatever password you want for wordpress_user.

Setup wp-config.php

Return to where you extracted the WordPress package in Step 1, rename the file wp-config-sample.php to wp-config.php, and open it in a text editor.

Enter your database information under the section labeled as follows:

// ** MySQL settings - You can get this info from your web host ** //

DB_NAME is the name of the database you created for WordPress in Step 2.

DB_USER is the MySQL username you created for in Step 2.

DB_PASSWORD is the password you chose for the database user in Step 2.

DB_HOST is the hostname you used in Step 2 (usually localhost).

Save the wp-config.php file when you’re done.

Run Install Script and Finish Installation

In a web browser, go to the url for the install.php file. For example, if you placed the WordPress files in the root directory, you should open http://example.com/wp-admin/install.php

Follow the instructions on the web page to enter the title of your WordPress website and the username, password, and e-mail address for the new WordPress user that will be created. All of this can be changed later in the Administration Screen of your WordPress backend.

If you successfully installed WordPress, the login prompt will be displayed. Enter the login information to continue setting up the rest of your WordPress website.


Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.