Install WordPress On CentOS

1 minute read

Description:

This assumes you have already followed the steps in Setting Up LAMP On CentOS. The only step left to do is install WordPress:

To Resolve:

  1. Open a terminal – type:
# Change to home dir and get the latest wordpress install for CentOS:
cd ~
wget http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz

# Extract to root server dir (default apache directory)
sudo rsync -avP ~/wordpress/ /var/www/html/

# Create an uploads folder
sudo mkdir /var/www/html/wp-content/uploads

# Give the "apache" user full permissions for the directory and subfolders
sudo chown -R apache:apache /var/www/html/*

# Set the sample php config file as your own
sudo cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
  1. Now just add the MySQL info from your MySQL install:
sudo vi wp-config.php
# Find and replace with our database, user, password:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/
/** MySQL database username */
define('DB_USER', 'wordpressuser');
/
/** MySQL database password */
define('DB_PASSWORD', 'password');
  1. Now open up a browser and go to: http://server_domain_name_or_IP # NOTE: mine wouldn’t start so I rebooted the server, then it worked!

  2. Now get WordPress to start on startup:

# Find your firewall zone for your nic
firewall-cmd --get-active-zones

# Add the rule
firewall-cmd --zone=public --add-port=80/tcp --permanent
  1. Now setup DDNS following my guide at Setting Up DDNS For Your Home.

  2. Forward the ports in your router which is described in the same post. Done!

NOTE: If you ever want to uninstall WordPress, just do the following:

 

# Delete everything under /var/www/html. NOTE: I'm a Powershell guy so I really wish there was a -whatif switch for this. Instead I just echo the command first to check the dirs and then delete them.
echo rm -rf /var/www/html
rm -rf /var/www/html

# Remove Mysql database
mysql -u root -p
# password
DROP DATABASE wordpress;
FLUSH PRIVILEGES;
exit

References:

https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-centos-7