Centmin Mod – A Shell Script To Automatically Deploy LEMP Stack In CentOS

About LEMP Stack

LEMP is a combination of the operating system and open-source software stack. LEMP is acronym of Linux, Nginx(engine-x) HTTP Server, MySQL/MariaDB database, and PHP/Perl/Python. Compared to LAMP stack (Apache, MySQL/MariaDB, perl/php/python), LEMP is light weight, fast, and able to handle much higher load using the same set of hardware. Don’t get me wrong. I won’t say LEMP is better than LAMP stack. It is purely depends on what you want to deploy on your web server.

In this tutorial, let us see to how to setup LEMP stack using CentMin Mod, a shell menu based NGINX installer for CentOS servers.

About Centmin Mod

For those who don’t know, Centmin Mod is a shell menu based auto-installer script for LEMP stack. The shell based menu allows Nginx and PHP version management, upgrading or downgrading Nginx and PHP or setting up Nginx vhosts. At present, Centmin Mod supports CentOS 5.x and 6.x versions only. The testing for CentOS 7.x version is going on.

Centmin Mod script will install the following softwares automatically.

  • Nginx 1.7.12 (https / SPDY SSL + ngx_pagespeed support) ;
  • PHP 5.4.41 (php-fpm) with support for PHP 5.3/5.4/5.5/5.6 ;
  • MariaDB 5.5.43 ;
  • PHP opcode cache: Zend OpCache 7.0.4, APC Cache 3.13, Xcache 3.1.0 ;
  • Memcached Server 1.4.20 and Memcache 3.0.8 PHP Extension ;
  • Libmemcached 1.0.18 and Memcached 2.2.0 PHP Extension (Centmin Mod v1.2.3-eva2000.01+) ;
  • Multi-threaded compression: pigz, pbzip2, lbzip2, plzip, p7zip (optional) ;
  • CSF Firewall.

Centmin Mod Installation

In this tutorial, let us see how to deploy LEMP stack in CentOS 6.6 64bit version using Centmin Mod script.

First of all, update your system

yum update -y

And, Install the following prerequisites too.

yum install bc wget unzip yum-plugin-fastestmirror -y

We can install Centmin Mod in three different methods.

Method 1:

This is the traditional method. Just download the script archive, extract it and run the script using the following command and select menu option 1.

Download latest version of Centmin Mod:

cd /usr/local/src
wget http://centminmod.com/download/centmin-v1.2.3-eva2000.07.zip

Note: DO NOT download to /tmp and run centmin.sh from /tmp as Centmin Mod removes the ability to execute scripts from /tmp as a security precaution. Also the downloaded contents must NOT be deleted or removed as subsequent runs of centmin.sh to use menu options require certain files and scripts in place.

Extract the downloaded zip file using command:

unzip centmin-v1.2.3-eva2000.07.zip

Go to the centmin directory:

cd centmin-v1.2.3mod/

Set execute permissions to the centmin.sh script with command:

chmod +x centmin.sh

Finally, run the script to deploy LEMP stack:

./centmin.sh

You will see the following shell menu based installer. Enter ‘1’ to start install Centmin.

----------------------------
Configure sshd_config
----------------------------
Reloading sshd:                                            [  OK  ]
--------------------------------------------------------
Centmin Mod 1.2.3-eva2000.07 - http://centminmod.com
--------------------------------------------------------
                   Centmin Mod Menu                   
--------------------------------------------------------
1).  Centmin Install
2).  Add Nginx vhost domain
3).  NSD setup domain name DNS
4).  Nginx Upgrade / Downgrade
5).  PHP Upgrade / Downgrade
6).  XCache Re-install
7).  APC Cache Re-install
8).  XCache Install
9).  APC Cache Install
10). Memcached Server Re-install
11). MariaDB 5.2, 5.5, 10 Upgrade Sub-Menu
12). Zend OpCache Install/Re-install
13). Install ioping.sh vbtechsupport.com/1239/
14). SELinux disable
15). Install/Re-install ImageMagick PHP Extension
16). Change SSHD Port Number
17). Multi-thread compression: pigz,pbzip2,lbzip2,p7zip etc
18). Suhosin PHP Extension install
19). Install FFMPEG and FFMPEG PHP Extension
20). NSD Re-install
21). Update - Nginx + PHP-FPM + Siege
22). Exit
--------------------------------------------------------
Enter option [ 1 - 22 ] 1

The Centmin Mod will disable SELinux to reduce the complexity during installation.

---------------------------------------------------------------
SELINUX linux detected
---------------------------------------------------------------
disabling SELINUX...
will require a server reboot before running initial install
SELINUX disabled, please reboot server and rerun install

Reboot your server now.

reboot

After logging in to the Server, go to the Centmin Mod folder, and run the script again.

cd centmin-v1.2.3mod/
./centmin.sh

Now, select the first option from the menu to continue installing centmin..

