How to Setup Let’s Encrypt FREE SSL Certificate on Centos 6 Apache using Certbot?

Having SSL on your website these days is important especially if you want your website to rank better on Google search, and that’s when Let’s Encrypt come into the picture.

Let’s Encrypt is a free, automated, and open certificate authority (CA), run for the public’s benefit. It is a service provided by the Internet Security Research Group (ISRG).

Without further ado, let’s begin with the tutorial.

Step 1: Install Certbot

Installing Certbot via certbot-auto script.

Step 2: Get Certificate & Edit Apache Config

It should bring you through a series of steps to have your SSL certificate setup.

Select the site you want to have SSL certificate installed on.

Step 3: Configure CRON Job for Cert Renewal

The following are commands to renewal your SSL certificate.

Dry Run

Actual Command

Add actual command to crontab.

Enter :i and paste the following in the file following by ctrl+c and :wq to quit and save editor.

 

That’s it all is done.

How to Change Time Zone on CentOS 6?

Always having difficulty on how to change time zone on CentOS 6? Just bookmark this page and everything will be solved.

Identify your current time zone

There are two ways to identify your current time zone.

or

Change time zone

Change “Amercia/Chicago” to the respective time zone that you want.

 

[Additional] Change PHP time zone

Search for this line

Change it to

Of course change it the time zone you want it to be

 

After running the commands above, remember to run the first step again to check that your time zone has been updated successfully.

That’s it. Changing CentOS 6 time zone is as simple as this.

Install Varnish Cache on CentOS 6/7

Varnish Cache is a tool that helps to cache web pages for quicker loading of web pages.

Here we will cover how to install Varnish Cache on CentOS 6/7.

Step 1: Add EPEL

CentOS 6

CentOS 7

Step 2: Download Varnish Cache

CentOS 6

CentOS 7

Step 3: Install Varnish Cache

CentOS 6/7

Step 4: Start Varnish Cache

CentOS 6

CentOS 7

Step 5: Set Varnish Cache to run on boot

CentOS 6

CentOS 7

 

That’s it! It’s that simple to setup Varnish Cache.

Feel free to contact me at [email protected] if you have any questions.

Install Zabbix Agent on CentOS/RHEL

Zabbix is an open source software for application and network monitoring. There are two types of Zabbix installation, namely Zabbix server and Zabbix agent. Zabbix server is installed on the server where you will oversee and monitor all the networks or devices. Zabbix agent is installed on all networks or devices so that the Zabbix server is able to communicate with it.

This tutorial guides you step by step on how to install and configure a Zabbix agent on CentOS/RHEL server.

Installing Zabbix Agent

1. Configure Yum Repository

Run the following commands accordingly to the version of CentOS/RHEL you are using.

CentOS/RHEL 7

CentOS/RHEL 6

CentOS/RHEL 5

2. Install Zabbix Agent

Command to install Zabbix agent

3. Update Zabbix Agent Configuration File

Your Zabbix agent configuration file should be located at /etc/zabbix/zabbix_agentd.conf.

Edit configuration file

Modify the following lines

Save and exit nano editor

4. Restart Zabbix Agent

Command to restart Zabbix agent

(Additional Information) Alternately, you can start/stop your Zabbix agent via the following commands.

 

That’s it! You are done installing Zabbix agent on your server.

In case you have missed out on how to install Zabbix server on your server, you can refer to the guide on how to install Zabbix server on CentOS/RHEL.

Feel free to email me at [email protected] if you have any questions.

Install Zabbix Server on CentOS/RHEL

Zabbix is an open source software for application and network monitoring. There are two types of Zabbix installation, namely Zabbix server and Zabbix agent. Zabbix server is installed on the server where you will oversee and monitor all the networks or devices. Zabbix agent is installed on all networks or devices so that the Zabbix server is able to communicate with it.

This tutorial guides you step by step on how to install and configure a Zabbix server on CentOS/RHEL server.

1. Set up Apache, MySQL and PHP

Install Apache

Install MySQL

Install PHP

Start Apache and MySQL services

Setup MySQL by running the following command

2. Configure Yum Repository

RPM repository needs to be configured before installing Zabbix.

Run the following commands according to the version of OS that you are using.

CentOS/RHEL 7

CentOS/RHEL 6

CentOS/RHEL 5

3. Install Zabbix Server with MySQL

Command to install zabbix server

4. Setup Zabbix Apache Configuration

