NOTE: You must have the LAMP stack installed before installing WordPress.
Create the WordPress database, user, and password
mysql -u root -p |
Now, create the database and user for your WordPress installation. You can replace WPdatabase, WPuser, and WPpassword with your own database name, username, and password in the following commands:
CREATE DATABASE wordpressdb; |
Â
CREATE USER WPuser@localhost IDENTIFIED BY 'WPpassword'; |
Â
GRANT ALL PRIVILEGES ON WPdatabase.* TO WPuser@localhost; |
Now, flush the privileges and restart the service:
FLUSH PRIVILEGES; |
Â
exit |
Download WordPress
wget http://wordpress.org/latest.tar.gz |
Now, extract the compressed file to your home directory:
tar -xzvf latest.tar.gz |
Configure WordPress
Begin by copying the sample config file into a new file:
cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php |
Now open the file in Nano so that it can be edited:
sudo nano ~/wordpress/wp-config.php |
Once you have the wp-config.php file open in Nano, go through it and replace wpdatabase, wpuser and dbpassword with the database name, username and password you created in the first step. Then save your changes and exit Nano.
Move WordPress to the web root and set permissions
Now that WordPress is configured, you will need to move the contents of the WordPress directory to your website's web root directory:
sudo rsync -cvP ~/wordpress/ /var/www/ |
You will need to change to the web root directory now:
cd /var/www/ |
Now you must grant ownership of the directory to the Apache user (www-data):
sudo chown www-data:www-data /var/www/* -R |
Add the username you created in the first step of this guide to the group. Replace WPuser in the following with the username you created:
sudo usermod -a -G www-data WPuser |
Finally, install a necessary module, php-gd:
sudo apt-get install php5-gd |
Now complete the WordPress setup now located at http://yourdomain.com/wp-admin/install.php, where 'yourdomain.com' is replaced with your actual domain.