CentOS 8 / Redhat 8 install wordpress with let's encrypt ssl https.

Set Current Hostname :

hostnamectl set-hostname example.com
hostnamectl restart systemd-hostnamed

Install EPEL release

yum -y install epel-release

Install httpd mod_ssl php and mariadb server database

yum -y install php php-mysqlnd php-json mod_ssl httpd mariadb-server

Enable httpd and mariadb server database

systemctl enable mysqld
systemctl enable httpd
systemctl start mariadb httpd

Configure Mariadb Secure Installation

mysql_secure_installation

Configure User WordPress and database

# mysql -u root -p
Enter password:
## Create database ##
CREATE DATABASE wordpress;
## Creating new user ##
CREATE USER wordpress@localhost IDENTIFIED BY "change_this";
## Grant privileges to database ##
GRANT ALL ON wordpress.* TO wordpress@localhost;
## FLUSH privileges ##
FLUSH PRIVILEGES;
## Exit ##
exit

Configuring Firewalld to open traffic for http and https

yum -y install firewalld
firewall-cmd –zone=public –permanent –add-service=http
firewall-cmd –zone=public –permanent –add-service=https

Install https ssl letencrypt

wget https://dl.eff.org/certbot-auto
mv certbot-auto /usr/local/bin/certbot-auto
chown root /usr/local/bin/certbot-auto
chmod 0755 /usr/local/bin/certbot-auto
/usr/local/bin/certbot-auto

Edit SSL.conf /etc/httpd/conf.d/ssl

add

DocumentRoot /var/www/html/wordpress

INSTALL WORDPRESS

cd /var/www/html
wget https://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz
chown -R apache:apache wordpress
rm -rf latest.tar.gz

Point your browser to https://domain.com and follow the instruction. 🙂

WordPress How to add color for code using prismjs. Useful for presenting Code with color.

  1. Download PrismJS from http://prismjs.com/ note: only choose language that you want to use or else your file is bigger and may be will slow your site.

2 . Download the JS and CSS do not click download from the top, it will reload the page again . scroll down to the bottom and you will see

3. once you download your prism.js and prism.css , we need to upload it to our theme directory which is at /yourwordpress/directory/wp-content/themes/yourthemehere

upload prism.js to /yourwordpress/directory/wp-content/themes/yourthemehere/
upload prism.css to /yourwordpress/directory/wp-content/themes/yourthemehere/
4. chown apache:apache /yourwordpress/directory/wp-content/themes/yourthemehere/prism.js
chown apache:apache /yourwordpress/directory/wp-content/themes/yourthemehere/prism.css
chmod 644 /yourwordpress/directory/wp-content/themes/yourthemehere/prism.js
chmod 644 /yourwordpress/directory/wp-content/themes/yourthemehere/prism.css

3. Edit your theme functions.php:

On the theme editor, click on “Theme Functions” and add this code:

Add it to the bottom of your function.php

// Function to add prism.css and prism.js to the site
function add_prism() {
    // Register prism.css file
    wp_register_style(
        'prismCSS', // handle name for the style so we can register, de-register, etc.
        get_stylesheet_directory_uri() . '/prism.css' // location of the prism.css file
    );
    // Register prism.js file
    wp_register_script(
        'prismJS', // handle name for the script so we can register, de-register, etc.
        get_stylesheet_directory_uri() . '/prism.js' // location of the prism.js file
    );
    // Enqueue the registered style and script files
    wp_enqueue_style('prismCSS');
    wp_enqueue_script('prismJS');
}
add_action('wp_enqueue_scripts', 'add_prism');

To use prism just edit your post with this at the beginning of html
example below we are using python highlighter.

<pre><code class="language-javascript">
enter your text here.
</code></pre>

Alternatively , We can Use Plugin , Which Is Call Prismatic.

https://wordpress.org/plugin/prismatic

To use prismatic see the screenshot below. Find the Button of Prismatic at your wordpress editor which is normally at Formatting Block.

Once you used it quite often it will be there in Most Used.

To use it press Prismatic button , once you add text , convert it to html and edit language to your choice language . example .

code class=”language-yourchoiceoflanguage”

source : https://crambler.com/how-to-implement-prism-js-syntax-highlighting-into-your-wordpress-site/

Setup Centos 7 / RHEL 7 WordPress + FreeSSL

Since wordpress is not supporting php that come with centos 7 default package anymore , we use remi php repo , at current of this tutorial , stable php is version 7.3. Follow guide through of the following command . it just take than 5 minute before you have wordpress site running with Let’s encrypt free ssl .

# yum -y update

# hostnamectl set-hostname yourdomain.com

# systemctl restart systemd-hostnamed

# yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

# yum install yum-utils

# yum-config-manager –disable remi-php54

# yum-config-manager –enable remi-php73

# yum install httpd mod_ssl mariadb mariadb-server php php-common php-mysql php-gd php-xml php-mbstring php-mcrypt

# systemctl enable mariadb

# systemctl enable httpd

# systemctl start httpd

# systemctl start mariadb

# mysql_secure_installation

# mysql -u root -p
Enter password:
## Create database ##
CREATE DATABASE wordpress;
## Creating new user ##
CREATE USER wordpress@localhost IDENTIFIED BY "change_this";
## Grant privileges to database ##
GRANT ALL ON wordpress.* TO wordpress@localhost;
## FLUSH privileges ##
FLUSH PRIVILEGES;
## Exit ##
exit

# cd /var/www/html

# yum -y install wget

# wget http://wordpress.org/latest.tar.gz

# tar -xvzf latest.tar.gz

# chown -R apache:apache /var/www/html/wordpress

# vi /etc/httpd/conf.d/yourdomain.com.conf

<VirtualHost *:80>
   ServerAdmin admin@yourdomain.com
   DocumentRoot /var/www/html/wordpress
   ServerName yourdomain.com
   ServerAlias www.yourdomain.com
   ErrorLog /var/log/httpd/yourdomain.com-error-log
   CustomLog /var/log/httpd/yourdomain.com-acces-log common
</VirtualHost>

# systemctl restart httpd

Now we are setting up Let’s Encrypt SSL Certificate to Secure Apache on RHEL/CentOS 7. Follow the walk through

# yum install epel-release

# cd /usr/local/

# git clone https://github.com/letsencrypt/letsencrypt

# cd /usr/local/letsencrypt/

Almost Finished Hang in there . now just run ./letsencrypt-auto and follow the installation. As easy as that and restart httpd.

# ./letsencrypt-auto

# systemctl restart httpd

Verify our brand new https by clicking link below
https://www.ssllabs.com/ssltest/analyze.html
Enjoy !!!