Monday, July 28, 2014

Setting up Wordpress on VPS

This is just to journal down the steps required for setting up a fresh installation of Wordpress on a VPS. FTP account is required and i assumed that your VPS has it.

Install mysql and mysqld
 yum install mysql mysqld  

Install PHP
 yum install php php-mysql  

Install Wordpress
 wget http://wordpress.org/latest.tar.gz  
 tar -xzvf latest.tar.gz   
 cp ./wordpress/wp-config-sample.php ./wordpress/wp-config.php  
 sudo cp -r ./wordpress/* /var/www/html  
 sudo yum install php-gd  
 sudo service httpd restart  

Install Mysql
sudo yum install mysql-server   
sudo service mysqld start   
sudo /usr/bin/mysql_secure_installation   

  Enter current password for root (enter for none):    
  OK, successfully used password, moving on...   
  By default, a MySQL installation has an anonymous user, allowing anyone   
  to log into MySQL without having to have a user account created for   
  them. This is intended only for testing, and to make the installation   
  go a bit smoother. You should remove them before moving into a   
  production environment.   
  Remove anonymous users? [Y/n] y              
  ... Success!   
  Normally, root should only be allowed to connect from 'localhost'. This   
  ensures that someone cannot guess at the root password from the network.   
  Disallow root login remotely? [Y/n] y   
  ... Success!   
  By default, MySQL comes with a database named 'test' that anyone can   
  access. This is also intended only for testing, and should be removed   
  before moving into a production environment.   
  Remove test database and access to it? [Y/n] y   
  - Dropping test database...   
  ... Success!   
  - Removing privileges on test database...   
  ... Success!   
  Reloading the privilege tables will ensure that all changes made so far   
  will take effect immediately.   
  Reload privilege tables now? [Y/n] y   
  ... Success!   
   $   

Create Mysql database
mysql -u adminusername -p  
CREATE DATABASE databasename;  
GRANT ALL PRIVILEGES ON databasename.* TO "root@localhost" IDENTIFIED BY "p@ssw0rd";  
FLUSH PRIVILEGES;     

Configure Mysql and link it with Wordpress wp-config.php
 define('DB_NAME', 'wordpress');  
 define('DB_USER', 'user');  
 define('DB_PASSWORD', 'password');  

Try surfing to Wordpress Site to complete the installation
 serverip/wp-admin/install.php  

Next configure so that themes can be installed automatically
 //add this line of code to wp-config.php  
 if(is_admin()) {  
      add_filter('filesystem_method', create_function('$a', 'return "direct";' ));  
      define( 'FS_CHMOD_DIR', 0751 );  
 }  

Some bugs with WP meant that inorder to create folders automatically i had to edit permission to WP-Content folder
 chmod 777 -R /var/www/html/wp-content  

References
http://www.wpmayor.com/the-ultimate-guide-to-setting-up-a-wordpress-vps-part-1/
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-centos-6--2
http://www.wpbeginner.com/wp-tutorials/how-to-fix-the-error-establishing-a-database-connection-in-wordpress/
http://wordpress.org/support/topic/your-php-installation-appears-to-be-missing-the-mysql-extension-which-is-require

No comments:

Post a Comment