Chinaunix首页 | 论坛 | 博客
  • 博客访问: 74503
  • 博文数量: 32
  • 博客积分: 2510
  • 博客等级: 少校
  • 技术积分: 510
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-09 09:12
文章分类

全部博文(32)

文章存档

2011年(1)

2008年(31)

我的朋友
最近访客

分类: LINUX

2008-10-18 10:36:50

在编写脚本之前首先要感谢Linux群里的CU-Thatday兄弟给的一些建议,和公司的奇创哥哥给的一些帮助,把脚本发到下面 软件版本 是apache 2.2.9 php5.2.6 MYSQL5.0.6吧集体的望了. 软件部分不强调了.自己可以按照叫上的把软件下到一个soft的文件夹里 把安装脚本setup.sh也放在这里 用tar -czvf soft.tar.gz打包,然后setup文件是一个引导安装的 要和soft.tar.gz文件放在同一文件夹下,然后运行setup

setup脚本部分

#!/bin/bash
#
#rpm -e gnome-user-share-0.10-6.el5.i386
#rpm -e httpd-2.2.3-6.el5.centos.1
tar -zxvf soft.tar.gz
cd soft
chmod +x setup.sh
sh setup.sh

setup.sh脚本部分

#!/bin/bash
#
#apache2.2.9+mysql5+php5.2.6

echo -e "Now, please set your apache2 install path..."
echo -n "please enter you apache2 install path:"  
read httpd_path

##### user input apache setup path #####

echo -e "Now, please set your mysql5 install path..."
echo -n "please enter you mysql5 install path:"  
read mysql_path

##### user input apache setup path #####

echo -e "Now, please set your gd2 install path..."
echo -n "please enter you mysql5 install path:"  
read gd_path

##### user input apache setup path #####

echo -e "Now, please set your php5 install path..."
echo -n "please enter you gd2 install path:"  
read php_path

##### user input apache setup path #####

groupadd mysql
useradd -g mysql mysql

##### add mysql group and add mysql user #####

tar -zxvf httpd-2.2.9.tar.gz
cd httpd-2.2.9
./configure --prefix="$httpd_path" --with-ssl --enable-ssl --enable-so --enable-rewrite --disable-cgid --disable-cgi
make
make install
cp "$httpd_path/bin/apachectl" /etc/init.d/httpd
chmod 755 /etc/init.d/httpd
chkconfig --add httpd
chkconfig httpd on

cat<"$httpd_path/htdocs"/index.php
phpinfo();
?>
END_OF_FILE

##### setup apache2 ######

cd ..
tar -zxvf mysql-5.0.51b.tar.gz
cd mysql-5.0.51b
./configure --prefix="$mysql_path" --with-comment=Source --with-server-suffix=-enterprise-gpl --with-mysql-user=mysql --without-debug --with-socket-path="$mysql_path/var/mysql.sock" --with-big-tables --with-charset=gbk --with-collation=gbk_chinese_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-innodb --without-ndb-debug --without-isam --enable-local-infile --with-readline --with-raid
make
make install
cd "$mysql_path"
chown -R mysql .
chgrp -R mysql .
bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql var
cp share/mysql/my-medium.cnf /etc/my.cnf
cp share/mysql/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 3 mysqld on

#### MYSQL install over modify password for root #####

cd /root/soft
tar -zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix="$gd_path"
make
make install

#### setup gd2 ###

cd ..
tar -zxvf php-5.2.6.tar.gz
cd php-5.2.6
./configure --prefix="$php_path" --with-apxs2="$httpd_path/bin/apxs" --with-zlib-dir --with-bz2 --with-libxml-dir --with-gd="$gd_path" --enable-gd-native-ttf --enable-gd-jis-conv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-ttf --enable-mbstring --with-mysql="$mysql_path" --with-config-file-path=/etc --with-iconv --disable-ipv6 --enable-static --enable-zend-multibyte --enable-inline-optimization --enable-zend-multibyte --enable-sockets --enable-soap --with-gettext --enable-ftp
make
make install

##### install php over ####

sed 's/^short_open_tag = Off$/short_open_tag = On/g' php.ini-recommended > /etc/php.ini

