How To Install and Enable Alternative PHP Cache (APC) on CentOS

Install and Enable Alternative PHP Cache

The Alternative PHP Cache (APC) is a free, open, and robust framework for caching and optimizing PHP intermediate code. It’s an PECL extension which shares the packaging and distribution system with its sister, PEAR. In this post, i will show how to enable APC (Alternative PHP Cache) and makes PHP be fast.

In this tutorial we will show you how to install and configuration of Alternative PHP Cache (APC) on your CentOS server.

Install Alternative PHP Cache (APC) on CentOS

Step 1. Install dependencies.

 yum install php-pear php-devel httpd-devel pcre-devel gcc make

Step 2. Installing Alternative PHP Cache (APC) on CentOS.

 pecl install apc

Step 3. Configuring APC.

You can put your configuration in php.ini file but i prefer to have separate file like above for configuration. Values mentioned below are for demonstration purpose, different values  for APC can be set  which depends on number of PHP pages, size of memory in server, number of page hits e.t.c

#nano /etc/php.d/apc.ini

; Enable the extension module
extension = apc.so
 
; Options for the APC module version >= 3.1.3
; See http://www.php.net/manual/en/apc.configuration.php
 
; This can be set to 0 to disable APC.
apc.enabled=1
; The number of shared memory segments to allocate for the compiler cache.
apc.shm_segments=1
; The size of each shared memory segment, with M/G suffixe
apc.shm_size=512M
; A "hint" about the number of distinct source files that will be included or
; requested on your web server. Set to zero or omit if you're not sure;
apc.num_files_hint=1024
; Just like num_files_hint, a "hint" about the number of distinct user cache
; variables to store.  Set to zero or omit if you're not sure;
apc.user_entries_hint=4096
; The number of seconds a cache entry is allowed to idle in a slot in case this
; cache entry slot is needed by another entry.
apc.ttl=7200
; use the SAPI request start time for TTL
apc.use_request_time=1
; The number of seconds a user cache entry is allowed to idle in a slot in case
; this cache entry slot is needed by another entry.
apc.user_ttl=7200
; The number of seconds that a cache entry may remain on the garbage-collection list.
apc.gc_ttl=3600
; On by default, but can be set to off and used in conjunction with positive
; apc.filters so that files are only cached if matched by a positive filter.
apc.cache_by_default=1
; A comma-separated list of POSIX extended regular expressions.
apc.filters
; The mktemp-style file_mask to pass to the mmap module
apc.mmap_file_mask=/tmp/apc.XXXXXX
; This file_update_protection setting puts a delay on caching brand new files.
apc.file_update_protection=2
; Setting this enables APC for the CLI version of PHP (Mostly for testing and debugging).
apc.enable_cli=0
; Prevents large files from being cached
apc.max_file_size=1M
; Whether to stat the main script file and the fullpath includes.
apc.stat=1
; Vertification with ctime will avoid problems caused by programs such as svn or rsync by making
; sure inodes havn't changed since the last stat. APC will normally only check mtime.
apc.stat_ctime=0
; Whether to canonicalize paths in stat=0 mode or fall back to stat behaviour
apc.canonicalize=0
; With write_lock enabled, only one process at a time will try to compile an
; uncached script while the other processes will run uncached
apc.write_lock=1
; Logs any scripts that were automatically excluded from being cached due to early/late binding issues.
apc.report_autofilter=0
;This setting is deprecated, and replaced with apc.write_lock, so let's set it to zero.
apc.slam_defense=0

Step 4. Enable APC PHP Extension

Once that finishes, run the following command to enable APC extension in Apache configuration.

 echo "extension=apc.so" > /etc/php.d/apc.ini

Step 4. Restrat Nginx

 service httpd restart

APC provides a web interface with detailed information on the cache (memory usage, hits and misses, cache entries). By default it is not accessible so you need to copy the file /usr/share/php/apc.php to somewhere you can browse to. Now from browser, you can go to  http://domain.com/apc.php. I prefer to wait for a day to see the APC performance so we can have clear idea how well our configuration did.

