Configure Nginx Server Blocks on CentOS 7 - Step by Step Process ?
This article covers how to create an Nginx server block configuration to host multiple website on a single CentOS server.
Server Blocks, often referred to as Nginx virtual host are a feature of the Nginx web server that allows you to host multiple websites on one server.
To Test NGINX configuration file, run the command:
$ sudo nginx --t
If the syntax is OK, the output tells you the test was successful.
To restart your Nginx web server and confirm that it's running as expected:
$ sudo systemctl restart nginx
$ sudo systemctl status Nginx
To Enable HTTPS on Domain Hosted on Nginx:
You may consider encrypting your domain using Lets Encrypt SSL to add a layer of protection and secure traffic to and from the webserver:
$ sudo dnf install certbot python3-certbot-nginx
$ sudo certbot --nginx
Install Nginx on CentOS 7 Server - Step by Step Process ?
This article covers how to Install and configure Nginx on your CentOS 7 server. Now you can deploy your applications and use Nginx as a web or proxy server.
Nginx is a high performance web server software. It is a much more flexible and lightweight program than Apache HTTP Server.
To Install Nginx Web Server on CentOS 8:
1. Install the nginx package with:
$ sudo dnf install nginx
When prompted, enter y to confirm that you want to install nginx. After that, dnf will install Nginx and any required dependencies to your server.
2. After the installation is finished, run the following commands to enable and start the server:
$ sudo systemctl enable nginx
$ sudo systemctl start nginx
This will make Nginx start at system boot.
To configure Firewall Rules on CentOS for Nginx:
1. Run the following command to permanently enable HTTP connections on port 80:
$ sudo firewall-cmd --permanent --add-service=http
2. To verify that the http firewall service was added correctly, you can run:
$ sudo firewall-cmd --permanent --list-all
3. To apply the changes, you'll need to reload the firewall service:
$ sudo firewall-cmd --reload
Secure Apache with Let's Encrypt on CentOS 7 - Step by Step Process ?
This article covers how to secure Apache with Let's Encrypt SSL on CentOS 7 using Certbot client. Also, you will learn how to set up a cronjob for automatic certificate renewal. Basically, A security certificate is critical for securing traffic sent from web browsers to web servers. Let's Encrypt certificate is a free, open and automated certificate authority that you can use to encrypt your site. The certificate expires after every 90 days and auto-renews at absolutely no cost.
To Install Certbot in CentOS 8.
Certbot is a client that automates the installation of the security certificate. It fetches the certificate from Let's encrypt authority and deploys it on your web server without much of a hassle.
1. Before downloading certbot, first, install packages that are necessary for the configuration of an encrypted connection:
$ sudo dnf install mod_ssl openssl
2. Download certbot using the curl command:
$ sudo curl -O https://dl.eff.org/certbot-auto
3. Next, move the certbot file to the /usr/local/bin directory and assign the execute file permissions:
$ sudo mv certbot-auto /usr/local/bin
$ sudo chmod 755 /usr/local/bin/certbot-auto
To Assign the permissions to the Document root of a domain:
$ sudo chown -R apache:apache /var/www/domain.com
For the changes to come into effect, restart the Apache service:
$ sudo systemctl restart httpd
Install MySQL on CentOS 7 Server - Step by Step Process ?
This article covers how to install and secure a MySQL server on a CentOS 7 server. MySQL is one of the most widely used database management systems for websites and server applications.
To start the MySQL server daemon with the following command:
$ sudo systemctl start mysqld
systemctl doesn't display the outcome of all service management commands, so to be sure we succeeded, we'll use the following command:
$ sudo systemctl status mysqld
To configure MySQL, run the following command:
$ sudo mysql_secure_installation
To Current MySQL Version, run the command:
$ mysql -u root -p
Terms used in Managing MySQL User Permissions:
- SELECT – users can read through the database using the select command.
- CREATE – they can generate new tables.
- DROP – allows users to remove tables.
- DELETE – users can take out rows from tables.
- INSERT – lets users add in rows into tables.
- UPDATE – enable them to update the rows.
- GRANT OPTION – they can grant or remove the privileges of other users.
Configure Apache Virtual Hosts on CentOS 7
This article covers method to easily configure Apache virtual hosts. You repeat same procedure for multiple domain.
You can use yum to install Apache through CentOS's default software repositories:
$ sudo yum -y install httpd
Next, enable Apache as a CentOS service so that it will automatically start after a reboot:
$ sudo systemctl enable httpd.service
How to Set Up Local Hosts File ?
If you are on a Mac or Linux computer, edit your local hosts file with administrative privileges by typing:
$ sudo nano /etc/hosts
The details that you need to add are the public IP address of your VPS followed by the domain that you want to use to reach that VPS:
This will direct any requests for example.com and example2.com on our local computer and send them to our server at server_ip_address.
Install PHP 7.4, 7.3, 7.2, 7.1 on CentOS 7 & CentOS 8 - Step by Step Process ?
This article covers how to install specific version of PHP 7 on CentOS 7 Linux server. PHP is a programming language often used to automate server tasks. It is part of the LAMP (Linux, Apache, MySQL, PHP) stack, which is a bundle of software used for running internet servers and services. PHP handles dynamic content, database requests, and processing and displaying data.
To Verify PHP Version:
You can Check which version of PHP you are running with the command:
$ php –v
To Install PHP with Apache on CentOS:
1. Start by installing the yum-utils package by entering the following command in a terminal window:
$ sudo yum install yum-utils –y
2. Then, enable the epel-release repository by entering the following:
$ sudo yum install epel-release –y
3. Finally, add the following software repositories that contain the PHP packages:
$ sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
4. For PHP 7.3, you can enable PHP 7.3. Install the release with the following commands:
$ sudo yum-config-manager ––enable remi–php73
$ sudo yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql –y