Pages

Friday, November 15, 2019

SolusVM Master on CentOS 7

When moving a master from one server to another I came across a few issues with the new (v4) installer for SolusVM and CentOS 7.

The server was loaded with the minimal install of CentOS, and there is no specific information on SolusVM’s site for dependencies.

The first time I ran the install script, it never stated that there was a problem, but the back end web server was not accepting connections.

Long story short, before you run the SolusVM installer for CentOS 7, run the following command to ensure that the software needed is in place:

Thursday, October 31, 2019

How to block an IP?

If you want to stop someone from visiting your website, you can use the IP Blocker interface within cPanel which allows you to block access to your site for one or more IP addresses or fully qualified domain names (FQDNs).

You can easily block an IP in cPanel by following these steps:

1) Log into cPanel.
2) Look for the “SECURITY” section and click on “IP Blocker” icon.
3) You can add a single IP, an IP range or a domain name to the block list, click the “Add” button to set the block.
4) If you scroll down on the same page, you’ll see a list of all the blocked IPs, from here you can also delete an IP from the block list.

Rock on.

How to ban any IP Address via .htaccess

If someone is trying to hack your website or you want to block their IP Address, you can add this line to your .htaccess file.

order allow,deny
deny from IP-ADDRESS
allow from all


Replace “IP-ADDRESS” with the IP Address you want to block.

Rock on.

Set Password or SSH Key for CentOS Cloud Images using virt-sysprep

Step 1: Install virt-sysprep

Type the following apt-get command/apt command to install virt-sysprep on a Debian or Ubuntu Linux:

$ sudo apt install libguestfs-tools


If you are using a CentOS/RHEL/Oracle/Scientific Linux, type the following yum command:

$ sudo yum install libguestfs-tools


If you are using a Fedora Linux, type the following dnf command to install the same:

Saturday, October 26, 2019

How to Install MySQL on CentOS 7

This guide will outlined how to install MySQL on CentOS 7. MySQL is a widely used database management platform used by various applications. Many applications such as WordPress, Joomla and others rely on MySQL databases to function. MySQL however, must be installed with a few different steps since it’s no longer the default in the CentOS repositories.

All commands without sudo

yum update -y
yum install -y wget
wget http://repo.mysql.com/mysql-community-release-el7-7.noarch.rpm
rpm -ivh mysql-community-release-el7-7.noarch.rpm
yum update -y
yum install -y mysql-server
systemctl start mysqld
systemctl enable mysqld
mysql_secure_installation


All commands with sudo

How to Disable SSH Login for the Root User

In this document, we will show you to disable the SSH root login to your server.

A major security hole is to allow direct root access without any restrictions. This is an open door for hackers. They can attempt to brute force your root password and potentially get access to your server if the password can be guessed.

Quick Steps:

Login to the server via SSH.
Open the file “/etc/ssh/sshd_config” in any of your favorite text editors.
Find the section in the file containing the line with “#PermitRootLogin yes” in it.
Uncomment and change it to “PermitRootLogin no”.
Save the file and exit.
Restart the sshd service.


Disabling SSH Login for Root

The first step is to login to the server. Please note that you need to get more than one terminal access to the server because in case we lost one connection you can recover and get access to the server with the other one.

Open the SSH configuration file with your text editor.

How do I create a custom php.ini file

A custom php.ini file can be constructed and placed in your web account. For instance, using a text editor such as Notepad, you can create a php.ini file with the following custom setting which would override our default server setting:

file_uploads=off

The php.ini file should only contain the custom settings - each on it's own line (such as the above example). When completed, save the file and upload it to an area (folder) on your web account where the rest of your php files are located.

NOTE: The php.ini file should be uploaded into every folder and/or subfolder where the settings need to take place.  Be sure to rename your php.txt file to php.ini before you upload it to your server.

Cron jobs

A 'cron job' is an automated task that can be set up within your cPanel. This will typically be used to automate the running of a reminder script each day for example, or perhaps to run your own daily backup script. Any server task or script that needs regular scheduling is the perfect opportunity to use a cron job.

We would ask that you be sparing with your use of cron jobs however, as a resource-intensive script executing every five minutes for example would clearly breach our acceptable use policy. Our recommendation would be to schedule cron jobs to run only as and when they are needed.

Your online cPanel allows for the creation of cron jobs via a simple web interface. This is presented in plain english, and requires little understanding to operate.

If you decide to use the "Advanced" option however, the following information may assist you in understanding how the system works.

Understanding the format

How to host the Primary Domain from a subfolder (.htaccess)

Your main domain will use the public_html directory for all of its website files by default. Addon domains use sub directories inside the public_html directory.

In order to also set up your main domain to use a subdirectory on your hosting account you will need to set up a redirect in the .htaccess file in the public_html folder so that the server knows that any request for your main domain will be redirected to a subdirectory on public_html.

Modifying the .htaccess

