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

[经验分享] lnmp一键安装之

[复制链接]

尚未签到

发表于 2018-12-21 11:58:30 | 显示全部楼层 |阅读模式
  写在最前面:
1. php的版本为 php-5.4.14,脚本运行环境在centos5.9 64bit通过.
2. 为什么不写lnmp一键安装的了,而单单拆分了,我也不知道.
3. 当然,如果你有任何你解决不了的问题,随时联系我.


  


  •   #!/bin/bash
  •   #version 1.0
  •   #date    2013-05-04
  •   #author  yangcan
  •   #mail    yoncan@qq.com
  •   #user define
  •   _php_path=/usr/local/php
  •   _mysql_path=/usr/local/mysql
  •   _wwwuser=ycan
  •   _work_path=`pwd`
  •   _check_stats() {
  •   if [ $? == 0 ];then
  •   echo "*************************************" >>$_work_path/install.log
  •   echo "$1 : at $(date +'%F %T') install OK "  >>$_work_path/install.log
  •   else
  •   echo "*************************************" >>$_work_path/install.log
  •   echo "$1 : at $(date +'%F %T') install                "  >>$_work_path/install.log
  •   fi
  •   }
  •   _check_file() {
  •   ( yum grouplist|grep -B 100 "Available Groups:"|grep "Development Libraries" ) || yum groupinstall "Development Libraries"
  •   ( yum grouplist|grep -B 100 "Available Groups:"|grep "Development Tools" ) || yum groupinstall "Development Tools"
  •   yum -y install ntp wget gcc gcc-c++ autoconf automake libtool* libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel libtiff-devel libXpm-devel gettext-devel fontconfig-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
  •   [ -s gd-2.0.35.tar.gz ] ||  wget -c http://jaist.dl.sourceforge.net/project/gd2/gd-2.0.35.tar.gz
  •   [ -s libiconv-1.14.tar.gz ] || wget -c http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
  •   [ -s libmcrypt-2.5.8.tar.gz ] || wget -c  http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
  •   [ -s mcrypt-2.6.8.tar.gz ] || wget -c http://nchc.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
  •   [ -s mhash-0.9.9.9.tar.bz2 ] || wget -c http://nchc.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.bz2
  •   #[ -s imagick-3.0.1.tgz ] || wget -c http://pecl.php.net/get/imagick-3.0.1.tgz
  •   #[ -s ImageMagick-6.6.9-8.tar.gz ] || wget -c http://image_magick.veidrodis.com/image_magick/ImageMagick-6.6.9-8.tar.gz
  •   [ -s jpegsrc.v9.tar.gz  ] || wget -c http://www.imagemagick.org/download/delegates/jpegsrc.v9.tar.gz
  •   [ -s freetype-2.4.11.tar.gz ] || wget -c http://download.savannah.gnu.org/releases/freetype/freetype-2.4.11.tar.gz
  •   [ -s php-5.4.14.tar.gz ] || wget -c http://cn2.php.net/distributions/php-5.4.14.tar.gz
  •   [ -s eaccelerator-eaccelerator-42067ac.tar.gz ] || wget -c http://soft.vpser.net/web/eaccelerator/eaccelerator-eaccelerator-42067ac.tar.gz
  •   [ -s memcache-2.2.7.tgz  ] || wget -c http://pecl.php.net/get/memcache-2.2.7.tgz
  •   [ -s memcached-1.4.15.tar.gz ] || wget -c http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
  •   [ -s libevent-2.0.21-stable.tar.gz ] || wget -c https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
  •   }
  •   _install_depth() {
  •   echo > $_work_path/install.log
  •   # install libiconv
  •   cd $_work_path
  •   tar zxf libiconv-1.14.tar.gz
  •   cd libiconv-1.14
  •   ./configure
  •   make && make install
  •   _check_stats libiconv
  •   # install libmcrypt
  •   cd $_work_path
  •   tar zxf libmcrypt-2.5.8.tar.gz
  •   cd libmcrypt-2.5.8
  •   ./configure
  •   make && make install
  •   _check_stats libmcrypt
  •   /sbin/ldconfig
  •   # install libltdl
  •   cd libltdl/
  •   ./configure --enable-ltdl-install
  •   make && make install
  •   _check_stats libltdl
  •   echo "/usr/local/lib"  >/etc/ld.so.conf.d/usr_local_lib.conf
  •   /sbin/ldconfig
  •   # install mhash
  •   cd $_work_path
  •   tar jxf mhash-0.9.9.9.tar.bz2
  •   cd mhash-0.9.9.9
  •   ./configure
  •   make && make install
  •   _check_stats mhash
  •   /sbin/ldconfig
  •   # install mcrypt
  •   cd $_work_path
  •   tar zxf mcrypt-2.6.8.tar.gz
  •   cd mcrypt-2.6.8
  •   ./configure
  •   make && make install
  •   _check_stats mcrypt
  •   # install zlib
  •   cd $_work_path
  •   tar zxf zlib-1.2.7.tar.gz
  •   cd zlib-1.2.7
  •   ./configure
  •   make && make install
  •   _check_stats zlib
  •   # install freetype
  •   cd $_work_path
  •   tar zxf freetype-2.4.11.tar.gz
  •   cd freetype-2.4.11
  •   ./configure
  •   make && make install
  •   _check_stats freetype
  •   # install jpegsrv
  •   cd $_work_path
  •   tar zxf jpegsrc.v9.tar.gz
  •   cd jpeg-9/
  •   ./configure
  •   make && make install
  •   _check_stats jpegsrc.v9
  •   /sbin/ldconfig
  •   # install gd
  •   cd $_work_path
  •   tar zxf gd-2.0.35.tar.gz
  •   cd gd-2.0.35
  •   ./configure --with-libiconv-prefix --with-png --with-freetype --with-jpeg --with-xpm
  •   make && make install
  •   _check_stats gd
  •   /sbin/ldconfig
  •   }
  •   _install_php() {
  •   # 请根据自己的需要添加编译参数
  •   if grep FAIL $_work_path/install.log ;then
  •   /usr/bin/clear
  •   echo
  •   echo
  •   echo
  •   echo "****************** notice ***********************"
  •   echo "Install depend on the package failure, please check.."
  •   echo
  •   echo
  •   cat $_work_path/install.log
  •   exit 1
  •   else
  •   cd $_work_path
  •   tar -zxf php-5.4.14.tar.gz
  •   cd php-5.4.14
  •   ./configure --prefix=$_php_path \
  •   --with-config-file-path=$_php_path/etc \
  •   --with-mysql=$_mysql_path \
  •   --with-mysqli=$_mysql_path/bin/mysql_config \
  •   --with-mysql-sock=/tmp/mysql.sock \
  •   --with-pdo-mysql=$_mysql_path \
  •   --with-png-dir \
  •   --with-jpeg-dir \
  •   --with-freetype-dir \
  •   --with-gd \
  •   --enable-gd-native-ttf \
  •   --with-pcre-regex \
  •   --with-iconv \
  •   --with-mhash \
  •   --enable-xml \
  •   --enable-bcmath \
  •   --enable-shmop \
  •   --enable-sysvsem \
  •   --enable-inline-optimization \
  •   --with-curlwrappers \
  •   --enable-mbregex \
  •   --enable-fpm \
  •   --enable-mbstring \
  •   --enable-ftp \
  •   --with-openssl \
  •   --enable-pcntl \
  •   --enable-sockets \
  •   --with-xmlrpc \
  •   --with-zlib-dir \
  •   --with-zlib \
  •   --with-bz2  \
  •   --enable-zip \
  •   --enable-soap \
  •   --with-gettext \
  •   --enable-session \
  •   --with-mcrypt \
  •   --with-curl \
  •   --with-ldap \
  •   --with-ldap-sasl \
  •   --without-pear \
  •   --disable-debug
  •   [ $? == 0 ] && make ZEND_EXTRA_LIBS='-liconv'
  •   [ $? == 0 ] && make install
  •   _check_stats php-5.4.14
  •   if [ $? == 0 ];then
  •   cp php.ini-production $_php_path/etc/php.ini
  •   cp $_php_path/etc/php-fpm.conf{.default,}
  •   cp sapi/fpm/init.d.php-fpm  /etc/init.d/php-fpm
  •   chmod a+x /etc/init.d/php-fpm
  •   chkconfig --add php-fpm
  •   fi
  •   fi
  •   }
  •   _install_ext() {
  •   # install memcache
  •   cd $_work_path
  •   tar zxf memcache-2.2.7.tgz
  •   cd memcache-2.2.7
  •   $_php_path/bin/phpize
  •   ./configure --enable-memcache --with-php-config=$_php_path/bin/php-config --with-zlib-dir
  •   make && make install
  •   _check_stats memcache
  •   cp $_php_path/etc/php.ini{,.default}
  •   cat >> $_php_path/etc/php.ini  $_php_path/etc/php.ini $1 ] || useradd -r -s /sbin/nologin $_wwwuser
  •   mkdir /home/logs
  •   chown $_wwwuser:$_wwwuser /home/logs/
  •   mkdir /home/htdocs
  •   chown $_wwwuser:$_wwwuser /home/htdocs/
  •   mkdir /var/tmp/eaccelerator_cache
  •   chmod 777 /var/tmp/eaccelerator_cache
  •   # set mysql
  •   cp $_mysql_path/bin/mysqld_safe{,.default}
  •   sed -i '/^# executing mysqld_safe/a\export LD_PRELOAD=/usr/local/lib/libtcmalloc.so' $_mysql_path/bin/mysqld_safe
  •   # set php
  •   sed -i 's#\(disable_functions =\).*#\1phpinfo,passthru,exec,system,popen,chroot,escapeshellcmd,escapeshellarg,shell_exec,proc_open,proc_get_status#g' $_php_path/etc/php.ini
  •   sed -i '/^;cgi.fix_pathinfo=1/a\cgi.fix_pathinfo=0' $_php_path/etc/php.ini
  •   sed -i 's#^\(expose_php = \).*#\1Off#g' $_php_path/etc/php.ini
  •   sed -i 's#^\(short_open_tag = \).*#\1On#g' $_php_path/etc/php.ini
  •   }
  •   # install
  •   if [ `id -u` -ne 0 ];then
  •   echo "install php need root"
  •   exit 1
  •   else
  •   _check_file
  •   _install_depth
  •   _install_php
  •   _install_ext
  •   _other
  •   [ $? -eq 0 ] && echo " $(date +"%F %T")  @@@@@@@ PHP INSTALL OK.. @@@@@@ " >> $_work_path/install.log
  •   sleep 5
  •   fi
  



附件:http://down.运维网.com/data/2362786


运维网声明 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-654011-1-1.html 上篇帖子: 编写PHP高质量代码 下篇帖子: PHP源代码下载(本代码供初学者使用)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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