How to install WordPress
In this tutorial we will cover the steps needed to install WordPress on your CentOS 6.4, Debian or Ubuntu platform.
Requirements
- CentOS 6.4, Debian or Ubuntu installed on your computer/server
- SSH access (Command line access to the server)
- root privileges
- Basic skills for working on a Linux environment
- LAMP/LEMP installed on the server
WordPress is one of the most popular free open-source content management systems (CMS) available at the moment. You can create flexible blog websites with it although there is large amount of third party plugins allowing you to extend the functionality of the CMS. This way you can create fully functional online shop, gallery website etc.
Configure a WordPress database
The WordPress requires a MySQL database where the website information will be stored. During the installation the database name, database username and password should be specified so we will go ahead and create new empty database through SSH:
1 |
mysql -p -u root |
You will be prompted to fill in the MySQL root password. After that the command prompt will be switched to a MySQL one.
New MySQL database can be created with the following command:
1 |
create database wordpressdb; |
After that create new MySQL username and assign it to the database:
1 2 |
create user wordpressuser@localhost identified by 'pass1234'; grant all privileges on wordpressdb.* to wordpressuser@localhost; |
You can set desired password in the first MySQL query.
When ready flush the MySQL privileges in order for the changes to take effect:
1 |
flush privileges; |
When ready you can exit the MySQL prompt:
1 |
exit |
Install WordPress and test its functionality
You can download the latest WordPress installation package through the official website. Download and extract the content of the package inside the default web root folder (usually this is /var/www/):
1 |
cd /var/www/ && sudo wget http://wordpress.org/latest.tar.gz && sudo tar zxvf latest.tar.gz |
A folder called wordpress should be extracted from the archive.
Access the folder and copy the sample WordPress configuration file included inside:
1 |
sudo cp wp-config-sample.php wp-config.php |
Make sure that the correct ownership is set for the website content:
1 |
sudo chown -R www-data: /var/www/wordpress |
where www-data is the default user configured for the web server.
During the installation the WordPress will look for that file. We can go ahead and fill in the database credentials inside:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
sudo nano wp-config.php // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'wordpressdb'); /** MySQL database username */ define('DB_USER', 'wordpressuser'); /** MySQL database password */ define('DB_PASSWORD', 'pass1234'); /** MySQL hostname */ define('DB_HOST', 'localhost'); |
where pass1234 is the password assigned to the MySQL user which you have created on your end.
When the correct MySQL credentials are filled in we can continue the installation by accessing the WordPress installation wizard through the browser:
1 |
http://X.X.X.X/wordpress |
where X.X.X.X is your server's IP address, i.e. http://1.2.3.4/wordpress
An easy way to find your server's IP address is to execute the following command:
1 |
ip addr show eth0|grep inet|awk '{print $2}'|cut -d / -f1 |
You will be asked to specify a title for your website and to set WordPress administrative username and password.
You will need to confirm the installation and will be redirected to the WordPress login page:
1 |
http://X.X.X.X/wordpress/wp-login.php |
The WordPress administrative area is available at:
1 |
http://X.X.X.X/wordpress/wp-admin |