Centos6.4安装配置LNMP

页面导航:首页 > 操作系统 > LINUX > Centos6.4安装配置LNMP

Centos6.4安装配置LNMP

来源: 作者: 时间:2016-01-14 17:21 【

配置环境:L:Centos 2 6 32-358 el6 x86_64N:Nginx 1 7M:Mysql5 7 3P:PHP5 5 11NGINX一键脚本: ! bin bash Author:Byrd Version:1 0 Site:www t4x org Contact:root t4x org Compile

配置环境:
L:Centos 2.6.32-358.el6.x86_64
N:Nginx 1.7
M:Mysql5.7.3
P:5.5.11
NGINX一键脚本

#!/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 www
yum install pcre* openssl* openssl-devel gcc 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 $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

Mysql一键安装:

#!/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 "
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 mysql
yum install pcre* openssl* openssl-devel gcc gcc-c++ cmake libaio* library* ncurses-* -y
cd $DownMysqlTools
if [ ! -f $Version.tar.gz ];then
wget $MysqlUrl
tar zxf $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 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 &&
make && make install
RETVAL1=$?
elif [ -f $Version.tar.gz ];then
tar zxf $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 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=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一键脚本:

#!/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
LibiconvUrl=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 gcc-c++ wget libxml* libtool* libxslt* -y
cd $SoftTool
if [ ! -f $LibicoVern.tar.gz ];then
wget $LibiconvUrl || exit 1 && echo "$LibicoVern Download Error,Please try again"
tar zxf $LibicoVern.tar.gz
cd $LibicoVern
./configure --prefix=/usr/local/libiconv
make && make install
RETVAL1=$?
elif [ -f $LibicoVern.tar.gz ];then
tar zxf $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 $libmcryptVen.tar.gz ];then
wget $libmcryptUrl || exit 1 && echo "$libmcryptVen.tar.gz Download Error,Please try again"
tar zxf $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.a
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.8
ln -s /usr/local/lib64/libmhash.a /usr/lib64/libmhash.a
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 $libmcryptVen.tar.gz ];then
tar zxf $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.a
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.8
ln -s /usr/local/lib64/libmhash.a /usr/lib64/libmhash.a
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
mhashUrl=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 $mhashDev.tar.gz
cd $mhashDev
./configure
make && make install
RETVAL3=$?
else
tar zxf $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
PhpVen=php-5.5.11
if [ ! -f $PhpVen.tar.gz ];then
wget $PhpUrl
tar zxf $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 $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参数设置:

./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 --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=bywww --with-fpm-group=bywww --enable-ftp --disable-fileinfo --with-pdo-mysql

基于Centos6.4 X64、PHP5.5.11、NGINX1.7、MYSQL5.7.3

Tags:

文章评论

最 近 更 新
热 点 排 行
Js与CSS工具
代码转换工具

<