The following code will need to be added to the .htaccess file in the public_html folder of your hosting account. You will need to insert the following code block and make modifications as noted in the (#) comments.

You will need to change the two instances of example.com to your domain, and the three instances of subdirectory to the folder where you want your site.

# Hostingname.com (Your Hosting Name)
# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on
# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ subdirectory/index.html [L]


Visitors to your website will not be able to tell that your main domain is using a subdirectory.

Note:  This method is not guaranteed to work with every script or software and can be used at your own discretion.

How to change the date.timezone value in PHP?

If your PHP scripts do not show the correct time, the reason is that most probably your hosting server is in a different timezone.

This can be easily resolved by changing a setting in PHP called date.timezone.
Depending on your location you can set a specific date.timezone value in PHP using the following option which should be added to your local php.ini file:
date.timezone = "US/Central" 

The above example assumes you'd like to set the timezone for your PHP scripts to US/Central. The full list of supported time zones is available here and you should simply replace "US/Central" with the desired timezone.

Cron PHP | How To Run PHP Scripts From Cron Jobs?

This article describes how to run PHP scripts from cron jobs.

Running PHP scripts from cron jobs

A common method for running PHP scripts from a cron job is to use a command-line program such as curl or wget. For example, the cron job runs a command similar to the following command:

curl http://example.com/script.php

In this command, curl retrieves the web page, which then runs the PHP script.

However, there is a better way to run PHP scripts on your web site from cron jobs. You can run the script directly by using the PHP command-line interpreter. This method is just as effective, and usually faster. The following command shows how to run a script using the PHP command-line interpreter:

Sunday, June 23, 2019

cPanel EasyApache 4 Installing Redis and Redis PHP extension

Installing the Redis daemon:
for CentOS 6/RHEL 6
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum -y install redis --enablerepo=remi --disableplugin=priorities
chkconfig redis on
service redis start

 
for CentOS 7/RHEL 7
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum -y install redis --enablerepo=remi --disableplugin=priorities
systemctl enable redis
systemctl start redis

 

Sunday, June 9, 2019

How To Secure Apache

Introduction

Let’s Encrypt is a Certificate Authority (CA) that provides an easy way to obtain and install free TLS/SSL certificates, thereby enabling encrypted HTTPS on web servers. It simplifies the process by providing a software client, Certbot, that attempts to automate most (if not all) of the required steps. Currently, the entire process of obtaining and installing a certificate is fully automated on both Apache and Nginx. In this tutorial, you will use Certbot to obtain a free SSL certificate for Apache on Ubuntu 18.04 and set up your certificate to renew automatically.
This tutorial will use a separate Apache virtual host file instead of the default configuration file. We recommend creating new Apache virtual host files for each domain because it helps to avoid common mistakes and maintains the default files as a fallback configuration.

Prerequisites

To follow this tutorial, you will need:

Saturday, June 8, 2019

Apache vs Nginx

Web server is essential for all server to serve the content over the internet. There are a lot of web servers available in the market. The two Major web servers are Apache and Nginx. A lot of people are confusing themselves about choosing the one among both of them. In this article, I am going to compare Apache and Nginx which will give the answer to your confusion. Both of these web servers can’t be replaced by each other. They have their uniqueness. You have to choose any of the web server based on the requirement. In this article, we will also see the nginx vs apache difference.

Here: I am going to compare Apache and Nginx with following factors

Connection Handling architecture
Static vs Dynamic content
Distributed vs Centralized configuration
File vs URI based interpretation
Modules
Compatibility
Using both of them together.
Apache
Apache was initially created by Robert McCool. The year of creation was 1995. After that, Apache has been developed by Apache software foundation from 1999. The actual organization is HTTP web server. But the foundation is now referred with the name of Apache. The Product name overrides the organization name. It becomes very famous after its launch since then the Apache foundation is benefiting from the documentation and integration with software. Apache is the first choice for many server administrators due to its power, compatibility and support for many platforms. The Apache is easily extensible through loading the dynamic module. Apache process many interpreted languages and it does not use any other external software for that.

How To Install Apache on CentOS 7

Apache HTTP server is the most popular web server in the world. It is a free, open-source and cross-platform HTTP server providing powerful features which can be extended by a wide variety of modules. The following instructions describe how to install and manage the Apache web server on your CentOS 7 machine.
Apache is available in the default CentOS repositories and the installation is pretty straight forward. On CentOS and RHEL the Apache package and the service is called httpd. To install the package run the following command:
sudo yum install httpd

Once the installation is completed, enable and start the Apache service:
sudo systemctl enable httpd
sudo systemctl start httpd

Saturday, May 11, 2019

How to Secure your Server

Here are some quick tips on how to secure your Linux server. This is only a short list, but, they are must do’s! Some of which are:

1. Change ssh port (use keys if possible as well/allow only specific users)
2. Disable unneeded services
3. Install a good firewall
4. Disable dangerous / unused PHP functions / harden your PHP
5. Install mod_security
6. Virus scan FTP uploads
7. Install root kit detection
8. Set root email to off server email account
9. Make sure your passwords are tough to guess. This is a big one, especially for the root user, this should be a very tough password.

This is a quick list, as there are many other things that can be done.