Did You Know?
Got a tip? Let us know

HostGator Diwali Mega Offer 50% Flat Discount on all Hosting Plans - Grab it Now

WordPress 3.9 Released – Install Using LAMP or LEMP on RHEL, CentOS & Fedora

Download Your Free eBooks NOW - 10 Free Linux eBooks for Administrators
CW

Well, on the internet you will find a number of good and better ways to install WordPress on Linux, but this installation guide is prepared for my future reference as well as for those beginners who are new to WordPress and Linux platform. In this installation I will show you’ll how to install latest WordPress 3.9 on RHEL 6.5/6.4/6.3/6.2/6.1/6/5.8, CentOS 6.5/6.4/6.3/6.2/6.1/6/5.8 and Fedora 20,19,18,17,16,15,14,13,12 distributions.

Install WordPress in Linux

Install WordPress Using Apache and Nginx

This guide has two way of installation, one is using LAMP (Linux, Apache, MySQL, PHP) and other is LEMP (Linux, Nginx, MySQL, PHP). So, please select your installation method based on your web servers. Before moving ahead let me provide you a little description about WordPress, LAMP & LEMP.

What Is WordPress?

WordPress is an open source and free blogging application and a dynamic CMS (Content Management System) developed using MySQL and PHP. It has huge number of third party plugins and themes. WordPress currently one of the most popular blogging platform available on the internet and used by millions of people across the globe.

What Is LAMP and LEMP?

LAMP (Linux, Apache, MySQL, PHP) and LEMP (Linux, Nginx, MySQL, PHP) is an open source Web application platform that runs on Linux systems. Apache and Nginx both are Web servers, MySQL is RDMS (Relational Database Management System) and PHP is a server side scripting language.

Install WordPress 3.9 on RHEL 6.5/6.4/6.3/6.2/6.1/6/5.8, CentOS 6.5/6.4/6.3/6.2/6.1/6/5.8 and Fedora 20,19,18,17,16,15,14,13,12

As I said above the installation method has two ways, one is using Apache and other is Nginx. So I have named it A and B. Those who want to install WordPress on their Apache server they can use A method and those who want to install WordPress using Nginx they can follow method B. In case, if you don’t have LAMP or LEMP setup on your systems, please use the following guides to install it.

Method A: Installing WordPress 3.9 for Apache on RHEL, CentOS & Fedora

This Method A installation guide shows you how to install latest WordPress 3.9 using LAMP setup on RHEL 6.5/6.4/6.3/6.2/6.1/6/5.8, CentOS 6.5/6.4/6.3/6.2/6.1/6/5.8 and Fedora 20,19,18,17,16,15,14,13,12.

Step 1: Downloading WordPress 3.9 for Apache

You must be root user to download the package.

# cd /tmp
# wget http://wordpress.org/latest.tar.gz

Step 2: Extracting WordPress 3.9 for Apache

Once the download finishes, run the following command to untar it.

# tar -xvzf latest.tar.gz -C /var/www/html

Step 3: Creating MySQL Database WordPress

Connect to MySQL server and run the following commands to create database and grant privileges.

## Connect to MySQL Server & Enter Password (if any or leave blank)## 
mysql -u root -p
Enter password:

## Creating New User for WordPress Database ##
CREATE USER wordpress@localhost IDENTIFIED BY "your_password_here";

## Create New Database ##
create database wordpress;

## Grant Privileges to Database ##
GRANT ALL ON wordpress.* TO wordpress@localhost;

## FLUSH privileges ##
FLUSH PRIVILEGES;

## Exit ##
exit

Please replace text a shown in Red color with your appropriate Database Name, User and Password. These settings we will required later.

Step 4: Creating Apache VirtualHost for WordPress

Open the file /etc/httpd/conf/httpd.conf with VI editor.

# vi /etc/httpd/conf/httpd.conf

Add the following lines of code at the bottom of the file. Replace the text shown in Red color with your required settings.

<VirtualHost *:80>
  ServerAdmin tecmint@tecmint.com
  DocumentRoot /var/www/html/wordpress
  ServerName wordpress
  ErrorLog /var/log/httpd/wordpress-error-log
  CustomLog /var/log/httpd/wordpress-acces-log common
</VirtualHost>

Next, restart the Apache service to reflect changes.

# service httpd restart

Add the following line to /etc/hosts file.

127.0.0.1  wordpress

Step 5: Configuring WordPress Installation

Copy default wp-config-sample.php to wp-config.php to configure WordPress installation.

# cd /var/www/html/wordpress
# cp wp-config-sample.php wp-config.php

Open wp-config.php file.

# vi wp-config.php

Modify the following database settings as we created in the Step #3 above.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

Step 6: Finishing WordPress Installation

Open your browser and type any of the following address.

http://wordpress/

http://localhost


http://your-ip

Give your Site Title, Create Admin User, Create Admin Password, Enter Your E-Mail and then click on Install button.

Creating WordPress Admin Login

Creating WordPress Admin Login

Login into your WordPress Dashboard.

WordPress Login Screen