Install Alternative PHP Cache (APC) on CentOS

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

How To Install Eclipse Luna on CentOS 7

Install Eclipse Luna on CentOS 7

Eclipse is an open source and free multi-language and multi-platform (Windows , Linux and Mac) software development program that used to build JAVA based web applications. It is written in Java program and can be used to develop Java based applications and other various plugins, including languages like C, C++, PHP, Perl, Python, Ruby and Rails framework.

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. We will show you through the step by step installation Eclipse on CentOS 7.

Step 1. First, Install Java required packages.

 yum install java

Check if java installed:

 java -version

Step 2. Download Eclipse Luna.

Download latest eclipse package. This guide uses Eclipse IDE for Java Developers version. Another popular versions are Eclipse IDE for Java EE Developers and Eclipse for PHP Developers. Select also 32-bit or 64-bit version depending on your system.

Extract Eclipse package (example /opt/):

 tar -zxvf eclipse-java-luna-SR1-linux-gtk-x86_64.tar.gz -C /opt

Make symbolic link to bin directory:

 ln -s /opt/eclipse/eclipse /usr/bin/eclipse

Step 3. Create Gnome desktop launcher.

 ##nano /usr/share/applications/eclipse.desktop

Add the following lines of code it, save and close the file:

[Desktop Entry]
Encoding=UTF-8
Name=Eclipse 4.4.1
Comment=Eclipse Luna
Exec=/usr/bin/eclipse
Icon=/opt/eclipse/icon.xpm
Categories=Application;Development;Java;IDE
Version=1.0
Type=Application
Terminal=0

Step 4. Start Eclipse.

From Desktop terminal run the following command to launch Eclipse:

 eclipse

From Desktop menu Gnome 3 Eclipse 4.4.1:

CentOS-7-Eclipse-4.4-Luna-Gnome

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

You Might Also Like:  How To Install Eclipse Luna on Ubuntu 14.04

How To Install Seafile on CentOS 6

Install Seafile on CentOS 6

Seafile is a open source cloud storage software. It offers file sharing and syncing for individual users and groups, it provides client side encryption and easy access from mobile devices. Also easily integrated with local services such as LDAP and WebDAV or can be deployed using advanced network services and databases like MySQL, SQLite, PostgreSQL, Memcached, Nginx or Apache Web Server.

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. We will show you through the step by step how to install Seafile on CentOS 6.

Install Seafile on CentOS 6

Step 1. First, Install required packages.

yum -y update
yum -y install python-imaging MySQL-python python-simplejson python-setuptools

Step 2. Download and install the latest version of Seafile.

Create a new user that will be used to run the seafile services:

adduser seafile
passwd seafile
su -seafile

You need to download the last relase of Seafile:

wget https://bitbucket.org/haiwen/seafile/downloads/seafile-server_4.0.6_x86-64.tar.gz
tar xfz seafile-server_4.0.6_x86-64.tar.gz
cd seafile-server_4.0.6/

Run this script which will create the required databases and directories for the Seafile server and and answer all questions using the following configuration options, after the script verifies the existence of all Python required modules:

 ./setup-seafile-mysql.sh

After Seafile server successfully installs, it will generate some useful information such as what ports needs to be open on your Firewall to allow external connection and what scripts to handle in order to start the server.

Step 3. Configure Iptables or firewall

# nano /etc/sysconfig/iptables
-A INPUT -p udp -m state --state NEW --dport 8000 -j ACCEPT
-A INPUT -p tcp -m state --state NEW --dport 8000 -j ACCEPT

Restart iptables to apply rules using the following command:

 service iptables restart

Step 4. Starting the Seafile services.

Now run the ‘seafile.sh’ and ‘seahub.sh’ scripts to start the Seafile server.

su - seafile
cd seafile-server_4.0.6
./seafile.sh start
./seahub.sh start

Step 5. Accessing Seafile.

Seafile will be available on HTTP port 8000 by default. Open your favorite browser and navigate to http://yourdomain.com:8000 or http://server-ip:8000. Enter the admin email id and password to login  which you have created at the time of installation. If you are using a firewall, please open port 8000 to enable access to the control panel.

seafile-web-interface-login

Congratulation’s! You have successfully installed Seafile. Thanks for using this tutorial for installing Seafile open source cloud storage on CentOS 6 system.

You Might Also Like: How To Install Seafile on Ubuntu 14.04

How To Install Exim Mail Server on CentOS 6

Install Exim Mail Server on CentOS

Exim is free software distributed under the terms of the GNU General Public License, and it aims to be a general and flexible mailer with extensive facilities for checking incoming e-mail. The Exim security record is much better than sendmail. Advanced features are queue handling, address routing and testing.

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. We will show you through the step by step how to Install Exim Mail Server on CentOS 6.

Step 1. First, we need to install the latest EPEL repository RPM suited to your architecture.

## RHEL/CentOS 6 64-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
## RHEL/CentOS 6 32-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm


Step 2. Install the Exim package.

 yum install exim-mysql -y

Step 3. Disable Postfix (the default MTA).

By default, CentOS using Postfix as MTA. Follow is how to disable and enable exim on CentOS. First, we stop the service and disable postfix for autostart:

service postfix stop
chkconfig postfix off

Step 4. Set Exim as the default MTA.

Next we change the default Postfix MTA to Exim. Press “2” enter to select Exim:

# alternatives --config mta
There are 2 programs which provide 'mta'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/sbin/sendmail.postfix
   2           /usr/sbin/sendmail.exim
Enter to keep the current selection[+], or type selection number: 2

Step 5. Start Exim service.

chkconfig exim on
service exim start

Step 6. Accessing Exim.

Now you are done with Exim installation. Let’s verify is the MTA working as expected:

$ echo 'Hello, welcome to the jungle exim MTA' | mail -s 'Exim testing email' 
# tail -F /var/log/exim/mainlog

Congratulation’s! You have successfully installed Exim. Thanks for using this tutorial for installing Exim Mail Server on CentOS 6 systems. Learn more from Exim Internet Mailer official Documentation.

How To Install CentOS Web Panel on CentOS 6

Install CentOS Web Panel

CentOS Web Panel is a free alternative to cPanel and provides plenty of features and designed for newbie who want to build a working hosting server easily and to take control or manage his/her server all in an intuitive web interface without having to open any SSH console. CentOS Web Panel provides Apache, Varnish, suPHP & suExec, Mod Security, PHP version switcher, Postfix and Dovecot, MySQL Database Managment, PhpMyAdmin, CSF Firewall, CageFS, SSL Certificates, FreeDNS (DNS server) and many more.

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. I will show you through the step by step installation CentOS Web Panel on CentOS 6.

Install CentOS Web Panel on CentOS 6

Step 1. First, you need to update the system to ensure that we have all of the latest software installed.

 yum update -y

Step 2. Setup Hostname.

You can use the following command for hostname setup:

 hostname srv1.wpcademy.com

Step 2. Downloading and install CentOS Web Panel script.

cd /usr/local/src
wget http://centos-webpanel.com/cwp-latest

Once you download the installer on your server, you are ready to start with the installation process. Installation will take approximately 5-15 minutes depends on your server speed and power. To do so, use the command below:

 sh cwp-latest

Step 3. Accessing CentOS Web Panel.

CentOS Web Panel will be available on HTTPS port 2031 by default. Open your favorite browser and navigate to https://yourdomain.com:2031 or http://server-ip:2030. To log in, you can use ‘root’ as user and your root password. If you are using a firewall, please open port 2030 to enable access to the control panel.

Congratulation’s! You have successfully installed CentOS Web Panel. Thanks for using this tutorial for installing CentOS Web Panel web server management on CentOS 6 system.

How To Install Virtualmin on CentOS 6

install virtualmin on centos

Virtualmin is an advanced web server management panel, and a very good alternative to cPanel, with the same administration structure based on root users, resellers, and clients. Once installed, you will be able to manage Apache, Nginx, PHP, DNS, MySQL, PostgreSQL, mailboxes, FTP, SSH, SSL, Subversion/Git repositories and many more.

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. I will show you through the step by step installation virtualmin on CentOS 6.

Step 1. First, you need to update the system to ensure that we have all of the latest software installed.

 yum update

Step 2. Install Virtualmin.

Virtualmin can be installed in a number of ways an automated install script or manual Installation. Now you can enter this command to get the installer:

 wget http://software.virtualmin.com/gpl/scripts/install.sh

Once downloaded, do a chmod +x to make the script executable:

 chmod +x install.sh

Now it is time to install VirtualMin. To do so, use the command below:

./install.sh
### During the installation it will ask you for the host name make sure you enter this correctly ###

Step 3. Accessing Virtualmin.

Virtualmin web based monitoring will be available on HTTPS port 10000 by default. Open your favorite browser and navigate to http://yourdomain.com:10000 or http://server-ip:10000. If you are using a firewall, please open port 10000 to enable access to the control panel.

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

You Might Also Like: How To Install Virtualmin on Ubuntu 14.04

How To Install PowerDNS on CentOS 6

install powerdns on centos

PowerDNS is a MySQL-based DNS server, written in C++ and licensed under the GPL. PowerDNS can be managed through a web interface (PowerAdmin). Unlike Bind, PowerDNS can be setup using a multitude of backends such as Bind Zone Files, or various Databases.

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. I will show you through the step by step installation PowerDNS on CentOS 6.

Step 1. First, you need to enable EPEL repository on your system.

## RHEL/CentOS 6 64-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
## RHEL/CentOS 6 32-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm

Step 2. Install MySQL.

 yum -y install mysql mysql-server

Enable MySQL on boot and start MySQL server:

service mysqld start
chkconfig mysqld on

Step 3. Configuring MySQL.

By default, MySQL is not hardened. You can secure MySQL using the mysql_secure_installation script. you should read and below each steps carefully which will set root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MySQL.

 mysql_secure_installation


Step 4. Create PowerDNS Database and User in MySQL.

Login as a MySQL root and create a new database and tables:

 mysql -uroot -p
create database powerdns;
GRANT ALL PRIVILEGES ON powerdns.* TO 'powerdns'@'localhost' IDENTIFIED BY 'powerdnsPassword';
use powerdns;

CREATE TABLE domains (
id INT auto_increment,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
primary key (id)
);
CREATE UNIQUE INDEX name_index ON domains(name);

CREATE TABLE records (
id INT auto_increment,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(6) DEFAULT NULL,
content VARCHAR(255) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
primary key(id)
);
CREATE INDEX rec_name_index ON records(name);
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);

CREATE TABLE supermasters (
ip VARCHAR(25) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) DEFAULT NULL
);
exit;

Step 5. Install PowerDNS.

 yum install pdns-backend-mysql pdns bind-utils

Enable PowerDNS on boot and start PowerDNS server:

service pdns start
chkconfig pdns on

Step 6. Configure PowerDNS.

Open the /etc/pdns/pdns.conf file and add the following lines:

launch=gmysql
gmysql-host=localhost
gmysql-user=powerdns
gmysql-password=powerdnsPassword
gmysql-dbname=powerdns

Finally, restart the Power DNS service:

 service pdns restart

Congratulation’s! You have successfully installed PowerDNS. Thanks for using this tutorial for installing PowerDNS on CentOS 6 system.

You Might Also Like: How To Install PowerDNS on Ubuntu 14.04