Centos6.4 install and configure LNMP
Configuration environment:
L: Centos 2.6.32-358. el6.x86 _ 64
N: Nginx 1.7
M: Mysql5.7.3
P: PHP5.5.11
NGINX one-click script:
#! /Bin/bash
# Author: Byrd
# Version: 1.0
# Site: www.t4x.org
# Contact: root # t4x.org
# Compile and install nginx by: byrd at: 2014-04-30
# This script for nginx1.4 nginx1.6 nginx1.7
# Define
DownTools =/byrd/tools
NginxWget = http://nginx.org/download/nginx-1.7.4.tar.gz
Openssl = http://www.openssl.org/source/openssl-1.0.1h.tar.gz
NginxVersion = nginx-1.7.4
InstallNginxDir =/byrd/service
PATH =/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin :~ /Bin
Export PATH
LANG = "en_US.UTF-8"
# Check if user is root
If [$ UID! = "0"]; then
Echo "Error: You must be root to run this script, please use root to install lnmp"
Exit 1
Fi
Clear
Echo "============================================== ========================================"
Echo "============================ Install Nginx ========== ====================================="
Echo "============================================== ========================================"
Echo "===============================www.t4x.org ========== ====================================="
Echo "============================================== ========================================"
# Create web user
Groupadd www
Useradd-s/sbin/nologin-g www
Yum install pcre * openssl-devel gcc-c ++ wget vim-y
# Create a file download directory
[! -D $ DownTools] & mkdir-p $ DownTools
[! -D $ InstallNginxDir] & mkdir $ InstallNginxDir
Cd $ InstallNginxDir
If [! -F openssl-1.0.1h.tar.gz]; then
Wget $ Openssl | exit 1 & echo "Please changes Openssl URL"
Tar zxf openssl-1.0.1h.tar.gz
Cd openssl-1.0.1h
./Config
Make
Else
Tar zxf openssl-1.0.1h.tar.gz
Cd openssl-1.0.1h
./Config
Make
Fi
RETVAL1 = $?
If [$ RETVAL1-eq 0]; then
Echo "Openssl installed successfully"
Else
Exit $ RETVAL1
Fi
Cd $ DownTools
Wget $ NginxWget
Tar zxf restart nginxversion.tar.gz
Cd $ NginxVersion
. /Configure -- user = www -- group = www -- prefix = $ InstallNginxDir/$ NginxVersion -- with-openssl = $ InstallNginxDir/openssl-1.0.1h -- with-pcre -- with-http_ssl_module -- with-http_spdy_module -- with-http_gunzip_module -- with-http_gzip_static_module -- with-http_stub_status_module -- with-ipv6 -- with-http_sub_module &&
#. /Configure -- user = www -- group = www -- prefix =/byrd/service/nginx-1.6.2 -- with-openssl =/byrd/service/openssl-1.0.1j -- with-pcre -- with-http_ssl_module -- with-http_spdy_module -- with-http_gunzip_module -- with-http_gzip_static_module -- with-http_stub_status_module -- with-http_sub_module
Make & make install
RETVAL2 = $?
If [$ RETVAL2-eq 0]; then
Echo "Nginx installed successfully"
Else
Exit $ RETVAL2
Fi
Ln-s $ InstallNginxDir/$ NginxVersion/usr/local/nginx
/Usr/local/nginx/sbin/nginx
/Bin/netstat-tunlp |/bin/grep 80
If [-s/sbin/iptables]; then
/Sbin/iptables-I INPUT-p tcp -- dport 80-j ACCEPT
/Sbin/iptables-save
Fi
One-click Mysql installation:
#! /Bin/bash
# Author: Byrd
# Version: 1.0
# Site: www.t4x.org
# Contact: root # t4x.org
# This script for Mysql 5.6.16
# Check if user is root
If [$ UID! = "0"]; then
Echo "Error: You must be root to run this script, please use root to install lnmp"
Exit 1
Fi
Clear
Echo "============================================== ========================================"
Echo "Will automatically install mysql"
Echo "============================================== ========================================"
MysqlInstall =/byrd/service
DownMysqlTools =/byrd/tools
MysqlUrl = http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.19.tar.gz
Version = mysql-5.6.19
[! -D $ DownMysqlTools] & mkdir-p $ DownMysqlTools
[! -D $ MysqlInstall] & mkdir $ MysqlInstall
Groupadd mysql
Useradd-s/sbin/nologin-g mysql
Yum install pcre * openssl-devel gcc-c ++ cmake libaio * library * ncurses-*-y
Cd $ DownMysqlTools
If [! -F implements version.tar.gz]; then
Wget $ MysqlUrl
Tar zxf implements version.tar.gz
Cd $ Version
Cmake. -DCMAKE_INSTALL_PREFIX = $ MysqlInstall/$ Version-DMYSQL_DATADIR = $ MysqlInstall/$ Version/data-DMYSQL_UNIX_ADDR = $ MysqlInstall/$ Version/tmp/mysql. sock-DMYSQL_USER = mysql-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-DENABLED_LOCAL_INFILE = ON-demand = 1-success = 1-success = 1-success = 1 &&
Make & make install
RETVAL1 = $?
Elif [-f implements version.tar.gz]; then
Tar zxf implements version.tar.gz
Cd $ Version
Cmake. -DCMAKE_INSTALL_PREFIX = $ MysqlInstall/$ Version-DMYSQL_DATADIR = $ MysqlInstall/$ Version/data-DMYSQL_UNIX_ADDR = $ MysqlInstall/$ Version/tmp/mysql. sock-DMYSQL_USER = mysql-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-DENABLED_LOCAL_INFILE = ON-demand = 1-success = 1-success = 1-success = 1 &&
Make & make install
RETVAL1 = $?
Else
Exit 1
Fi
If [$ RETVAL1-eq 0]; then
Echo "$ Version install successful"
Else
Echo "$ Version install failed ."
Fi
Ln-s $ MysqlInstall/$ Version/usr/local/mysql
/Usr/local/mysql/scripts/mysql_install_db -- basedir =/usr/local/mysql/-- datadir =/usr/local/mysql/data/-- user = mysql
/Bin/cp/usr/local/mysql/support-files/mysql. server/etc/init. d/mysqld
/Bin/mv/etc/my. cnf/etc/my. cnf. backup
/Bin/cp/usr/local/mysql/support-files/my-default.cnf/etc/my. cnf
/Etc/init. d/mysqld start
If ['netstat-tunlp | grep mysql | wc-l'-ne 0]; then
Echo "$ Version Starting successful"
Else
Echo "$ Version Starting failed ."
Fi
PHP one-click script:
#! /Bin/bash
# Author: Byrd
# Version: 1.0
# Site: www.t4x.org
# Contact: root # t4x.org
PATH =/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin :~ /Bin
Export PATH
LANG = "en_US.UTF-8"
# Check if user is root
If [$ UID! = "0"]; then
Echo "Error: You must be root to run this script, please use root to install lnmp"
Exit 1
Fi
Clear
Echo "============================================== ========================================"
Echo "Install PHP5.5.11 BY: byrd at: 2014-04-30"
Echo "============================================== ========================================"
RETVAL = 0
SoftTool =/byrd/tools
Server =/byrd/server
Libian convurl = http://ftp.gnu.org/gnu/libiconv/libiconv-1.9.2.tar.gz
LibicoVern = libiconv-1.9.2
[! -D $ SoftTool] & mkdir-p $ SoftTool
[! -D $ Server] & mkdir $ Server
Yum install zlib libjpeg freetype libpng gd curl zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel gcc-c ++ wget libxml * tool lib* libxslt * -y
Cd $ SoftTool
If [! -F then libicovern.tar.gz]; then
Wget $ LibiconvUrl | exit 1 & echo "$ LibicoVern Download Error, Please try again"
Tar zxf returns libicovern.tar.gz
Cd $ LibicoVern
./Configure -- prefix =/usr/local/libiconv
Make & make install
RETVAL1 = $?
Elif [-f then libicovern.tar.gz]; then
Tar zxf returns libicovern.tar.gz
Cd $ LibicoVern
./Configure -- prefix =/usr/local/libiconv
Make & make install
RETVAL1 = $?
Else
Exit 1
Fi
If ['echo $ RETVAL1 '-eq $ RETVAL]; then
Echo "$ LibicoVern Install Successful"
Else
Echo "$ LibicoVern Install Failured"
Exit 'echo $ retval1'
Fi
LibmcryptUrl = http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
LibmcryptVen = libmcrypt-2.5.8
Cd $ SoftTool
If [! -F implements libmcryptven.tar.gz]; then
Wget $ libmcryptUrl | exit 1 & echo "Unzip libmcryptven.tar.gz Download Error, Please try again"
Tar zxf unzip libmcryptven.tar.gz
Cd $ libmcryptVen
./Configure
Make & make install
RETVAL2 = $?
Rm-f/usr/lib/libmcrypt .*
Rm-f/usr/lib/libmhash *
Ln-s/usr/local/lib/libmcrypt. la/usr/lib/libmcrypt. la
Ln-s/usr/local/lib/libmcrypt. so/usr/lib/libmcrypt. so
Ln-s/usr/local/lib/libmcrypt. so.4/usr/lib/libmcrypt. so.4
Ln-s/usr/local/lib/libmcrypt. so.4.4.8/usr/lib/libmcrypt. so.4.4.8
Ln-s/usr/local/lib/libmhash. a/usr/lib/libmhash.
Ln-s/usr/local/lib/libmhash. la/usr/lib/libmhash. la
Ln-s/usr/local/lib/libmhash. so/usr/lib/libmhash. so
Ln-s/usr/local/lib/libmhash. so.2/usr/lib/libmhash. so.2
Ln-s/usr/local/lib/libmhash. so.2.0.1/usr/lib/libmhash. so.2.0.1
Ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
Rm-f/usr/lib64/libmcrypt .*
Rm-f/usr/lib64/libmhash *
Ln-s/usr/local/lib64/libmcrypt. la/usr/lib64/libmcrypt. la
Ln-s/usr/local/lib64/libmcrypt. so/usr/lib64/libmcrypt. so
Ln-s/usr/local/lib64/libmcrypt. so.4/usr/lib64/libmcrypt. so.4
Ln-s/usr/local/lib64/libmcrypt. so.4.4.8/usr/lib64/libmcrypt. so.4.4.4.8
Ln-s/usr/local/lib64/libmhash. a/usr/lib64/libmhash.
Ln-s/usr/local/lib64/libmhash. la/usr/lib64/libmhash. la
Ln-s/usr/local/lib64/libmhash. so/usr/lib64/libmhash. so
Ln-s/usr/local/lib64/libmhash. so.2/usr/lib64/libmhash. so.2
Ln-s/usr/local/lib64/libmhash. so.2.0.1/usr/lib64/libmhash. so.2.0.1
Ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
Ln-s/usr/local/mysql/lib/libmysqlclient. so/usr/lib64/
Ln-s/usr/local/mysql/lib/libmysqlclient. so.18/usr/lib64/libmysqlclient. so.18
Ldconfig-v
Elif [-f implements libmcryptven.tar.gz]; then
Tar zxf unzip libmcryptven.tar.gz
Cd $ libmcryptVen
./Configure
Make & make install
Rm-f/usr/lib/libmcrypt .*
Rm-f/usr/lib/libmhash *
Ln-s/usr/local/lib/libmcrypt. la/usr/lib/libmcrypt. la
Ln-s/usr/local/lib/libmcrypt. so/usr/lib/libmcrypt. so
Ln-s/usr/local/lib/libmcrypt. so.4/usr/lib/libmcrypt. so.4
Ln-s/usr/local/lib/libmcrypt. so.4.4.8/usr/lib/libmcrypt. so.4.4.8
Ln-s/usr/local/lib/libmhash. a/usr/lib/libmhash.
Ln-s/usr/local/lib/libmhash. la/usr/lib/libmhash. la
Ln-s/usr/local/lib/libmhash. so/usr/lib/libmhash. so
Ln-s/usr/local/lib/libmhash. so.2/usr/lib/libmhash. so.2
Ln-s/usr/local/lib/libmhash. so.2.0.1/usr/lib/libmhash. so.2.0.1
Ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
Rm-f/usr/lib64/libmcrypt .*
Rm-f/usr/lib64/libmhash *
Ln-s/usr/local/lib64/libmcrypt. la/usr/lib64/libmcrypt. la
Ln-s/usr/local/lib64/libmcrypt. so/usr/lib64/libmcrypt. so
Ln-s/usr/local/lib64/libmcrypt. so.4/usr/lib64/libmcrypt. so.4
Ln-s/usr/local/lib64/libmcrypt. so.4.4.8/usr/lib64/libmcrypt. so.4.4.4.8
Ln-s/usr/local/lib64/libmhash. a/usr/lib64/libmhash.
Ln-s/usr/local/lib64/libmhash. la/usr/lib64/libmhash. la
Ln-s/usr/local/lib64/libmhash. so/usr/lib64/libmhash. so
Ln-s/usr/local/lib64/libmhash. so.2/usr/lib64/libmhash. so.2
Ln-s/usr/local/lib64/libmhash. so.2.0.1/usr/lib64/libmhash. so.2.0.1
Ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
Ln-s/usr/local/mysql/lib/libmysqlclient. so/usr/lib64/
Ln-s/usr/local/mysql/lib/libmysqlclient. so.18/usr/lib64/libmysqlclient. so.18
Ldconfig-v
Else
Exit 1
Fi
If ['echo $ RETVAL2 '-eq $ RETVAL]; then
Echo "$ libmcryptVen Install Successful"
Else
Echo "$ libmcryptVen Install Failured"
Exit 'echo $ retval2'
Fi
Cd $ SoftTool
Mhash url = http://nchc.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
MhashDev = mhash-0.9.9.9
If [! -F $mhashDev.tar.gz]; then
Wget $ mhashUrl
Tar zxf running mhashdev.tar.gz
Cd $ mhashDev
./Configure
Make & make install
RETVAL3 = $?
Else
Tar zxf running mhashdev.tar.gz
Cd $ mhashDev
./Configure
Make & make install
RETVAL3 = $?
Fi
If ['echo $ retval3'-eq $ RETVAL]; then
Echo "$ mhashDev Install Successful"
Else
Echo "$ mhashDev Install Failured"
Exit 'echo $ retval3'
Fi
Cd $ SoftTool
PhpUrl = http://am1.php.net/distributions/php-5.5.11.tar.gz
PHP = php-5.5.11
If [! -F $PhpVen.tar.gz]; then
Wget $ PhpUrl
Tar zxf prepare phpven.tar.gz
Cd $ PhpVen
. /Configure -- enable-opcache -- prefix = $ Server/$ PhpVen -- with-mysql =/usr/local/mysql/-- with-mysqli -- with-iconv-dir =/usr/ local/libiconv -- with-freetype-dir -- with-jpeg-dir -- with-png-dir -- with-zlib -- with-libxml-dir =/usr -- enable-xml -- disable -rpath -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline-optimization -- with-curl -- enable-mbregex -- enable-fpm -- enable-mbstring -- with-mcrypt -- with-gd -- enable-gd-native-ttf -- with-openssl -- with-mhash -- enable-pcntl -- enable-sockets -- with-xmlrpc -- enable-zip -- enable-soap -- enable-short-tags -- enable-static -- with-xsl -- with-fpm-user = www -- with-fpm-group = www -- enable-ftp
Make & make install
RETVAL4 = $?
Else
Tar zxf prepare phpven.tar.gz
Cd $ PhpVen
. /Configure -- enable-opcache -- prefix = $ Server/$ PhpVen -- with-mysql =/usr/local/mysql/-- with-mysqli -- with-iconv-dir =/usr/ local/libiconv -- with-freetype-dir -- with-jpeg-dir -- with-png-dir -- with-zlib -- with-libxml-dir =/usr -- enable-xml -- disable -rpath -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline-optimization -- with-curl -- enable-mbregex -- enable-fpm -- enable-mbstring -- with-mcrypt -- with-gd -- enable-gd-native-ttf -- with-openssl -- with-mhash -- enable-pcntl -- enable-sockets -- with-xmlrpc -- enable-zip -- enable-soap -- enable-short-tags -- enable-static -- with-xsl -- with-fpm-user = www -- with-fpm-group = www -- enable-ftp
Make & make install
RETVAL4 = $?
Fi
If ['echo $ RETVAL4 '-eq $ RETVAL]; then
Echo "$ PhpVen Install Successful"
Else
Echo "$ PhpVen Install Failured"
Exit 'echo $ retval4'
Fi
Ln-s $ Server/$ PhpVen/usr/local/php
Cp $ SoftTool/$ PhpVen/php. ini-production/usr/local/php/lib/php. ini
Mv/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
/Usr/local/php/sbin/php-fpm-t
/Usr/local/php/sbin/php-fpm
If ['netstat-tunlp | grep php-fpm | wc-l'-ne 0]; then
Echo "$ PhpVen Starting successful"
Else
Echo "$ PhpVen Starting failed ."
Fi
PHP parameter settings:
. /Configure -- enable-opcache -- prefix =/Byrd/service/php-5.5.11 -- with-mysql =/usr/local/mysql/-- with-mysqli -- with-iconv-dir =/usr /local/libiconv -- with-freetype-dir -- with-jpeg-dir -- with-png-dir -- with-zlib -- with-libxml-dir =/usr -- enable-xml -- disable-rpath -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline-optimization -- with-curl -- enable-mbregex -- enable-fpm -- enable-mbstring --- mcrypt -- with-gd -- enable-gd-native-ttf -- with-openssl -- with-mhash -- enable-pcntl -- enable-sockets -- with-xmlrpc -- enable-zip -- enable- soap -- enable-short-tags -- enable-static -- with-xsl -- with-fpm-user = bywww -- with-fpm-group = bywww -- enable-ftp -- disable-fileinfo -- with-pdo-mysql
Based on Centos6.4 X64, PHP5.5.11, NGINX1.7, and MYSQL5.7.3