WordPress Login Screen

Enter your WordPress Login details.

Enter WordPress Login Details

Enter WordPress Login Details

Welcome to WordPress Dashboard.

WordPress 8 Dashboard

WordPress 8 Dashboard

View your New WordPress blog.

View WordPress Blog

View WordPress Blog

Method B: Installing WordPress 3.9 for Nginx on RHEL, CentOS & Fedora

Step 1: Creating WordPress Directories for Nginx

# mkdir -p /srv/www/wordpress/public_html
# mkdir /srv/www/wordpress/logs
# chown -R nginx:nginx /srv/www/wordpress

Step 2: Downloading and Extracting WordPress 3.9 for Nginx

cd /tmp
# wget http://wordpress.org/latest.tar.gz
# tar -xvzf latest.tar.gz -C /srv/www/wordpress/public_html --strip-components=1

Step 3: Creating MySQL Database WordPress

Connect to MySQL server and run the following commands to create database and grant privileges.

## Connect to MySQL Server & Enter Password (if any or leave blank)## 
mysql -u root -p
Enter password:

## Creating New User for WordPress Database ##
CREATE USER wordpress@localhost IDENTIFIED BY "your_password_here";

## Create New Database ##
create database wordpress;

## Grant Privileges to Database ##
GRANT ALL ON wordpress.* TO wordpress@localhost;

## FLUSH privileges ##
FLUSH PRIVILEGES;

## Exit ##
exit

Please replace text a shown in Red color with your appropriate Database Name, User and Password. These settings we will required later.

Step 4: Creating Nginx VirtualHost For WordPress

If you’ve followed our LEMP guide these directories are already created. In case, if not then please create it by running these commands.

# mkdir /etc/nginx/sites-available
# mkdir /etc/nginx/sites-enabled

