How to install WordPress using command line

Installing WordPress is a very simple process if you have a nice GUI available for file uploads and database configuration. This post is about installing WordPress using the command line. People with access to VPS hosting or root SSH access may not necessarily have access to the GUI based installation options. Let’s us see the steps for installing and configuring the WordPress installation. We follow these steps for our WordPress installations

  1. 1. Download the WordPress source to the desired folder for example /var/www/html or similar one in your LAMP installation. Use the wget command for the download
# wget http://wordpress.org/latest.tar.gz
  1. 2. Create a MySQL user in the MySQL installation for the purpose of using in the WordPress installation
# mysqladmin -u root -p create username
3. Give permissions to the MySQL user account just created. You will have to login to the MySQL server in order to do this. The below command will allow the user “username” with password Pa55w@ard to run the WordPress.
 # mysql –u root – p    > It will prompt you for the password of the MySQL root user
mysql > GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON databasename.* TO ‘username’@’localhost’ IDENTIFIED BY ‘Pa55w@ard’;
mysql > exit
4. Unzip /untar the WordPress files
# tar –xzvf latest.tar.gz
# unzip latest.zip  > If you have downloaded the .zip file
5. This would create a expand the zip file into the current directory. The WordPress source is located under the folder “wordpress”. It would be required to rename the foldername to your taste. If you are planning the installation as a subdirectory to your main directory, rename the “wordpress” to things like blog e.g. http://www.example.com/blog
# mv wordpress blog     > this will rename the folder wordpress to blog
6. Access your installation http://www.example.com/blog and provide the information for configuration including the database configuration details