Locate Zabbix’s own Apache configuration file. By default it should be located at /etc/httpd/conf.d/zabbix.conf. Modify the config file by added your time zone.

Added time zone to config file

Restart Apache service after changing the time zone value

5. Create Zabbix MySQL Database

Zabbix MySQL user and database is required as part of Zabbix server installation.

Login to your MySQL first

After which you will be prompt to enter your root password that you have configured previously when you setup MySQL.

Create Zabbix database

Create Zabbix MySQL user to access Zabbix database

Grant privileges to Zabbix user on Zabbix database

Flush privileges

Exit MySQL

After creating MySQL user and database for Zabbix, you will need to restore the default MySQL database provided by Zabbix. The files can be found at /usr/share/doc/zabbix-server-mysql-<version>/create/ directory.

Note: remember to change the version accordingly to the version that you are installing.

6. Start Zabbix Server

Command to start Zabbix server

7. Start Zabbix Web Installer

You can now access your Zabbix web installer via the following url

Zabbix Setup Welcome Screen

Following is the welcome screen of Zabbix web installer. Click on Next to proceed.

Screen Shot 2015-08-15 at 11.55.34 am

Installation pre-requisites

If everything is ok, click Next to proceed.

Screen Shot 2015-08-15 at 11.57.54 am

Configure Database Connection

Enter the database information that you have created previously. Then click on Test Connection. If everything is correct, click Next to proceed.

Screen Shot 2015-08-15 at 12.00.35 pm

Zabbix Server Details

Click on Next to proceed.

Screen Shot 2015-08-15 at 12.01.46 pm

Pre-Installation Summary Screen

If all information is correct, click on Next to proceed.

Screen Shot 2015-08-15 at 12.12.48 pm

Installation Success

Click on Finish to proceed.

Screen Shot 2015-08-15 at 12.03.40 pm

Zabbix Login Screen

You can now login to Zabbix via the following url

Default username and password is as follows

Screen Shot 2015-08-15 at 12.15.08 pm

 

 

That’s it! You are done installing Zabbix server on your server. For installation of Zabbix agent, you can refer to my guide on how to install Zabbix agent on CentOS/RHEL.

Feel free to email me at [email protected] if you have any questions.

Create New User and Grant Permissions in MySQL

MySQL is an open source relational database management software. It helps to store, organise and retrieve data. MySQL has a feature for you to create users to manage different databases or tables with certain permissions.

MySQL Permissions

The different types of permissions available in MySQL are as follows.

[su_table]

Permission Description
ALL PRIVILEGES allows user to perform all the following permissions on tables or databases
CREATE allows user to create tables or databases
DROP allows user to delete tables or databases
DELETE allows user to delete rows from tables
INSERT allows user to insert rows to tables
SELECT allows user to retrieve rows to tables
UPDATE allows user to update rows to tables
GRANT OPTION allows user to grant or remove other users’ privileges

[/su_table]

How to create a new user

Before being able to run any of these commands, you will have to login to your MySQL first, which usually we will use root to login at command line.

It should prompt you to enter your root password for MySQL. After that, you will be logged into your MySQL.

Command to create a new user

  • new_username – username of user
  • localhost – location in terms of ip address of MySQL to create user at
  • password – password for user to login to MySQL

After creating a new user in MySQL, we need to give the user permissions in order for the user to do anything.

  • new_username – username of user created previously
  • localhost – location in terms of ip address of MySQL where user was created at previously

Once you are done with the two commands above, you need to reload the permissions for MySQL.

 

That’s it! You are all set.

Feel free to drop me an email at [email protected] if you have any questions.

Install and Secure phpMyAdmin on CentOS 6.4

PhpMyAdmin is a popular web interface for web developers to manage MySQL databases. This tutorial will guide you through on how to install and secure PhpMyAdmin on your CentOS web server.

Pre-requisites

This guide assumes that you already have Apache and MySQL installed on your CentOS web server.
(Optional) Note that if you want to access PhpMyAdmin using SSL, then you will need to configure SSL certificate by referring to the following guide.

Setting up an SSL Secured Web Server with CentOS

1. Add EPEL Repositories

PhpMyAdmin is not included in CentOS packages, therefore you will need to add EPEL (Extra Packages for Enterprise Linux) to your web server.

(Optional) Run the following command to install wget if you haven’t install wget yet

Command to install EPEL packages to your web server

Check that EPEL has been added to your repository