Method 2:

Second method, from unattended CLI command line via SSH commandfrom within download zip files extracted directory:

./centmin.sh install

Method 3:

Third method, from one liner CLI install via SSH command below which basically invokes the ./centmin.sh install method via curl:

curl -sL http://centminmod.com/installer.sh | bash

The last two CLI command line methods are great for 100% unattended Centmin Mod installs .

In this tutorial, I used the third method, and it’s worked well as expected.

After running the script, the following screen will appear. Sit back and grab a cup of coffee. Centmin Mod script will automatically add the necessary repositories and install LEMP stack. This will take few minutes depending upon your Internet connection and server configuration.

root@server:~-centmin-v1.2.3mod_001

root@server:~-centmin-v1.2.3mod_002

That’s it. LEMP stack has been successfully deployed now.

Finally, you may get the output like below.

*************************************************
* Centmin Mod install completed....
*************************************************

*************************************************
*  Setup memcached_*.php admin page ...
*************************************************

Setup Memcached Server Admin Login Details for /usr/local/nginx/html/memcache_26636.php
current memcached username: memcacheuser
current memcached password: memcachepass
*************************************************
Memcached Server Admin Login: /usr/local/nginx/html/memcache_26636.php
new memcached username: memadmin810f8efcf2
new memcached password: decc4a2cd82cad64f458ccfc
*************************************************
*************************************************
* memcache_26636.php admin page installed
*************************************************

*************************************************
* MariaDB Security Setup
*************************************************

-------------------------------------------------------
MySQL root user password set
MySQL root user added to /root/.my.cnf
-------------------------------------------------------
MySQL root password: npxV05nrsiRebzqM
-------------------------------------------------------
*************************************************
* MariaDB Security Setup Completed
*************************************************

--------------------------------------------------------
Please bookmark:
--------------------------------------------------------
###############################################################
* Getting Started Guide - http://centminmod.com/getstarted.html
* Find the latest Centmin Mod version - http://centminmod.com
* Centmin Mod FAQ - http://centminmod.com/faq.html
* Change Log - http://centminmod.com/changelog.html 
* Google+ Page latest news http://centminmod.com/gpage
* Community Forums https://community.centminmod.com (signup)
###############################################################
# Cheap VPS Hosting at Digitalocean 
# https://www.digitalocean.com/?refcode=c1cb367108e8
###############################################################

ccache stats:
cache directory                     /home/.ccache
cache hit (direct)                   778
cache hit (preprocessed)             306
cache miss                          3435
called for link                      235
called for preprocessing             244
compile failed                        55
preprocessor error                    62
bad compiler arguments                54
unsupported source language           78
autoconf compile/link                612
unsupported compiler option           14
no input file                        170
files in cache                      7169
cache size                         208.4 Mbytes
max cache size                       2.0 Gbytes

Total YUM Time: 1728.033043453 seconds
Total Centmin Mod Install Time: 5182.295676887 seconds

Please note down the MySQL and Memcached login and password details. You may need them later.

From now on you can add virtual hosts, upgrade PHP, MariaDB etc.

Let us check if Nginx is installed correctly. Open the Web browser and navigate to http://ip-address/. You should see the nginx test page.

Test Page for the Nginx HTTP Server - Mozilla Firefox_001

To view the nginx version, run:

nginx -v

Sample output:

nginx version: nginx/1.7.12

Check php version:

php -v

Sample output:

PHP 5.4.41 (cli) (built: May 19 2015 10:12:54) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

Check mysql version:

mysql -v

Sample output:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 5.5.43-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Reading history-file /root/.mysql_history
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Congratulations! LEMP stack is ready to use.

For detailed guide about Centmin Mod, check the getting started with Centmin Mod page.

Updating to latest stable version

Centmin Mod .07 stable over time may get bug fixes or minor updates. So to grab the latest code at least, it’s basically the same as Method 1 instructions above minus the need to run initial install if you are on an existing Centmin Mod .07 stable based server environment and needing to remove the old zip and extracted folder first.

Go to the directory where you downloaded the centmin script and delete it.

cd /usr/local/src
rm -rf centmin*

Then, download the most recent version using command:

wget http://centminmod.com/download/centmin-v1.2.3-eva2000.07.zip

Extract the downloaded zip archive:

unzip centmin-v1.2.3-eva2000.07.zip

Change to the extracted directory:

cd centmin-v1.2.3mod

Finally run the following command to upgrade it.

chmod +x centmin.sh

That’s it. We have successfully deployed LEMP stack using Centmin Mod.

You might want to check other NGINX auto-installer scripts for CentOS.

I don’t like scripts, I want to setup LEMP server step by step myself. How I can do that?

No worries, It is not that difficult!

Refer the following links to setup LEMP stacks manually yourself.

For CentOS:

For Debian/Ubuntu:

For SUSE/openSUSE:

Cheers!!

Reference: