2012年(4)
分类:
2012-08-29 17:52:35
原文地址:linux运维自动化安装web环境 作者:houtian150
最近 老大 让起web
好记性不如烂笔头 没啥技术含量
PXE 安装 操作系统 开发包 和 库都安装上 省得以后 编译费劲
系统环境 cetos5.5-32bit-i686
FTP 是VSFTP 软件包 没有的自己 去下载 修改下FTP 目录就可以执行了 别在 留言问这傻子问题 我是自己的FTP 不公开
里面包含了nginx rein jdk jdbc 等 动态网站 需要的组件
下面是脚本
#!/bin/bash
rpm -qa |grep httpd |xargs rpm -e --nodeps
rpm -qa |grep mysql |xargs rpm -e --nodeps
rpm -qa |grep php |xargs rpm -e --nodeps
rpm -qa |grep jdk |xargs rpm -e --nodeps
sleep 5
chkconfig --level 35 iptables off
service iptables stop
sed -i 's/SELINUX=enforcing/SELINUX=disable/' /etc/selinux/config
ntpdate pool.ntp.org
hwclock -w
mkdir /opt/tar
mkdir /opt/src
cd /opt/tar
mkdir /usr/local/jdk
wget ftp://192.168.0.250/src/tar/jdk-6u29-linux-i586.rpm
wget ftp://192.168.0.250/src/postsrc/mysql-5.1.40.tar.gz
wget ftp://192.168.0.250/src/postsrc/php-5.2.6.tar.gz
wget ftp://192.168.0.250/src/tar/nginx-0.8.52.tar.gz
wget ftp://192.168.0.250/src/tar/pcre-8.10.tar.gz
wget ftp://192.168.0.250/src/tar/openssl-0.9.8l.tar.gz
wget ftp://192.168.0.250/src/tar/zlib-1.2.3.tar.bz2
wget ftp://192.168.0.250/src/tar/php-5.2.6-fpm-0.5.8.diff.gz
wget ftp://192.168.0.250/src/tar/php-fpm.confbak
wget ftp://192.168.0.250/src/tar/nginx.confbak
wget ftp://192.168.0.250/src/tar/resin-pro-3.1.10.tar.gz
wget ftp://192.168.0.250/src/tar/mysql-connector-java-5.0.8.tar.gz
rpm -ihv --prefix /usr/local/jdk jdk-6u29-linux-i586.rpm
tar -zxf mysql-connector-java-5.0.8.tar.gz -C /opt/src/
tar -zxf resin-pro-3.1.10.tar.gz -C /opt/src
tar -zxf pcre-8.10.tar.gz -C /opt/src
tar -zxf openssl-0.9.8l.tar.gz -C /opt/src
tar -jxf zlib-1.2.3.tar.bz2 -C /opt/src
tar -zxf mysql-5.1.40.tar.gz -C /opt/src
tar -zxf php-5.2.6.tar.gz -C /opt/src
tar -zxf nginx-0.8.52.tar.gz -C /opt/src
gzip -cd php-5.2.6-fpm-0.5.8.diff.gz | patch -d /opt/src/php-5.2.6/ -p1
sleep 1
#install mysql
cd /opt/src/mysql-5.1.40
groupadd mysql
useradd -g mysql mysql
./configure --prefix=/usr/local/mysql --enable-thread-safe-client --enable-local-infile --with-charset=gbk --with-extra-charsets=all --with-
low-memory
make
make install
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
cd /usr/local/mysql
chown -R mysql:mysql .
bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql var
bin/mysqld_safe --user=mysql &
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
ldconfig
PATH=$PATH:/usr/local/mysql/bin
export PATH
#install nginx
cd /opt/src/nginx-0.8.52
useradd www
groupadd www
usermod -g www www
./configure --prefix=/usr/local/nginx --with-http_realip_module --with-http_sub_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-pcre=/opt/src/pcre-8.10 --with-openssl=/opt/src/openssl-0.9.8l --with-zlib=/opt/src/zlib-1.2.3
make
make install
sed -i 's/nobody/www/' /usr/local/nginx/conf/nginx.conf
/usr/local/nginx/sbin/nginx
#install php
cd /opt/src/php-5.2.6
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --enable-fastcgi --enable-fpm
make
make install
cp php.ini-dist /usr/local/php/etc/php.ini
cd
cd /usr/local/php/etc
cp php-fpm.conf `date +%F`php-fpm.conf
cat /opt/tar/php-fpm.confbak > /usr/local/php/etc/php-fpm.conf
cd /usr/local/nginx/conf
cp nginx.conf `date +%F`nginx.conf
cat /opt/tar/nginx.confbak > /usr/local/nginx/conf/nginx.conf
echo "/usr/local/php/sbin/php-fpm start" >> /etc/rc.sysinit
echo "" > /usr/local/nginx/html/index.php
/usr/local/php/sbin/php-fpm restart
/usr/local/nginx/sbin/nginx -s reopen
#install jdk
sleep 1
cd /opt/tar
#add env
echo "export JAVA_HOME=/usr/local/jdk/jdk1.6.0_29 " >> /etc/profile
echo "export RESIN_HOME=/usr/local/resin" >> /etc/profile
echo "export PATH=\$JAVA_HOME/bin:\$PATH:\$RESIN_HOME/bin" >> /etc/profile
echo "export CLASSPATH=:\$JAVA_HOME/lib:\$JAVA_HOME/jre/lib:\$RESIN_HOME/lib:/usr/local/nginx/html " >> /etc/profile
source /etc/profile
java -version
#install resin
cd /opt/src/resin-pro-3.1.10/
./configure --prefix=/usr/local/resin --with-java-home=/usr/local/jdk/jdk1.6.0_29
make
make install
#install jdbc
cd /opt/tar
echo "CLASSPATH=:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/htmlconverter.jar:\$RESIN_HOME/lib:/usr/java/jdbc/mysql-connector-java-5.0.8-bin.jar" >> /etc/profile
mkdir -p /usr/java/
cp -fr /opt/src/mysql-connector-java-5.0.8 /usr/java/
cd /usr/java
ln -s mysql-connector-java-5.0.8/ jdbc
source /etc/profile
echo check port status
/etc/init.d/mysql restart
netstat -tunalp |grep 3306
java -jar /usr/local/resin/lib/resin/jar restart
netstat -tunalp |grep 8080
/usr/local/nginx/sbin/nginx -s reopen
netstat -tunalp |grep 80
netstat -tunalp |grep 6600
/usr/local/php/sbin/php-fpm restart
netstat -tunalp |grep 9000
echo test page
firefox &
#url 栏分别输入
#
#
#下一个文章里有 整合nginx resin
# 即可打开resin 欢迎页面