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

[经验分享] 用nginx_php 自动安装LNMP第二版

[复制链接]

尚未签到

发表于 2018-11-11 09:09:04 | 显示全部楼层 |阅读模式
  本次脚本修正第一版存在的错误,并更新了软件包版本,php 增加suhosin等等,命令参数有了改变. sh nginx_php init|ins_nginx|ins_mysqlserver|ins_mysqlclient|ins_php52|ins_php52ext
  


  • #!/bin/bash
  • # author:coralzd powered by www.freebsdsystem.org
  • # written by coralzd 2010.11.05
  • # version 0.1.4 build 20110831
  • # description: nginx php mysql install shell

  • nginx_dir="/usr/local/nginx"
  • php52_dir="/usr/local/php52"
  • mysql_dir="/usr/local/mysql"

  • function init()
  • {

  • yum -y install wget gcc gcc-c++ autoconf bison flex re2c  libmhash libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

  • read -p "Now,will download nginxphp software...Y|y:"  nginxphp

  • case "$nginxphp" in

  •      Y|y)

  • echo -n "starting download nginx_php ..."
  • cat > list > /etc/profile
  • source  /etc/profile
  • done
  • ;;

  • *)

  •   echo -n "exit install script"
  •    exit 0
  • ;;

  • esac

  • groupadd www &&  useradd www -s /sbin/nologin -g www
  • groupadd mysql && useradd mysql -s /sbin/nologin -g mysql
  • echo "www and mysql user && group create!"
  • cd packages/
  • tar zxf
  • /bin/rm -rf list

  • echo -e "All of installed sucussful!"


  • }
  • function is_version()

  • {


  • if [ `uname -m` == "x86_64" ];then
  • tar zxf libunwind-0.99.tar.gz
  • tar zxvf libunwind-0.99.tar.gz
  • cd libunwind-0.99/
  • CFLAGS=-fPIC ./configure
  • make CFLAGS=-fPIC
  • make CFLAGS=-fPIC install
  • cd ../
  • else

  •         echo "your system is 32bit ,not install libunwind lib!"
  • fi


  • }

  • function ins_nginx()

  • {

  • cd packages/
  • is_version
  • tar zxf google-perftools-1.6.tar.gz
  • cd google-perftools*
  • ./configure
  • make
  • make install
  • cd ..

  • tar zxf pcre-8.10.tar.gz
  • cd pcre-*
  • ./configure
  • make
  • make install
  • cd ..
  • tar zxf nginx-1.0.1.tar.gz
  • cd nginx-1.0.1
  • ./configure --prefix=${nginx_dir} --user=www --group=www --with-http_stub_status_module

  • make && make install
  • cd ..
  • rm -rf /usr/local/nginx/conf/nginx.conf
  • echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
  • cp nginx.conf /usr/local/nginx/conf/
  • cp fcgi.conf /usr/local/nginx/conf/
  • echo "nginx installed sucussfully!"
  • }

  • function ins_mysqlserver()
  • {

  • cd packages/
  • tar zxf mysql-5.1.58.tar.gz
  • cd mysql-5.1.58
  • CHOST="x86_64-pc-linux-gnu"
  • CFLAGS="-march=nocona -O2 -pipe"
  • CXXFLAGS="${CFLAGS}"
  • ./configure --prefix=/usr/local/mysql --enable-assembler --with-server-suffix=-DZWWW --enable-thread-safe-client --enable-local-infile --enable-thread-safe-client --with-big-tables --with- --with-client-ldflags=-all-static --with-collation=utf8_general_ci --with-extra-charsets=all --with-mysqld-ldflags=-all-static --with-mysqld-ldflags=-ltcmalloc  --with-mysqld-user=mysql --with-plugins=partition,myisammrg --with-pthread --with-unix-socket-path=/tmp/mysql.sock --without-ndb-debug
  • make && make install
  • cp support-*/mysql.server /etc/init.d/mysqld
  • cp my.cnf /etc/
  • chmod 744 /etc/init.d/mysqld
  • cd /usr/local/mysql

  • chown -R mysql:mysql .
  • rm -rf sql-bench mysql-test
  • mkdir -p /data0/mysql/relaylog/
  • mkdir -p /data0/mysql/binlog/
  • chown -R mysql.mysql /data0/mysql

  • /usr/local/mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data0/mysql/data
  • echo "mysql server  5.1.58 installed successfully!"
  • }

  • function ins_mysqlclient()
  • {

  • cd packages/
  • tar zxf mysql-5.1.58.tar.gz
  • cd mysql-5.1.58
  • CHOST="x86_64-pc-linux-gnu"
  • CFLAGS="-march=nocona -O2 -pipe"
  • CXXFLAGS="${CFLAGS}"
  • ./configure "--prefix=${mysql_dir}"   "--with-mysqld-user=mysql"   "--without-debug" "--with-charset=utf8"  "--with-extra-charsets=all"  "--with-pthread" "--with-big-tables" "--enable-thread-safe-client" "--enable-assembler" "--with-readline" "--with-ssl" "--enable-local-infile"  "--without-server"

  • make && make install
  • cd /usr/local/mysql
  • chown -R mysql:mysql .
  • rm -rf sql-bench mysql-test
  • echo "mysql client  5.1.58 installed successfully!"
  • }
  • function ins_php52()
  • {
  • cd packages/
  • tar zxf libiconv-1.13.1.tar.gz
  • cd libiconv-1.13.1/
  • ./configure --prefix=/usr/local
  • make
  • make install
  • cd ../

  • tar zxf autoconf-2.13.tar.gz
  • cd autoconf-2.13
  • ./configuire --prefix=/usr
  • make && make install
  • cd ..

  • tar zxf libmcrypt-2.5.8.tar.gz
  • cd libmcrypt-2.5.8/
  • ./configure
  • make
  • make install
  • /sbin/ldconfig
  • cd libltdl/
  • ./configure --enable-ltdl-install
  • make
  • make install
  • cd ../../

  • tar zxf mhash-0.9.9.9.tar.gz
  • cd mhash-0.9.9.9/
  • ./configure
  • make
  • make install
  • cd ../

  • 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

  • tar zxf mcrypt-2.6.8.tar.gz
  • cd mcrypt-2.6.8/
  • /sbin/ldconfig
  • ./configure
  • make
  • make install
  • cd ../


  • tar zxf php-5.2.17.tar.gz
  • gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
  • cd php-5.2.17/
  • patch -p1 -i ../suhosin-patch-5.2.17-0.9.7.patch
  • ./buildconf --force
  • ./configure --prefix=${php52_dir} --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=${php52_dir}/etc  --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --enable-suhosin --enable-ftp
  • make ZEND_EXTRA_LIBS='-liconv'
  • make install
  • cd ..
  • cp php.ini /usr/local/php52/etc/
  • cp php-fpm.conf /usr/local/php52/etc/

  • echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf.d/mysql_lib.conf
  • /sbin/ldconfig
  • echo "php52 installed successfully!"
  • }

  • function ins_php52ext()

  • {
  • cd packages/

  • tar zxf memcache-2.2.5.tgz
  • cd memcache-2.2.5/
  • ${php52_dir}/bin/phpize
  • ./configure --with-php-config=${php52_dir}/bin/php-config
  • make
  • make install
  • cd ../

  • tar jxf eaccelerator-0.9.5.3.tar.bz2
  • cd eaccelerator-0.9.5.3
  • ${php52_dir}/bin/phpize
  • ./configure --enable-eaccelerator=shared --with-eaccelerator-shared-memory --with-php-config=${php52_dir}/bin/php-config
  • make
  • make install
  • cd ../

  • #tar zxf PDO_MYSQL-1.0.2.tgz
  • #cd PDO_MYSQL-1.0.2/
  • #${php52_dir}/bin/phpize
  • #./configure --with-php-config=${php52_dir}/bin/php-config --with-pdo-mysql=${mysql_dir}
  • #make
  • #make install
  • #cd ../

  • tar zxf ImageMagick.tar.gz
  • cd ImageMagick-6.5.1-2/
  • ./configure
  • make
  • make install
  • cd ../

  • tar zxf imagick-2.3.0.tgz
  • cd imagick-2.3.0/
  • ${php52_dir}/bin/phpize
  • ./configure --with-php-config=${php52_dir}/bin/php-config
  • make
  • make install
  • cd ..


  • echo "php52 extension installed successfully!"


  • }

  • case $1 in


  • init)

  •         init
  •          ;;
  • ins_mysqlserver)

  •           ins_mysqlserver

  •           ;;
  • ins_mysqlclient)
  •           ins_mysqlclient
  •           ;;
  • ins_nginx)
  •            ins_nginx
  •            ;;
  • ins_php52)
  •        ins_php52
  •            ;;
  • ins_php52ext)
  •        ins_php52ext
  •        ;;
  • *)

  •      echo "Usage:`basename $0` {init|ins_mysqlserver|ins_mysqlclient|ins_php52|ins_php52ext}"
  •          ;;
  • esac
  




运维网声明 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.iyunv.com/thread-633536-1-1.html 上篇帖子: 解决phpMyAdmin在nginx+php-fpm模式下无法使用的问题 下篇帖子: Nginx下载服务生产服务器调优
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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