Installing WordPress on RHEL 7, CentOs 7 or Oracle Linux 7

Installing WordPress on RHEL 7, CentOs 7 or Oracle Linux 7, and BTW this works for AWS EC2 Amazon Linux 2 (recently released December 2017)
I’ve done this on CentOS 7, Oracle Linux 7.4 and Amazon Linux 2 – same process on all.
# do all this as root or prefix each command with sudo – requires root privilege
# update all installed packages first

yum update

# install apache and mysql

yum install httpd
yum install mysql-server

# if you want the newer versions of mysql – you may have to go here and download rpms then use yum localinstall or rpm commands:
https://dev.mysql.com/downloads/repo/yum/
# note while I was installing on CentOS as above – yum chose mariaDB instead of Oracle’s mysql – which is fine – it is a clone

yum install php php-mysql
yum install php-gd php-xml
systemctl start httpd
systemctl start mysql
# make them both start on boot
systemctl enable httpd
systemctl enable httpd

# cd into the dir that will contain wordpress and the apache documents root

cd /var/www

# install wordpress

wget http://wordpress.org/latest.zip
unzip latest.zip # creates wordpress dir right here
# remove html dir – it is empty
rmdir html

# put wordpress files at the root document level of apache

mv wordpress html
vi /etc/httpd/conf/httpd.conf

# replace index.html with index.php
# securing mysql
# 5.7 of mysql sets an initial password for mysql root user and puts it here for you

grep 'temporary password' /var/log/mysqld.log

# 5.6 and earlier

mysql -u root -p
 create database wordpress;
 GRANT ALL PRIVILEGES on wordpress.* to 'lonzodb'@'localhost' identified by 'YourPW';
 flush privileges;

# configure wordpress

cp -p wp-config-sample.php wp-config.php

# make apache own this stuff not root

chown -R apache:apache html

#
# configure wordpress

cp -p wp-config-sample.php wp-config.php
vi wp-config.php

# change dbname to wordpress, user to lonzodb, and password to your password in wp-config.php

chown -R apache:apache html
chown -R apache:apache html

# restart mysql and apache – enable them for reboot too

systemctl restart httpd
systemctl restart mysql

# from a local browser

http://localhost

# the command above will start a browser based session to continue WordPress setup – use the username / password you setup earlier in mysql – in my case that was “lonzodb”
Note:
I did not pre-install php, mysql, nor apache on the Linux installs as configuration process changes everything.  If you do or did pre-install – you could simply “yum remove” to clean up and start fresh – it is the pre-install of php that gave me problems I believe.

Leave a Comment

Scroll to Top