##### modify php.ini-recommended and rewiter to /etc/php.ini support Discuz bbs #####

sed 's/DirectoryIndex index.html/DirectoryIndex index.php default.php index.html/' "$httpd_path/conf/httpd.conf" > /tmp/step1.txt
sed 's/\(AddType application\/x-gzip .gz .tgz\)$/\1\n    AddType application\/x-httpd-php .php/' /tmp/step1.txt > /tmp/step2.txt
cp /tmp/step2.txt "$httpd_path/conf/httpd.conf"
rm -f /tmp/step1.txt /tmp/step2.txt

####configure httpd.conf support php #####

service httpd start

HTTPD_PROCESS_COUNT="`netstat -tnl | grep :80 | wc -l`"

if [ $HTTPD_PROCESS_COUNT -gt 0 ]
then
   echo httpd is running
else
   echo httpd is NOT running
fi

##### start httpd service and test #####

service mysqld start

MYSQL_PROCESS_COUNT="` ps -ef | grep "$mysql_path/libexec/mysqld" | grep -v grep | wc -l `"
if [ $MYSQL_PROCESS_COUNT -gt 0 ]
then
   echo mysqld is running
else
   echo mysqld is NOT running
fi
##### start mysqld services and test #####

安装说明

LAMP软件包
包含

引导安装脚本: setup \\在执行前请先用chmod +x setup 加个执行权限
软件包:       soft.tar.gz \\里面包含了 tar.gz的安装包 和一个 安装脚本setup.sh

安装步骤:

操作系统安装要求:
   
   在安装操作系统REDHAT或者Centos时,需要图形界面的请只要选择GNOME桌面 其他的KDE server serverGUI 群集 负载什么的都别选择了 语言选择个 英文的。在定制的时候 服务器里你要选择一个 服务器配置工具 里的service的 记得编辑器要都选择 不知道少哪个 GCC的一定要 不然没办法编译。装好 如果是文本界面的 可以用rpm -qa httpd检查一下 系统是否为了支持某个应用把rpm包方式 系统自带的HTTPD装上了。如果装了就用rpm -e httpd卸载。 GNOME界面的一定要先用rpm -qa httpd检查一下 估计是跟顶存在系统自带的httpd 要卸载时 先卸载rpm -e gnome-user-share-0.10-6.el5.i386这个,再卸载 rpm -e httpd-2.2.3-6.el5.centos.1软件版本因为操作系统版本不同请注意。(针对GNOME界面的朋友,在setup的脚本里也写了自动卸载的,请根据自己的实际更改要卸载的软件的版本,在setup里这两行是注释掉的,如需要请去掉注释,也可以直接手工的运行两条卸载命令)

软件安装

1. 先把两个文件同时放到/root 或者其他目录
2. 用chmod +x setup 给setup引导安装脚本一个 可执行权限
3. ./setup 进行安装 安装过程请注意
4. 在前4步 是输入要安装的软件到的路径
5. 安装过程中会把index.php文件 生成到 apache根目录下的htdocs文件夹里,主要是方便测试
   也可以手工的把DocmentRoot的路径指向其他位置,CP index.php到你新建立的文件夹里去,
    注意 编辑了httpd.conf后 要用service httpd restart重起apache 让更改后的生效
6. 安装完毕后 会提示一个 httd is running 和mysql is running
7. 请手工的更改mysql的root用户密码 有两种方式
   1. 可以把mysql的安装目录 加到 $PATH里
   2. 直接在命令行里先cd到mysql的安装目录后,再用bin/mysqladmin -u root password 密码
      测试登陆 用bin/mysql -u root -p 然后更改过的密码 登陆OK 就OK了
8. 如果开启了iptables防火墙 请把防火墙里的80端口开放 3306如果不需要外部服务器连接你的MYSQL
   就不用开了。
9. 设置防火墙 界面的可以在 系统--管理--安全级别与防火墙里设置
              文本界面 可以用 iptables -I INPUT -p tcp --dport 80 -j ACCEPT来开启80端口
              文本界面输入命令 开启后别忘了用 sh /etc/init.d/iptables save 保存防火墙配置

基本就OK了
有问题可联系:QQ:85908819 或者E-mail:mypop3@126.com

阅读(1010) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~