#!/bin/bash
####一、系统环境部署及调整####
####1、检查系统是否正常,检查有无系统级错误信息
tail -n100 /var/log/messages
####2、检查硬件设备是否有错误信息
dmesg
####3、检查网卡设置是否正确
ifconfig
####4、检查网络是否正常
ping
####2、检查及更新系统GCC C++等语言环境####
yum -y install ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel \
ncurses-devel openssl-devel libtool* zlib-devel libxml2-devel libjpeg-devel libpng-devel libtiff-devel \
fontconfig-devel freetype-devel libXpm-devel gettext-devel curl curl-devel pam-devel \
e2fsprogs-devel krb5-devel libidn libidn-devel
####3、定时校正服务器时钟,与时钟服务器进行时间同步####
ntpdate time.nist.gov
####添加每天定时进行时钟同步####
crontab -e
####添加以下内容####
echo "15 3 * * * /usr/sbin/ntpdate time.nist.gov > /dev/null 2>&1" >>/etc/crontab
####二、LAMP安装及配置####
####1、安装ncurses-5.6(ncurses是一种能提供基于文本终端窗口功能的动态库)####
cd /root/soft/lamp/
tar -zxvf ncurses-5.6.tar.gz
cd /root/soft/lamp/ncurses-5.6
./configure --prefix=/usr --with-shared --without-debug
make
make install
####2、MYSQL安装与配置(mysql一种开源的数据库)####
####Mysql安装####
groupadd mysql
useradd mysql -d /dev/null -g mysql -s /sbin/nologin
cd /root/soft/lamp/
tar -zxvf mysql-5.1.30.tar.gz
cd /root/soft/lamp/mysql-5.1.30
./configure --with-mysqld-user=mysql --prefix=/usr/local/mysql5 --with-charset=gbk --with-extra-charset=all --without-isam --exec-prefix=/usr/local/mysql5
make
make install
####Mysql配置####
/usr/local/mysql5/bin/mysql_install_db --user=mysql
chown -R mysql.mysql /usr/local/mysql5/
cp /usr/local/mysql5/share/mysql/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 700 /etc/rc.d/init.d/mysqld
/usr/local/mysql5/bin/mysqld_safe --user=mysql &
/etc/rc.d/init.d/mysqld start
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
ln -s /usr/local/mysql5/bin/mysql /sbin/mysql
ln -s /usr/local/mysql5/bin/mysqladmin /sbin/mysqladmin
#####配置库文件搜索路径
echo "/usr/local/mysql5/lib/mysql" >> /etc/ld.so.conf
#####添加/usr/local/mysql5/bin到环境变量PATH中
export PATH=$PATH:/usr/local/mysql5/bin
####3、安装zlib(安装lamp的必备源码)####
cd /root/soft/lamp/
tar jxvf zlib-1.2.3.tar.bz2
cd /root/soft/lamp/zlib-1.2.3
./configure
make
make install
####4、安装openssl-0.9.8g(通信加密组件)####
cd /root/soft/lamp/
tar zxvf openssl-0.9.8g.tar.gz
cd /root/soft/lamp/openssl-0.9.8g
./config shared zlib
make
make test
make install
mv /usr/bin/openssl /usr/bin/openssl.OFF
mv /usr/include/openssl /usr/include/openssl.OFF
rm -f /usr/lib/libssl.so
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
ln -sv /usr/local/ssl/lib/libssl.so.0.9.8 /usr/lib/libssl.so
#配置库文件搜索路径
echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
####5、安装BerkeleyDB(高性能的,嵌入数据库编程库)####
cd /root/soft/lamp/
tar zxvf db-4.4.20.tar.gz
cd /root/soft/lamp/db-4.4.20/build_unix
../dist/configure --prefix=/usr/local/BerkeleyDB
make && make install
ln -sv /usr/local/BerkeleyDB/include /usr/include/db4
ln -sv /usr/local/BerkeleyDB/include/db.h /usr/include/db.h
ln -sv /usr/local/BerkeleyDB/include/db_cxx.h /usr/include/db_cxx.h
echo "/usr/local/BerkeleyDB/lib" >> /etc/ld.so.conf
ldconfig
####6、安装httpd-2.2.8(WEB服务器)####
cd /root/soft/lamp/
tar jxvf httpd-2.2.13.tar.bz2
cd /root/soft/lamp/httpd-2.2.13
./configure --prefix=/usr/local/apache2 --enable-module=rewrite --enable-module=so --enable-so --enable-ssl --with-ssl=/usr/local/ssl --enable-track-vars --enable-rewrite --with-zlib --enable-mods-shared=most --enable-suexec --with-suexec-caller=daemon
make && make install
echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.local
/usr/local/apache2/bin/apachectl start
####注:在这一步时极有可能会出现下列报错,这个报错是因为本系统开启了selinux功能,我们可以进行下列操作,关闭该功能,再启动时就没有问题:
####httpd: Syntax error on line 75 of /httpd/apache/conf/httpd.conf: Cannot load /httpd/apache/modules/mod_deflate.so into server:/httpd/apache/modules/mod_deflate.so: cannot restore segment prot after reloc:Permission denied
vi /etc/selinux/config
找到SELINUX=“XXXXX”项把后面的参数修改为“disable”
####7、安装libPNG(是多种应用程序使用的解析PNG图象格式的库)####
cd /root/soft/lamp/
tar zxvf libpng-1.2.14.tar.gz
cd /root/soft/lamp/libpng-1.2.14
cp scripts/makefile.linux ./makefile
./configure --prefix=/usr/local/libpng
make && make install
####8、安装freetype(高度模块化的字体程序库)####
cd /root/soft/lamp/
tar jxvf freetype-2.3.5.tar.bz2
cd /root/soft/lamp/freetype-2.3.5
./configure
make && make install
####9、安装JPEG6####
cd /root/soft/lamp/
tar zxvf jpegsrc.v6b.tar.gz
cd /root/soft/lamp/jpeg-6b
mkdir -pv /usr/local/jpeg/{,bin,lib,include,man/man1,man1}
./configure --prefix=/usr/local/jpeg --enable-shared --enable- static
make && make install
####10、安装GD####
cd /root/soft/lamp/
tar zxvf gd-2.0.35.tar.gz
cd /root/soft/lamp/gd-2.0.35
./configure --with-png --with-freetype --with-jpeg=/usr/local/jpeg/
make && make install
####11、安装LIBXML2####
cd /root/soft/lamp/
tar zxvf libxml2-2.6.31.tar.gz
cd /root/soft/lamp/libxml2-2.6.31
./configure --prefix=/usr/local/libxml2
make && make install
cp xml2-config /usr/bin
####12、安装libmcrypt####
cd /root/soft/lamp/
tar zxvf libmcrypt-2.5.7.tar.gz
cd /root/soft/lamp/libmcrypt-2.5.7
./configure
make && make install
####13、安装PHP5.2.5####
cd /root/soft/lamp/
tar jxvf php-5.2.5.tar.bz2
cd /root/soft/lamp/php-5.2.5
./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql5 --with-apxs2=/usr/local/apache2/bin/apxs --enable-ftp --with-mysqli=/usr/local/mysql5/bin/mysql_config
make && make install
####配置apache与php####
cp /root/soft/lamp/php-5.2.5/php.ini-dist /usr/local/apache2/conf/php.ini
vi /usr/local/apache2/conf/php.ini
####查找default_charset = "iso-8859-1",在这行下方添加:####
default_charset = "gbk"
vi /usr/local/apache2/conf/httpd.conf
####查找AddType application/x-gzip .tgz,在这行下方添加:####
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
####查找IfModule dir_module,在index.html前面添加:####
index.php,
####重启httpd服务####
vi /usr/local/apache2/htdocs/index.php
phpinfo();
?>
####打开IE浏览器,测试PHP功能是否正常####
####14、安装ZendOptimizer####
cd /root/soft/lamp/
tar -zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
cd /root/soft/lamp/ZendOptimizer-3.3.3-linux-glibc23-i386
./install
####安装在图形下进行,安装时注意根据提示选择就可以####
echo "LINUX+MYSQL+APACHE2+PHP5+ZEND INSTALL OK"
阅读(719) | 评论(0) | 转发(0) |