Add the following line of code to /etc/nginx/nginx.conf file, After the line that says “include /etc/nginx/conf.d/*.conf.

include /etc/nginx/sites-enabled/*;

Next create Nginx virtualhost file for WordPress.

# vi /etc/nginx/sites-available/wordpress

Add the following content to /etc/nginx/sites-available/wordpress file.

server {
    server_name wordpress;
    access_log /srv/www/wordpress/logs/access.log;
    error_log /srv/www/wordpress/logs/error.log;
    root /srv/www/wordpress/public_html;

    location / {
        index index.php;
    }

    # Disable favicon.ico logging
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    # Allow robots and disable logging
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # Enable permalink structures
    if (!-e $request_filename) {
        rewrite . /index.php last;
    }

    # Handle php requests
    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /srv/www/wordpress/public_html$fastcgi_script_name;
    }

    # Disable static content logging and set cache time to max
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }

    # Deny access to htaccess and htpasswd files
    location ~ /\.ht {
        deny  all;
    }
}

Create symlink for sites enabled directory.

# cd /etc/nginx/sites-enabled/
# ln -s /etc/nginx/sites-available/wordpress

Restart the Nginx server to reflect changes.

# service nginx restart

Add the following line to /etc/hosts file.

127.0.0.1  wordpress

Step 5: Configuring WordPress Installation

Copy default wp-config-sample.php to wp-config.php to configure WordPress installation.

# cd /srv/www/wordpress/public_html
# cp wp-config-sample.php wp-config.php

Modify the following database settings as we created in the Step #3 above.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

Now follow STEP 6 above for the WordPress installation.

In case, if you are having any trouble while installing please do let me know via comments and don’t forget to share this article with your friends.

Ravi Saive

Owner at TecMint.com
Simple Word a Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux.

Linux Services & Free WordPress Setup

Our post is simply ‘DIY’ aka ‘Do It Yourself, still you may find difficulties and want us to help you out. We offer wide range of Linux and Web Hosting Solutions at fair minimum rates. Please submit your orders by Clicking Here.

32 Responses

  1. I am no longer positive where you’re getting your information, however good topic. I must spend a while finding out much more or working out more. Thanks for fantastic information I was in search of this info for my mission.

  2. Hello, i believe that i noticed you visited my blog thus i came to return the favor?.I’m trying to to find issues to enhance my site!I suppose its good enough to use some of your ideas!!

  3. Sell Cisco says:

    Nice post. I used to be checking continuously this blog and I am impressed! Extremely helpful information particularly the last section :) I care for such info much. I was seeking this particular information for a long time. Thanks and good luck.

  4. seo prices says:

    great read, I’ll be sharing the information

  5. Great artical, I unfortunately had some problems printing this artcle out, The print formating looks a little screwed over, something you might want to look into.

    • Ravi Saive says:

      Dear Chaussures.

      Thanks for point out we will work on this soon and give a option to print and view pdf option..

  6. Sreekanth says:

    It is very good article I have followed the same steps to configure wordpress in Fedora 17 with nginx. But it is not working for me . Couldn’t resolve the name wordpress when I am trying to access it via browser. Please help

    • Ravi Saive says:

      @Sreekanth

      To resolve hostname just add the following line to your /etc/hosts file.

      127.0.0.1 wordpress

      and try browsing again. it should work on all browsers. if it doesn’t work you need to look into other things.

  7. Josh Maggart says:

    Great article! Thanks so much for sharing. However I am receiving a 404 error when browsing to mydomain.tv/wordpress. I added the 127.0.0.1 wordpress to /etc/hosts and it’s still no good. I had been following this tutorial, http://www.howtoforge.com/perfect-server-centos-6.2-x86_64-with-nginx-ispconfig-3 to install the server and had to stop before installing courier imap, so I thought I would install WordPress. Hopefully someone can give me pointers on what I may have missed. Thanks!

  8. Adam says:

    I am on a LEMP install. I followed your LEMP install to a T on my CentOS server. I am literally stuck on the very last step before going into wordpress. When I type this in:

    define(‘DB_NAME’, ‘MY_DATA_BASE_NAME’);

    I get the following error:

    -bash: syntax error near unexpected token `’DB_NAME’,’

    I am a n00b, and a frustrated one.

  9. Ravi Saive says:

    @ Adam,

    You have used wrong (comma) in the following line. that’s the reason you getting syntax error.

    define(‘DB_NAME’, ‘MY_DATA_BASE_NAME’);

    Use this following line with proper commas used. it will work..

    define(‘DB_NAME’, ‘MY_DATA_BASE_NAME’);

    • Adam says:

      @Ravi Slaive

      Thank you for your help, but inputting the correct commas (Is saw the slight difference) still did not work. I input this:

      define(‘DB_NAME’, ‘MY_DATA_BASE_NAME’);

      Still get this:

      -bash: syntax error near unexpected token `’DB_NAME’,’

      • Ravi Saive says:

        The error itself telling that you have used wrong commas

        `’DB_NAME’,’

        it should be ’DB_NAME’,

        Why not you copy my whole configuration of Step5 and then modify it.

        • Adam says:

          Forgive me for my ridiculous amount of n00bness on this. But what comma is there other than the one next to the enter key? I’m on a Mac in the default Terminal app if that helps. All I see is this one:

          All Terminal will do is this one:

          But I copy and pasted your edits and still get errors:

          define(’DB_NAME’, ’MY_DATA_BASE_NAME’);
          -bash: syntax error near unexpected token `’DB_NAME’,’

  10. Adam says:

    I know it’s in there somewhere, but I have no idea how to access my wordpress installation. I can’t FTP yet for some reason and I am too dumb to know how to get that to work. I may have to throw in the towel on this.

  11. Jamie says:

    dose not work with centos 5?

  12. Nix Guy says:

    Good informative article. Would have been much better if you demonstrated installation of phpmyadmin and configuring BIND as well. Since no one would be running their blog on the server’s IP without a domain.

  13. great article. thanks for sharing it.

    please avoid using __if’s__ within your nginx’s server block as ‘if is evil’ (http://wiki.nginx.org/IfIsEvil)

    instead, use try_files, for example:

    ——————-
    location / {
    try_files $uri $uri/ @rewrites;
    }

    location @rewrites {
    rewrite ^(.*)$ /index.php?q=$1 last;
    }
    ——————-

  14. Amit kumar says:

    Dear sir, i try to configure it using LNMP. i reached on step 5,but 6 step not working on my laptopits show 403 error.

  15. Supriyo says:

    Can you share a article regarding Flexlm License management? License file, How to install, License start, stop, re-read, remove etc..

    Regards, Supriyo

  16. sanjay says:

    hallo sir,
    i have configured wordpress on linux cent os webserver. and i am trying to configure ldap connection between wordpress and active directory.
    i have used most of the plugin from wordpress but couldn’t get succed.
    can you please suggest me or help me.
    this will help me so much
    thanks in advance

  17. Sivaraam says:

    Hi Ravi,
    I’m a complete newbie to Linux and WordPress…and just wanted to say that your article
    was well laid out and very simple to follow..

    Thank You..

  18. Erick says:

    Guys I was having trouble setting up my LAMP WordPress locally, but this youtube video shows you a step by step approach even if you don’t have a LAMP installed. Now I can have my fashion design business template up and running :) .

  19. Vizius says:

    Are these enough? Cause I am having trouble uploading giving error:

    The uploaded file could not be moved to wp-content/uploads/2013/05….

    • Ravi Saive says:

      Which web server instructions you followed? If Apache, change set apache ownership to wp-content folder.

  20. WP Plugins says:

    Hi Ravi,

    I followed every step but nothing seems to work. The default Nginx greeting is still displayed at localhost:80. Could you show me a way out?

  21. Stephen says:

    Hellpo there! Thiss is my 1st comment here so I just wanted
    to give a quick shout out and tell you I really enjoy reading through your articles.
    Cann you recommend anny otyher blogs/websites/forums that deazl with the same subjects?
    Thanks for your time!

Leave a Reply

This work is licensed under a (cc) BY-NC | TecMint uses cookies. By using our services, you comply to use of our cookies. More info: Privacy Policy.
© 2012-2014 All Rights Reserved.