设为首页 收藏本站
查看: 937|回复: 0

Centos6.4 安装配置LNMP

[复制链接]

尚未签到

发表于 2015-11-16 10:18:45 | 显示全部楼层 |阅读模式
配置环境:
L:Centos 2.6.32-358.el6.x86_64
N:Nginx 1.7
M:Mysql5.7.3
P:PHP5.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
fiMysql一键安装:
#!/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 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."
fiPHP一键脚本:
#!/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."
fiPHP参数设置:
./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
         版权声明:本文为博主原创文章,未经博主允许不得转载。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-139804-1-1.html 上篇帖子: wamp 中配置域名的虚拟主机 下篇帖子: Centos6.4 安装配置LNMP
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表