WordPress Server Installation




Setup WordPress Server in LAMP
Linux, Apache Httpd, MySQL, and PHP

1. Using CentOS 7 Linux distro:
# yum install httpd
# yum install mariadb mariadb-server
# yum install php php-gd php-mysql

2. Start and Enable at boot the Apache Httpd Server:
# systemctl start httpd
# systemctl enable httpd

3. Start and Enable MariaDB at boot time:
# systemctl start mariadb
# systemctl enable mariadb

4. Run the mysql_secure_installation scrip to setup MariaDB root password.

5. Create a Database and a user for WordPress:
$ mysql -u root -p
MariaDB> create database WordPressDB;
MariaDB> create user WordPressUser@localhost identified by ‘password’;
MariaDB> grant all privileges on WordPressDB.* to WordPressUser@localhost
MariaDB> identified by ‘password’;
MariaDB> flush privileges;
MariaDB> exit;

6. Configure WordPress:
Rename wp-config-sample.php to wp-config.php
# cd wordpress
# mv wp-config-sample.php wp-config.php

Edit config.php and change the database_name_here, username_here, and password_here.

# vim config.php
** 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');

For WordPress Theme and Plugging development, change the WP_DEBUG to true.

define('WP_DEBUG', true);

7. Configure the Apache Httpd Web Server:
Add a VirtualHost for WordPress

<VirtualHost *:80>
    ServerName DomainName.com
    ServerAlias www.DomainName.com
    DocumentRoot "/var/www/wordpress"
    DirectoryIndex index.php

    <Directory "/var/www/wordpress">
        Options FollowSymlinks
        AllowOverride None
        Order allow,deny
        Allow from all

        # WordPress Rewrite Rule
        <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteBase /
            RewriteRule ^index\.php$ - [L]
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule . /index.php [L]
        </IfModule>

        # Protect the WordPress config file
        <Files wp-config.php>
            Deny from all
        </Files>
    </Directory>

    ErrorLog /var/log/WP_error_log
    CustomLog /var/log/WP_access_log common   
</VirtualHost>

Check the httpd server for syntax error:
# httpd -t

Restart the Apache httpd server:
# systemctl restart httpd

8. Complete the WordPress Installation through its web interface:
From the web browser enter the http://DomainName or http://IP_Address. The WordPress Installation page will appear. Enter the Site Title, Username, Password and email then click on ‘Install WordPress‘ to start the WordPress installation process.
WordPress

9. After the WordPress installation completes, login. That’s it folks.