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

[经验分享] 安装apache+gd2(jpeg,png等)+mysql

[复制链接]

尚未签到

发表于 2018-11-27 09:07:46 | 显示全部楼层 |阅读模式
  #!/bin/sh
#this is a script about *nix installing apache,php with gd2.write by sery(sery@163.com),in 2009-12-03

#define some variables
http_prefix=/usr/local/apache2
php_prefix=/usr/local/php

#need root install
is_root=`id |awk ‘{print $1}’|awk -F’[=(]‘ ‘{print $2}’`
if [ $is_root != 0 ]
   then
   echo “please use root install this program!!!”
   exit 1
fi

#Os is ?
Os_is=`uname`

if [ "$Os_is" = "FreeBSD" ]
then

  ## install apache
  if [ ! -d "$http_prefix" ]
    then
       tar zxvf httpd-2.2.14.tar.gz
       cd httpd-2.2.14
       ./configure –prefix=$http_prefix –enable-so –enable-write –with-mpm=worker
       make
       make install
       cd ..
       if [ ! -f "$http_prefix/htdocs/test.php" ]
           then
              cp test.php $http_prefix/htdocs
       fi
       rm -rf httpd-2.2.14
       echo “apache install is ok!”
       sleep 2
  fi

  #install mysql client
  is_inst_mysql=`find /usr/local/bin -name mysql | wc -l`
  if [ "$is_inst_mysql" = 0 ]
     then
         tar zxvf mysql-5.1.41.tar.gz
         cd mysql-5.1.41
         ./configure –without-server –with-extra-charsets=gbk,gb2312,utf8 –enable-thread-safe-client
         make
         make install
         cd ..
         echo “/usr/local/lib”>>/etc/ld.so.conf
         ldconfig
         rm -rf mysql-5.1.41
         echo “mysql client install ok!”
         sleep 2
  fi

  #install gd2
  if [ ! -d /usr/local/gd2 ]
  then
      tar zxvf gd-2.0.35.tar.gz
      cd gd-2.0.35
      ./configure –prefix=/usr/local/gd2
      make
      make install
      cd ..
      rm -rf gd-2.0.35
      echo “gd2 install is ok!”
      sleep 2
  fi

  #install php.apache must be installed in /usr/local/apache2
  if [ ! -d /usr/local/php ]
  then
      tar zxvf php-5.2.11.tar.gz
      cd php-5.2.11
      ./configure –prefix=$php_prefix –with-gd=/usr/local/gd2 –with-apxs2=$http_prefix/bin/apxs –enable-mbregex –enable-bcmath
–with-mysql –with-zlib-dir –enable-mbstring=all –with-freetype-dir –with-pdo-mysql
      make
      make install
      cp php.ini-dist $php_prefix/lib/php.ini
      cd ..
      rm -rf php-5.2.11
      echo “php with gd2 install is ok!”
      sleep 2
      fi

  # setting apache configuration file
  sed -f httpd.sed $http_prefix/conf/httpd.conf>$http_prefix/conf/httpd.conf.temp
  cd $http_prefix/conf
  mv httpd.conf httpd.conf.old
  cat httpd.conf.temp>httpd.conf
  $http_prefix/bin/apachectl -t
  cd
  echo “It is very ok!”

