客戶生產環境是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