Setup Wordpress on CentOS
WordPress is known as one of the most popular blogging platform and content management systems out there. It's built on top of a LAMP Stack and it's really easy to setup.
Here I will show you how easy it is to setup:
Download Package:
$ cd /tmp/
$ wget https://wordpress.org/latest.tar.gz
$ tar -xvf latest.tar.gz
Pre-Requisites:
- PHP-GD
- LAMP Stack
Use this one-liner to determine if the module is installed, else it will install it for you
if [[ `rpm -q php-gd | grep "not installed" | wc -l` -eq "1" ]]; then $(which yum) install php-gd -y; else echo "php-gd installed"; fi
MySQL: Create the DB and Setup the User
$ mysql -u root -p
// create the database
mysql> CREATE DATABASE wordpress_db;
# create the user
mysql> CREATE USER wordpress_user@localhost;
# set the password
mysql> SET PASSWORD FOR wordpress_user@localhost= PASSWORD("secret");
# grant all privileges for the user
mysql> GRANT ALL PRIVILEGES ON wordpress_db.* TO wordpress_user@localhost IDENTIFIED BY 'secret';
mysql> FLUSH PRIVILEGES;
mysql> exit;
Apache: Prepare the Directories
$ mkdir /var/www/html/wordpress
$ mv wordpress/* /var/www/html/wordpress/
$ cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
Apache: Configure Wordpress DB Settings
edit wp-config.php
$ vi /var/www/html/wordpress/wp-config.php
define('DB_NAME', 'wordpress_db');
define('DB_USER', 'wordpress_user');
define('DB_PASSWORD', 'secret');
Permissions
$ chown -R apache:apache /var/www/html/wordpress
$ find /var/www/html/wordpress/ -type d -exec chmod 755 {} \;
$ find /var/www/html/wordpress/ -type f -exec chmod 644 {} \;
Access Wordpress
Access wordpress on 'http://your-endpoint/wordpress/' continue the installation, then you should be able to access your wordpress site.
Note on Security:
Always remember to only allow your application layer to communicate with MySQL so that your MySQL server don't get hacked.
Optional: SSL Encryption
If you would like to encrypt your info on your wordpress site, see Setup SSL