How to Install WordPress in Linux

Step 1: Prerequisites

Step 2: Create WordPress Database

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 834
Server version: 5.6.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
| Database           |
| information_schema |
| mysql              |
| performance_schema |
3 rows in set (0.02 sec)

mysql> create database wordpress;
Query OK, 1 row affected (0.01 sec)

mysql> grant all privileges on wordpress.* to wordpress@'localhost' identified by 'password';
Query OK, 0 rows affected (0.02 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit

Step 3: Install WordPress

To Install wordpress package use the yum command i.e.

# yum --enablerepo=epel -y install wordpress

Step 4: Configure WordPress

Edit the wp-config.php file to configure wordpress

# vi /etc/wordpress/wp-config.php

define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'password');
define('WPLANG', 'ja');
# vi /etc/httpd/conf.d/wordpress.conf
Allow from all
# mkdir /usr/share/wordpress/wp-content/languages
# wget -P /usr/share/wordpress/wp-content/languages \`rpm -q wordpress | cut -d"-" -f2`/messages/ \`rpm -q wordpress | cut -d"-" -f2`/messages/ \`rpm -q wordpress | cut -d"-" -f2`/messages/ \`rpm -q wordpress | cut -d"-" -f2`/messages/

Step 5: Restart apache Server

Restart apache server:

# service httpd restart
# /etc/rc.d/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

File/Folder Permissions in Linux


Linux has inherited from UNIX the concept of ownerships and permissions for files. When applying permissions to directories on Linux, the permission bits have different meanings than on regular files.

  • The write bit allows the affected user to create, rename, or delete files within the directory, and modify the directory’s attributes
  • The read bit allows the affected user to list the files within the directory
  • The execute bit allows the affected user to enter the directory, and access files and directories inside
  • The sticky bit states that files and directories within that directory may only be deleted or renamed by their owner (or root)

Following are the useful commands for modifying file permissions and ownership:

  • chmod – modify file access rights
  • su – temporarily become the superuser
  • chown – change file ownership
  • chgrp – change a file’s group ownership

The Permission Groups used are:

  • User (u): The owner of file
  • Group (g): Other user who are in group (to access files)
  • Other (o): Everyone else

Octal numbers and permissions

There are three types of modes in file system i.e

  • Read (r) – 4
  • Write (w) – 2
  • Execute (x) – 1

For Example if we want to change the file permission to 777, 666, 700

  • rwx rwx rwx = 111 111 111 = 777
  • rw- rw- rw- = 110 110 110 = 666
  • rwx — — = 111 000 000 = 700

Change Ownership of Directory/File

To change the ownership of any directory or file use the  “chown” command:

# chown wheel:wheel filename

Change Permission of Directory/File

To setup a file readable by anyone and writable by the owner only:

# chmod 644 file

To setup a file readable/executable by everyone and writable by the owner only:

# chmod 755 file

Note: By default the file permission of file in linux is 644 and 755 for folder.

Recursively Change:

We can change file permissions recursively with the following command:
For Directories:

# find /path/to/your/wordpress/install/ -type d -exec chmod 755 {} ;

For Files:

find /path/to/your/wordpress/install/ -type f -exec chmod 644 {} ;