Total Pageviews

Thursday, January 24, 2013

Install WordPress on linux server

Here are the instructions for setting up your own WordPress server. In this example, the server runs CentOS 6.3. Before you get started, switch to root user first, since most of the instructions below require a root privilege.
  1. Install related softwares: yum install httpd mysql-server mysql php php-mysql
  2. Start httpd and mysql: service start httpd service start mysqld Now open http://localhost, you should see a test page that indicates the server is working.
  3. Set up mysql server: Use mysqladmin utility to do the job: mysqladmin -u root -p password 123456 Then a prompt 'Enter password:' should appear, just hit enter since the default root user has no password. After this step, the mysql server has been setup. There is a user 'root' with the password 123456 (of course, you can change it).
  4. Install database manage tool phpMyAdmin: This tool provide a web gui interface to manage the mysql database.
    • Download the latest version of phpMyAdmin and put into the document root of Apache server(usually is /var/www/html): cd /var/www/html wget 'http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/3.5.5/phpMyAdmin-3.5.5-all-languages.tar.bz2/download#!md5!3f77e1a608939224a7dce97caf860f46'
    • Uncompress the file to phpmyadmin folder and remove the downloaded file: tar xvf phpMyAdmin-3.5.5-all-languages.tar.bz2 mv phpMyAdmin-3.5.5-all-languages phpmyadmin rm -rf phpMyAdmin-3.5.5-all-languages.tar.bz2
    • Now open http://localhost/phpmyadmin in the browser, you should see a login interface. Login with username root and password 123456 (configured in step (3))
  5. Create a new user and database for wordpress: In phpMyAdmin page:
    • Login phpMyAdmin as root.
    • In phpMyAdmin, click 'Users' tab on home page.
    • Click 'Add User'
    • In 'Add User' form, fill in the user information.
    • User name: choose 'User text field', fill in 'wordpress'
    • Host: choose 'Local'
    • Hit generate password, copy the generated password to somewhere else for future use. In this example, the password is jcqu9LH5C82h238c
    • Under 'Database for user' tab, choose second option: 'Create database with same name and grant all privileges'
    • Hit 'Add User', now the user 'wordpress' and database 'wordpress' is added to the mysql database.
  6. Install wordpress:
    1. Download and uncompress the lastest version of wordpress into document root:cd /var/www/html wget http://wordpress.org/latest.tar.gz tar xfv latest.tar.gz wordpress rm -rf latest.tar.gz Now a folder name 'wordpress' is placed under the document root.
    2. Create the config file by copying the sample file: cd wordpress cp wp-config-sample.php wp-config.php
    3. Configure database:
      • Use your favourite text editor, open wp-config.php file: emacs ./wp-config.php
      • Replace the corresponding lines in the file with your own database settings: define('DB_NAME', 'wordpress'); define('DB_USER', 'wordpress'); define('DB_PASSWORD', 'jcqu9LH5C82h238c');
      • Save the file
    4. Web interface install:
      1. Launch http://localhost/wordpress, now you should see a welcome page of wordpress.
      2. Follow the instruction in wordpress install page, choose site title, i.e., set up admin password, fill in your email address, then hit 'Install Wordpress'.
      3. If everything above goes well, it will redirect to a page that tells you WordPress has been successfully installed. Now you can log in the wordpress as 'admin' and configure you website via WordPress web interface.
  7. Set up proper folder permissions: Usually you need setup a ftp server to manage plugins. But it can be configured in such a way that the plugins install directly into /wp-content/plugins folder, which is easier. To do so:
    • Add a line in wp-config.php: define('FS_METHOD', 'direct');
    • Change the owner of /wp-content folder to apache server: chown -R apache:apache wp-content