Installing WordPress on CentOS 5/6


Wordpress is a content management system originally developed for blogging, but has been greatly expanded through widgets, themes and plugins. Complete the following steps to install WordPress on a CentOS 5/6.

Pre-reqs

yum -y install mysql-server httpd php php-mysql unzip wget  
chkconfig httpd on
chkconfig mysqld on
/etc/init.d/mysqld start
/etc/init.d/httpd start

Create a WordPress database and MySQL User

Note: After the wordpress files are unzipped, they will be in a directory called wordpress in the home directory.

  • Log in to the MySQL Shell and create a new MySQL directory for wordpress
    mysql -u root -p
  • After logging in using your MySQL root password, create a Wordpress database:

(For this example, we will use the database name Wordpressdb.)

   CREATE DATABASE WordPressdb; 
  • Then we need to create the new user. You can replace the database, name, and password, with whatever you prefer:
    CREATE USER wordpressuser@localhost; 
  • Set the password for your new user:
   SET PASSWORD FOR wordpressuser@localhost= PASSWORD("password"); 

Note: For security purposes, you would obviously not use “password” for your password. Be sure to assign a secure password in this line instead.

  • Grant all applicable privileges to the new user. Without this command, the wordpress installer will not start up:
   GRANT ALL PRIVILEGES ON WordPressdb.* TO wordpressuser@localhost IDENTIFIED BY 'password'; 

  • Refresh MySQL:
FLUSH PRIVILEGES;
  • Exit out of the MySQL shell:
   exit

Configure WordPress

  • Copy the sample wordpress configuration file from the wordpress directory, into a new file.
  • Edit the new file to create a new usable wordpress config file:
    cp ~/WordPressdb/wp-config-sample.php ~/WordPressdb/wp-config.php
  • Open the wordpress config:
    vi ~/WordPressdb/wp-config.php
  • Find the section that contains the field below and substitute in the correct name for your database, username, and password:
// ** 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', 'password');
  • Save and Exit.

Copy the Files

  • Transfer the unzipped WordPress files to the website's root directory.
    sudo cp -r ~/wordpress/* /var/www/html
  • Set the permissions on the installation. First, switch in to the web directory:
    cd /var/www/
  • Give ownership of the directory to the apache user.
    sudo chown www-data:www-data * -R sudo usermod -a -G www-data username
  • Install the following php module on your server, to enable the WordPress installation form online. Download php-gd:
    sudo apt-get install php-gd
  • Restart Apache:
    sudo service httpd restart

Confirm setup

  • Review your new set up at http://your-server-ip-or-hostname/wp-admin/install.php


Was this content helpful?




© 2011-2013 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License


See license specifics and DISCLAIMER