How To Install and Configure Squid 3 on CentOS

Install and Configure Squid 3 on CentOS

Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-requested web pages. Squid has extensive access controls and makes a great server accelerator. It runs on most available operating systems, including Windows and is licensed under the GNU GPL.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges.

In this tutorial we are going to learn how to install and configuration of Squid on your CentOS server.

Install and Configure Squid 3 on CentOS

Step 1. To install, first you must update yum repository and packages by typing the below command:

 #yum -y update

Step 2. Installing Squid 3.

Install squid package and dependencies using the below command :

 #yum -y install squid

Step 3. Configuration Squid.

Edit squid configuration file ‘/etc/squid/squid.conf’

 #nano /etc/squid/squid.conf
# Recommended minimum configuration:
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_passwd
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users

acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32
acl SSL_ports port 443
acl Safe_ports port 80        # http
acl Safe_ports port 21        # ftp
acl Safe_ports port 443        # https
acl Safe_ports port 1025-65535    # unregistered ports
acl Safe_ports port 280        # http-mgmt
acl Safe_ports port 488        # gss-http
acl Safe_ports port 591        # filemaker
acl Safe_ports port 777        # multiling http
acl CONNECT method CONNECT

http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny all
http_port 3128

hierarchy_stoplist cgi-bin ?
coredump_dir /var/spool/squid
cache deny all

refresh_pattern ^ftp:        1440    20%    10080
refresh_pattern ^gopher:    1440    0%    1440
refresh_pattern -i (/cgi-bin/|\?) 0    0%    0
refresh_pattern .        0    20%    4320

icp_port 3130

forwarded_for off

request_header_access Allow allow all
request_header_access Authorization allow all
request_header_access Proxy-Authorization allow all
request_header_access Proxy-Authenticate allow all
request_header_access Cache-Control allow all
request_header_access Content-Encoding allow all
request_header_access Content-Length allow all
request_header_access Content-Type allow all
request_header_access Date allow all
request_header_access Expires allow all
request_header_access Host allow all
request_header_access If-Modified-Since allow all
request_header_access Last-Modified allow all
request_header_access Location allow all
request_header_access Pragma allow all
request_header_access Accept allow all
request_header_access Accept-Charset allow all
request_header_access Accept-Encoding allow all
request_header_access Accept-Language allow all
request_header_access Content-Language allow all
request_header_access Mime-Version allow all
request_header_access Retry-After allow all
request_header_access Title allow all
request_header_access Connection allow all
request_header_access Proxy-Connection allow all
request_header_access User-Agent allow all
request_header_access Cookie allow all
request_header_access All deny all
visible_hostname wpcademy.com

Step 4. Create our authentication file which Squid can use to verify for user authentications:

 #htpasswd -b /etc/squid/squid_passwd username password

Example:

 #htpasswd -b -c /etc/squid/squid_passwd ranty ratna

Congratulation’s! You have successfully installed squid. Thanks for using this tutorial for installing squid proxy on CentOS system. For additional help or useful information, we recommend you to check the official squid web site.

You Might Also Like: How To Install Redis on Ubuntu 16.04 LTS

How to install Java on Ubuntu

How to install Java on Ubuntu

There are many programs and scripts that require java to run it, but usually Java is not installed by default on VPS/Dedicated Server. In this tutorial we are going to learn a simple step to install Java on your Ubuntu machine.

Java is at the heart of our digital lifestyle. It’s the platform for launching careers, exploring human-to-digital interfaces, architecting the world’s best applications, and unlocking innovation everywhere—from garages to global organizations.

Java technology allows you to work and play in a secure computing environment. Upgrading to the latest Java version improves the security of your system, as older versions do not include the latest security updates.

Java allows you to play online games, chat with people around the world, calculate your mortgage interest, and view images in 3D, just to name a few.

install Java on Ubuntu

First step, update apt-get repository

 apt-get update

Second step, install java run time

 apt-get install default-jre

Third step, install java development kit

 apt-get install default-jdk

Fourth step, check java installation

 java -version

Result:

java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

OK that’s all for now the tutorial to install Java Runtime and Java Development Kit on Ubuntu.

Congratulation’s! You have successfully installed Java. Thanks for using this tutorial for installing Oracle Java on Ubuntu system. For additional help or useful information, we recommend you to check the official Java web site.

You Might Also Like: How To Install Oracle Java on Ubuntu 17.04

How To Reset Root Password on MySQL Server

Reset Root Password on MySQL Server

By default, MySQL server will be installed with root account and password is blank. Have you ever forgotten the root password on one of your MySQL servers? If you have set the password for root and forget it, then you will need to reset the root password for MySQL. To reset your mysql password just follow these instructions and we assume that you already have a small amount of knowledge on MySQL.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The reset password MySQL is quite simple. I will show you through the step by step reset root password MySQL server.

Reset Root Password MySQL Server

Step 1. First thing to do is stop MySQL.

### CentOS 6 ###
service mysqld stop

### CentOS 7 ###
systemctl stop mysqld

Step 2. Next we need to start MySQL in safe mode with the –skip-grant-tables option so that it will not prompt for password.

 mysqld_safe --skip-grant-tables &

Step 3. Start the mysql client process using this command with root account and blank password.

 mysql -u root

Step 4. Change password for root account.

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where #User='root';
mysql> flush privileges;
mysql> quit

Step 5. Restart MySQL.

Once complete, you can restart MySQL is installed by running the below command:

### CentOS 6 ###
service mysqld restart

### CentOS 7 ###
systemctl restart mysqld

Congratulation’s! You have successfully reset password MySQL. Thanks for using this tutorial for reset root password MySQL on Linux system. For additional help or useful information, we recommend you to check the official MySQL web site

