Here’s a quick tutorial on installing WordPress on CentOS servers. If you’re reading this post, then you probably know a thing or two about WordPress.
Now, if you want to run a great blog or website, most webmasters across the web would recommend using WordPress CMS.
WordPress is probably the most popular opensource CMS system allows anyone to manage a professional looking website or blog with ease.
This brief tutorial shows you how to install and use WordPress on a CentOS server. WordPress runs on many Linux distributions, from Ubuntu to Fedora and CentOS.
To get started with installing WordPress on CentOS, the first thing you’ll want to verify is your access level to the server.
To install required packages to support WordPress requires that you have root or administrator access to the server. If you do, then continue below to install these packages.
- First, install Apache2 web server.
To run WordPress, you must install a web server.. now the most popular webserver in used today is Apache2. To install Apache2 in order to support WordPress, run the commands below
sudo yum -y install httpd
After installing Apache2, run the commands below to stop, start and enable Apache2 to automatically startup everytime you boot up your server or restart
sudo systemctl stop httpd
sudo systemctl start httpd
sudo systemctl enable httpd
- Second, install Mariadb database server
WordPress also depends on a database server to operate. For WordPress to function, you must install a database server… now the most popular database server online today is MySQL database server. However, MySQL isn’t available in the latest version of CentOS’ repositories.
CentOS is moving away from MySQL in favor of Mariadb. So, to simplify the process, install Mariadb instead.
To install Mariadb database server run the commands below.
sudo yum -y install mariadb-server
After installing the database server, run the commands below to stop, start and enable it to automatically start up everytime you restart your server.
sudo systemctl stop mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb
Another thing to do right after installing Mariadb database server is to configure it with a password. To do that, run the commands below.
sudo mysql_secure_installation
Next, follow the guide below to answer the prompts until you’re done.
- Enter current password for root (enter for none): press Enter
- Set root password? Y
- New password: Type new root password
- Re-enter new password: Confirm the password
- Remove anonymous users? Y
- Disallow root login remotely? Y
- Remove test database and access to it? Y
- Reload privilege tables now? Y
- Third, install PHP modules
WordPress depends on PHP modules to function. Without PHP and its modules, WordPress won’t function. To install PHP, run the commands below.
sudo yum -y install php php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-mysql
After installing Apache2, MariaDB and PHP modules, your server is now ready to run WordPress.
The next things to do are create WordPress database, download WordPress content and configure WordPress settings.
To create WordPress database, follow these steps:
Run the commands below to logon to MariaDB database server.
mysql -u root -p
Then run the commands below to create a new database called wpdatabase.
CREATE DATABASE wpdatabase;
Next, run the commands below to create a WordPress database user called wpuser with a password.
CREATE USER wpuser@localhost IDENTIFIED BY 'user_password_here';
Finally, great the new user rights and privileges to manage the newly created database.
GRANT ALL PRIVILEGES ON wpdatabase.* TO wpuser@localhost;
Flush and exit.
FLUSH PRIVILEGES;
exit
After that, go and download WordPress content from online and extract it.. then copy it over to Apache2 default root directory.
WordPress content can be downloaded using the commands below.
cd /tmp/ && wget http://wordpress.org/latest.zip
Next, extract the content and copy it to the /var/www/html directory.
unzip latest.zip
sudo cp -rf wordpress/* /var/www/html/
Next, change the permissions and ownership of the WordPress content folders.
chown -R apache:apache /var/www/html
chmod -R 755 /var/www/html
Next, create a copy of wp-config-sample.php and neame it wp-config.php.
sudo cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
Then edit the wp-config.php file and enter the database name, database username and user password you created earlier.
vi /var/www/html/wp-config.php
// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wpdatabase‘);
/** MySQL database username */
define(‘DB_USER’, ‘wpuser‘);
/** MySQL database password */
define(‘DB_PASSWORD’, ‘databse user password‘);
Save the file.
Finally, enable HTTP traffic through the firewall.
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
Restart Apache2, then open your browser and browse to your server. You should see WordPress configuration page.
That’s it!
Frequently Asked Questions
How do I install WordPress on a CentOS server?
To install WordPress on a CentOS server, you need to first ensure you have root or administrator access. Then follow a step-by-step guide to install required packages like Apache2 and Mariadb.
What are the key steps to install Apache2 on CentOS for WordPress?
To install Apache2 on CentOS for WordPress, use the command 'sudo yum -y install httpd'. After installation, start, stop, and enable Apache2 using 'sudo systemctl stop httpd', 'sudo systemctl start httpd', and 'sudo systemctl enable httpd'.
Why is Mariadb recommended over MySQL for WordPress on CentOS?
Mariadb is recommended over MySQL for WordPress on CentOS because CentOS has shifted towards supporting Mariadb in its repositories. Installing Mariadb simplifies the process of setting up the database server for WordPress.
How can I check my access level to a CentOS server for WordPress installation?
To check your access level to a CentOS server for WordPress installation, verify if you have root or administrator access. Without the necessary permissions, you may face limitations in installing required packages.
What are the main requirements for running WordPress on a CentOS server?
The main requirements for running WordPress on a CentOS server include installing Apache2 as the web server and Mariadb as the database server. Ensure you have the necessary access level and follow the installation steps.
Can WordPress be installed on other Linux distributions besides CentOS?
Yes, WordPress can be installed on various Linux distributions like Ubuntu and Fedora, in addition to CentOS. The installation process may vary slightly depending on the distribution, but the general steps remain similar.
Why is Apache2 the recommended web server for WordPress on CentOS?
Apache2 is the recommended web server for WordPress on CentOS due to its popularity and extensive support within the web hosting community. Installing Apache2 ensures compatibility and smooth operation of WordPress.
What are the advantages of using WordPress as a CMS on a CentOS server?
Using WordPress as a CMS on a CentOS server offers advantages such as ease of management, a wide range of plugins and themes, and a strong community for support and updates. WordPress simplifies website and blog creation for users of all levels.