Installing and configuring WordPress
See HowToForge’s Installing WordPress on CentOS 7 guide for reference.
When we created our domain example.com, one of the default options was to create a database for the website. Therefore, our MySQL instance already has a website for us to store our WordPress database (called “example”). However, I’d suggest creating a separate MySQL user for WordPress to use for database connections.
First, let’s enter MySQL’s command mode:
[newuser@mail ~]$ mysql -u root -p
Enter the master MySQL password when prompted. Now, let’s create a database user called “wordpressuser”.
MariaDB [(none)]> CREATE USER wordpressuser@locahost IDENTIFIED BY 'wordpressuserpassword'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON example.* to wordpressuser@localhost; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> exit
Now we need to restart the HTTP and MySQL services:
[newuser@mail ~]# sudo systemctl restart httpd [newuser@mail ~]# sudo systemctl restart mariadb
Let’s create firewall rules that allow web traffic:
[newuser@mail ~]# sudo firewall-cmd --add-service=http [newuser@mail ~]# sudo firewall-cmd --add-service=https [newuser@mail ~]# sudo firewall-cmd --permanent --add-service=http [newuser@mail ~]# sudo firewall-cmd --permanent --add-service=https
We now need to obtain the latest WordPress installation files. We’ll do this as the domain user so file permissions are set appropriately. When we created our domain example.com, a system user “example” was created and granted SSH, e-mail, and FTP access. We’ll want to use this user to perform the next steps. First, we’ll switch to that user:
[newuser@mail ~]# su example
Enter example’s password when prompted. Then, let’s change to our domain’s tmp directory:
sh-4.2$ cd ~/tmp
Now download the latest WordPress installation archive using the wget command:
sh-4.2$ wget http://wordpress.org/latest.zip
Let’s unzip (decompress) the files we just downloaded. By default, the website for example.com will be housed in /home/example/public_html. WordPress, by default, keeps all of its files in a wordpress folder. I want my WordPress installation to be the root of my site, so I’ll extract the files, then move them:
sh-4.2$ unzip -q latest.zip -d ~/public_html/ sh-4.2$ mv ~/public_html/wordpress/* ~/public_html/
If we now point our browser to http://example.com, we should see WordPress’ installation wizard. Choose your language, then enter the requested information:
Database name: example
Database user: wordpressuser
Database user password: wordpressuserpassword
Database host: localhost
Database table prefix: wp_
Complete the installation, then login to WordPress using the credentials created during the installation.
Let’s now install Roundcube webmail!