You Might Also Like: How To Backup and Restore MySQL Database Using Command Line

How To Enable Slow Query Log for MySQL

Enable Slow Query Log for MySQL

MySQL has built-in functionality that allows you to log SQL queries to a file, You can enable the full SQL queries logs to a file or only slow running queries log. It is easy for us to troubleshoot/ debug the sql statement if SQL queries log enable, The slow query log is used to find queries that take a long time to execute and are therefore candidates for optimization. We assume that you already have MySQL installed on Linux system with administrative privileges and we assume that you already have know how on MySQL.

In order to enable slow query logs for MySQL on your system you would need to do the following.

Enable Slow Query Log for MySQL

Step 1. Edit the /etc/my.cnf file with your favorite text editor.

 #nano /etc/my.cnf

 Step 2. Once you have your my.cnf file open, add the following line under the “[mysqld]” section.

[mysqld]
log-slow-queries
log-slow-queries= /var/log/mysql/slow-queries.log
long_query_time=1

 Step 3. Then create the file slow-queries.log. You can have the file in any spot you wish, as long as you define the path in your my.cnf.

#touch /var/log/mysql/slow-queries.log
#chown mysql.mysql /var/log/mysql/slow-queries.log

Step 4. After that, restart mysql service. Enter the following command:

 #service mysqld restart

Congratulation’s! You have successfully enable slow query log on MySQL. Thanks for using this tutorial for enable slow query log on MySQL in Linux system. For additional help or useful information, we recommend you to check the official MySQL web site.

You Might Also Like: How To Install Mtop (MySQL Database Server Monitoring) on CentOS 6

How To Increase PHP Memory Limit

Increase PHP Memory Limit

If you have seen an error like ”Fatal Error: PHP Allowed Memory Size Exhausted” in webserver logs or your browser, this means that PHP has exhausted the maximum memory limit. This tutorial we will show two different ways on how you can increase the php memory limit in your server.

Check PHP Memory Limit

You can check by creating a file called info.php in /var/www/html/ with the following content:

<?php phpinfo(); ?>

php-memory-limit

Increase PHP Memory Limit

Method 1. Changing memory limit from php.ini

First find locate the php.ini file used by your web server.

 #nano /etc/php.ini

Search “memory_limit” in your php.ini, and change it. If no “memory_limit” found, add the following line at the end of php.ini

 #memory_limit = 64M ;Maximum amount of memory a script may consume (64MB)

Restart webserver

#service httpd restart
or
#service nginx restart

Method 2. Changing memory limit using .htaccess

Find the “.htaccess” in your root directory of the specified domain, edit the .htaccess file in the web root directory. Look for the section:

 #php_value memory_limit 64M; Maximum amount of memory a script may consume (64MB)

Edit your wp-config.php file, if you are using WordPress

define('WP_MEMORY_LIMIT', '256M');

Congratulation’s! You have successfully increase PHP memory limit. Thanks for using this tutorial for increase PHP memory limit linux system. For additional help or useful information, we recommend you to check the official PHP web site

You Might Also Like: How To Install PHP 5.5 on CentOS

How To Remove MySQL Server from CentOS

Remove MySQL Server from CentOS

MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. The MySQL source code is freely available because it was originally developed as freeware. MySQL is written in C and C++ and is compatible with all major operating systems. MySQL can be used for a variety of applications, but is most commonly found on Web servers.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The uninstall or removing is quite simple. I will show you through the step by step removing MySQL on CentOS server. May be it’s good idea to backup databases before doing this.

In this tutorial we will guide you how to completely remove of MySQL from your CentOS server.

Completely Removing MySQL Server in CentOS

Step 1: Check list the mysql rpm which is installed on server

#rpm -qa | grep mysql
or
#yum list installed | grep mysql

Step 2 : Removing all mysql-related packages (with “yum remove”)

 #yum remove mysql-client mysql-server mysql-common mysql-devel

Step 3: Delete the databases folder

#rm -rf /var/lib/mysql/
#rm -rf /etc/my.cnf

If you need to reinstall mysql database server, check out our tutorial, click here.

Congratulation’s! You have successfully removes MySQL. Thanks for using this tutorial for removing MySQL server on CentOS system. For additional help or useful information, we recommend you to check the official MySQL web site

You Might Also Like: How To Install MySQL Database Server on CentOS

How To Install MySQL Database Server on CentOS

Install MySQL Database Server on CentOS

MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. The MySQL source code is freely available because it was originally developed as freeware. MySQL is written in C and C++ and is compatible with all major operating systems. MySQL can be used for a variety of applications, but is most commonly found on Web servers.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple.

In this tutorial we will guide you through the step by step installation MySQL in CentOS server.

Install MySQL Database Server on CentOS

To install, first you must add the Remi yum repository information corresponding to your CentOS/RHEL version to yum:

For CentOS 6.x use:

#rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
#rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

 For CentOS 5.x use:

#rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
#rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

After installing Remi repository on your system, then look for MySQL latest version using –enablerepo=remi switch option.

 #yum --enablerepo=remi list mysql mysql-server

Sample output:

Installing MySQL 5.5.37:

 #yum --enablerepo=remi install mysql mysql-server

Starting / Stopping MySQL Server on CentOS

#service mysqld start
#service mysqld restart
#service mysqld stop

Hardening MySQL with mysql_secure_installation:

 #mysql_secure_installation

Connecting to MySQL Server:

Connecting to newly installed MySQL server by providing username and password.

 #mysql -u root -p

Congratulation’s! You have successfully installed MySQL. Thanks for using this tutorial for installing MySQL server in CentOS system. For additional help or useful information, we recommend you to check the official MySQL web site.

You Might Also Like: How To Install MariaDB On CentOS 6