elif [ "$Os_is" = "Linux" ]
  then
  echo “this linux”
  
  ## install apache
  if [ ! -d "$http_prefix" ]
    then
       tar zxvf httpd-2.2.14.tar.gz
       cd httpd-2.2.14
       ./configure –prefix=$http_prefix –enable-so –enable-write –with-mpm=worker
       make
       make install
       cd ..
       if [ ! -f "$http_prefix/htdocs/test.php" ]
           then
              cp test.php $http_prefix/htdocs
       fi
       rm -rf httpd-2.2.14
       echo “apache install is ok!”
       sleep 2
  fi

  #install mysql client
  is_inst_mysql=`find /usr/local/bin -name mysql | wc -l`
  if [ "$is_inst_mysql" = 0 ]
     then
         tar zxvf mysql-5.1.41.tar.gz
         cd mysql-5.1.41
         ./configure –without-server –with-extra-charsets=gbk,gb2312,utf8 –enable-thread-safe-client
         make
         make install
         cd ..
         echo “/usr/local/lib”>>/etc/ld.so.conf
         ldconfig
         rm -rf mysql-5.1.41
         echo “mysql client install ok!”
         sleep 2
  fi

  #install freetype
  if [ ! -d /usr/local/freetype ]
     then
         tar zxvf freetype-2.3.10.tar.gz
         cd freetype-2.3.10
         ./configure –prefix=/usr/local/freetype
         make
         make install
         cd ..
         rm -rf freetype-2.3.10
         echo “freetype install is ok!”
         sleep 2
    fi

  #install jpeg
  if [ ! -d /usr/local/jpeg ]
     then
        tar zxvf jpegsrc.v7.tar.gz
        cd jpeg-7
        ./configure –prefix=/usr/local/jpeg
        make
        make install
        cd ..
        rm -rf jpeg-7
        echo “gpeg install is ok!”
  fi

  #install libpng
  if [ ! -d /usr/local/libpng ]
     then
        tar zxvf libpng-1.2.41.tar.gz
        cd libpng-1.2.41
        ./configure –prefix=/usr/local/libpng
        make
        make install
        cd ..
        rm -rf libpng-1.2.41
        echo “libpng install is ok!”
        sleep 5
  fi

  #link header file
  if [ ! -f /usr/include/pngconf.h ]
     then
        ln -s /usr/local/libpng/include/pngconf.h /usr/include
  fi

  if [ ! -f /usr/include/png.h ]
     then
        ln -s /usr/local/libpng/include/png.h /usr/include
  fi

  #install gd2
  if [ ! -d /usr/local/gd2 ]
     then
        tar zxvf gd-2.0.35.tar.gz
        cd gd-2.0.35
        ./configure –prefix=/usr/local/gd2 –with-freetype=/usr/local/freetype –with-png=/usr/local/libpng –with-jpeg=/usr/local/
jpeg
        make
        make install
        cd ..
        rm -rf gd-2.0.35
        echo “gd2 install is ok!”
        sleep 2
  fi

  #install php.apache must be installed in /usr/local/apache2
  if [ ! -d /usr/local/php ]
  then
      tar zxvf php-5.2.11.tar.gz
      cd php-5.2.11
      ./configure –prefix=$php_prefix –with-gd=/usr/local/gd2 –with-apxs2=$http_prefix/bin/apxs –enable-mbregex –enable-bcmath
–with-mysql –with-zlib-dir –enable-mbstring=all –with-pdo-mysql –with-freetype=/usr/local/freetype
      make
      make install
      cp php.ini-dist $php_prefix/lib/php.ini
      cd ..
      rm -rf php-5.2.11
      echo “php with gd2 install is ok!”
      sleep 2
      fi

  # setting apache configuration file
    sed -f httpd.sed $http_prefix/conf/httpd.conf>$http_prefix/conf/httpd.conf.temp
    cd $http_prefix/conf
    mv httpd.conf httpd.conf.old
    cat httpd.conf.temp>httpd.conf
    $http_prefix/bin/apachectl -t
    cd
    echo “It is very ok!”

else
echo “this is other os,please modify the script”
exit 1

fi

文件 httpd.sed内容:

/application\/x-compress .Z/a\
\    AddType application/x-httpd-php .php

说明:
1、除mysql客户端而外,其他的安装路径皆为 /usr/local(如/usr/local/apache2)
2、所有的版本皆为当前最稳定版
3、自动生成apache配置文件的php环境,不需要再手动添加 AddType …x-hhtpd-php .php   这样的行。
4、自动生成php测试脚本
修订:新增系统判断,安装gd2相关工具

使用的都是当前最新稳定版本

包下载处 http://221.202.126.2/apmg/apmg_install.tar.gz

下载后,tar zxvf apmg_install.tar.gz ; cd apmg_install; ./setup.sh 自动完成安装,时间大概10多分钟




运维网声明 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-640104-1-1.html 上篇帖子: Apache2 httpd.conf 配置详解(一) 下篇帖子: Apache+Tomcat负载均衡(一机多实例)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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