客户生产环境是centos6.5 x64位操作系统,需要往上面部署php网站,并开启GD库功能。为此,自己写了一个脚本,提高工作效率。
安装过程中,最为诡异的还是php.ini文件,编译完成后将php.ini-development拷到php配置目录下,gd库竟然不起作用,php网站的png验证码显示不正常,在网上查了很多资料,发现csdn论坛里有一个网友跟我出现了同样类似的问题,但是并没有解决办法
http://bbs.csdn.net/topics/300204068
把php.ini文件删除后,竟然神奇的成功了,恳请各位大神指点迷津。
脚本很原始,就是一个批处理文件。由于是自己用,所以就没有什么交互的东西,但是愿意给各位出现同样问题的网友分享一下。
!/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/
jpeg_dir=$install_dir/jpeg6/
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 -a
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 gcc-c++ gmake ncurses-devel gzip libXpm-devel libXext-deveb libXpm libXext libtool 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;make install ;
cd ../
cd apr-u*
./configure --prefix=$aprutil_dir --with-apr=$apr_dir ;make;make install ;
cd ../
cd pcre*/
./configure --prefix=$pcre_dir ; make ; make install ;
cd ../
cd httpd-*
./configure --prefix=$apache_dir --enable-so --with-apr-util=$aprutil_dir --with-pcre=$pcre_dir -enable-rewrite ;make;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 ;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 $jpeg_dir
mkdir -p $jpeg_dir/bin
mkdir -p $jpeg_dir/lib
mkdir -p $jpeg_dir/include
mkdir -p $jpeg_dir/man
mkdir -p $jpeg_dir/man1
mkdir -p $jpeg_dir/man/man1
cd jpeg*/
yes | cp -fr /usr/share/libtool/config.guess .
yes | cp -fr /usr/share/libtool/config.sub .
./configure --prefix=$jpeg_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=$jpeg_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=$jpeg_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 '378 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
安装包下载
http://pan.baidu.com/s/1hqH2HDE