You should see the following

Once done remove the respository configuration package

2. Download PhpMyAdmin

Command to download PhpMyAdmin

3. Configure PhpMyAdmin

Find your IP Address first
Then edit PhpMyAdmin config file

Modify the following 4 lines in the config file

Then save and close the config file

4. Open PhpMyAdmin in your Web Browser

Open the following url in your web browser

 

That’s it you are done!

Feel free to contact me at [email protected] if you have any questions.

Setting up an SSL secured Webserver with CentOS

This guide will teach you how to configure and setup your own SSL certification on your CentOS web server.

1. Install required software

Use yum to get the following software if its not yet installed on your web server.

yum install mod_ssl openssl

2. Generate a self-signed certificate

The following steps guides you on how to generate your own self-signed certificate.

Generate private key

openssl genrsa -out ca.key 2048

Generate CSR

openssl req -new -key ca.key -out ca.csr

Generate self-signed key

openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt

Copy the files to the respective locations

cp ca.crt /etc/pki/tls/certs

cp ca.key /etc/pki/tls/private/ca.key

cp ca.csr /etc/pki/tls/private/ca.csr

In cased you have moved the files and not copied them, use the following command to correct SELinux

restorecon -RvF /etc/pki

Update Apache SSL configuration file

sudo nano +/SSLCertificateFile /etc/httpd/conf.d/ssl.conf

Modified the paths to match where the new Key is stored

SSLCertificateFile /etc/pki/tls/certs/ca.crt

Then set the correct path for Certification Key file

SSLCertificateKeyFile /etc/pki/tls/private/ca.key

Finally quit and save the file then restart Apache

sudo service httpd restart

3. Configure firewall

The last step to setting up your own SSL certificate is to configure the firewall to accept requests from port 443, which is used for SSL connections.

Command to accept port 443 requests

iptables -A INPUT -p tcp --dport 443 -j ACCEPT

Save ip table

/sbin/service iptables save

iptables -L -v

 

That’s it! Your web server is now configured and ready for SSL connections.

Feel free to drop me any questions you have at [email protected]

 

Install Linux, Apache, MySQL, PHP (LAMP) stack on CentOS 6

LAMP stack is a group of open source softwares used to get web servers up and running. This guide assumes that you already have your CentOS installed successfully.

1. Install Apache

Apache is the web server in the lamp stack.

Install apache command

Start apache on your server

(Optional) Test if apache is alive

Get your IP address first

Then open the following url in your web browser

2. Install MySQL

MySQL is the database management system used in LAMP stack.

Install MySQL command

Start MySQL service

Set a root MySQL password

This will prompt you for your current MySQL root password, which you will most likely have none, because you have just installed MySQL only. So just leave it blank by pressing enter.

Next a series of yes/no questions will appear. All you have to do is just say Yes to all the options.

3. Install PHP

Install PHP command

(Optional) Install additional php modules

Search for PHP modules command

Next a bunch of php modules with their description will appear. So just use yum to install which ever modules that you want.

4. Configure Apache and MySQL to run on boot

5. Test if PHP is working on your server

By default apache web root directory is at /var/www/html

Create a file called info.php 

(Optional) If nano is not installed yet

Add the following code to info.php

Then save and exit

Restart Apache and visit the url on your web browser as follows

Then you should see your server’s php information

 

Feel free to contact me at [email protected] if you have any further questions.

Install APC (Alternative PHP Cache) in CentOS 5/6/7 and Fedora 20/21

APC (Alternative PHP Cache) is a free and open source tool to cache PHP codes.

phpapc

1. Install Dependency Packages for APC

2. Install APC using PECL (PHP Extension Community Library)

Press “Enter” for the following options

2a. [Alternative]

If the above command fails, you can use the following method to install APC as well.

3. Enable APC PHP Extension

4. Restart Apache Service for APC

CentOS

Fedora

5. Verify APC Installation

Create a file named phpinfo.php in Apache web root directory. For example our Apache web root directory is /var/www

And add the following code to the php file

[Optional] If you do not have nano installed

Open the following url in your web browser

Screen Shot 2015-08-02 at 2.48.22 pm

 

6. Enable PHP APC administration

Copy the following file to any web directory that you want. For example, in this case we will copy it to the web root directory.

Open the file apc.php 

In nano editor, use “Ctrl-w” to search for the username and password field to modify.

Open the following link in your web browser.

You should see your APC stats and that’s it!