Enable GD library shell script on CentOS Server

Source: Internet
Author: User
Tags centos server

Enable GD library shell script on CentOS Server

The customer's production environment is centos6.5 x64 operating system. You need to deploy the php website on it and enable the GD library function. Therefore, I wrote a script to improve work efficiency.

During the installation process, the most strange thing is php. INI file. copy ini-development to the php configuration directory, and the gd library does not work. The png verification code of the php website is abnormal. I checked a lot of information on the Internet, I found a netizen IN THE csdn Forum had the same problem as me, but there was no solution

Http://bbs.csdn.net/topics/300204068

After deleting the php. ini file, it was a magical success. Please kindly advise me.

The script is a batch processing file. Because it is for your own use, there is no interaction, but I would like to share it with users who encounter the same problem.

! /Bin/bash

Install_dir =/usr/local

Apache_dir = $ install_dir/apache/

Mysql_dir = $ install_dir/mysql/

Php_dir = $ install_dir/php/

Aprutil_dir = $ install_dir/aprutil/

Freetype_dir = $ install_dir/freetype/

Apr_dir = $ install_dir/apr/

Pcre_dir = $ install_dir/pcre/

Export _dir = $ install_dir/release 6/

Gd_dir = $ install_dir/gd2.1/

Libxml2_dir = $ install_dir/libxml2

Zlib_dir = $ install_dir/zlib/

If ["$ UID"-ne 0]

Then

Printf "Error: You must be root to run this script! \ N"

Exit 1

Fi

Echo '/dev/cdrom/mnt/iso9660defaults0 0'>/etc/fstab;

Mount-

Rm-rf/etc/yum. repos. d /*

Echo-e '[dvd] \ nbaseurl = file: // mnt \ ngpgcheck = 0 \ nenabled = 1'>/etc/yum. repos. d/my. repo

Yum update

For src in gcc-c ++ gmake ncurses-devel gzip libXpm-devel libXext-deveb libXpm libXext libtool-ltdl-devel

Do

Yum-y install $ src;

Done

For file in $ PWD/* .tar.gz

Do

Tar-zxf $ file

Done

# Apache

Cd apr-1 *

./Configure -- prefix = $ apr_dir; make install;

Cd ../

Cd apr-u *

./Configure -- prefix = $ aprutil_dir -- with-apr = $ apr_dir; make install;

Cd ../

Cd pcre */

./Configure -- prefix = $ pcre_dir; make install;

Cd ../

Cd httpd -*

./Configure -- prefix = $ apache_dir -- enable-so -- with-apr-util = $ aprutil_dir -- with-pcre = $ pcre_dir-enable-rewrite; make install;

Cd ../

Cp $ apache_dir/bin/apachectl/etc/rc. d/init. d/httpd

Sed-I '1 I # chkconfig: 345 66 33 \ n # description: Apache \ n'/etc/rc. d/init. d/httpd

Chkconfig -- add httpd

Chkconfig httpd -- level 345 on

# Mysql

Cd mysql *

./Configure -- without-debug -- with-mysqld-ldflags = -- all-static -- with-client-ldflags = -- all-static -- prefix = $ mysql_dir; make install;

Groupadd mysql

Useradd mysql-g mysql

Chown-R mysql: mysql/usr/local/mysql/

$ Mysql_dir/bin/mysql_install_db -- user = mysql

Cp-pr support-files/my-medium.cnf/etc/init. d/my. cnf

Cp-pr support-files/mysql. server/etc/init. d/mysqld

Chmod 700/etc/init. d/mysqld

Chkconfig mysqld -- level 345 on

Cd ../

# Php (freetype, libpng, jpeg, gd, libxml2, php)

Mkdir-p $ cmd_dir

Mkdir-p $ export _dir/bin

Mkdir-p $ cmd_dir/lib

Mkdir-p $ export _dir/include

Mkdir-p $ cmd_dir/man

Mkdir-p $ export _dir/man1

Mkdir-p $ cmd_dir/man/man1

Cd jpeg */

Yes | cp-fr/usr/share/libtool/config. guess.

Yes | cp-fr/usr/share/libtool/config. sub.

./Configure -- prefix = $ pai_dir -- enable-shared -- enable-static;

Make;

Make install;

Cd ../

Cd zlib */

./Configure;

Sed-I's/CFLAGS =-O3-DUSE_MMAP/CFLAGS =-O3-DUSE_MMAP-fPIC/G' Makefile

Make; make install;

Cd ../

Cd libpng */

Yes | cp-fr/usr/share/libtool/config. guess.

Yes | cp-fr/usr/share/libtool/config. sub.

./Configure -- enable-shared -- enable-static;

Make;

Make install;

Cd ../

Cd freetype */

Mkdir-p/usr/local/freetype

./Configure -- prefix = $ freetype_dir;

Make;

Make install;

Cd ../

Cd libgd */

Mkdir-p/usr/local/lib/bin/

Ln-s/usr/bin/libpng-config/usr/local/lib/bin/

. /Configure -- prefix =/usr/local/gd2.1 -- with-jpeg = $ defaults _dir -- with-png =/usr/local/-- with-zlib =/usr/local/lib -- with-freetype =/usr/local/freetype/

Make;

Make install;

Cd ..

Cd libxml2 *

./Configure -- prefix = $ libxml2_dir;

Make;

Make install;

Cd ../

Cd php *

. /Configure -- prefix = $ php_dir -- with-apxs2 = $ apache_dir/bin/apxs -- with-config-file-path = $ php_dir/etc -- with-mysqli = $ mysql_dir/bin/mysql_config -- with-mysql = $ mysql_dir -- with-libxml-dir = $ libxml2_dir -- with-gd = $ gd_dir -- with-jpeg-dir = $ export _dir -- with-png-dir =/ usr/local/-- with-zlib-dir =/usr/lib -- with-freetype-dir = $ freetype_dir -- enable-ftp -- enable-soap -- enable-sockets -- enable-mbstring -- with-xpm-dir =/usr/lib64;

Make;

Make install;

Sed-I '2017 I AddType application/x-httpd-php. php. phtml \ nAddType application/x-httpd-php-source. phps '$ apache_dir/conf/httpd. conf

Sed-I's/index.html/index. php index.html/'$ apache_dir/conf/httpd. conf

Iptables-I RH-Firewall-1-INPUT 1-p tcp -- dport 80-j ACCEPT

Iptables-I RH-Firewall-1-INPUT 1-p tcp -- dport 3306-j ACCEPT

/Etc/init. d/iptables save

Download the installation package

Http://pan.baidu.com/s/1hqH2HDE

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.