#!/bin/bash # molezz centos shell: http://www.molezz.net/ # version: 0.2 # 2010-04-23 # # Reference: # http://www.centospub.com/ # http://www.atans.cn/post/93/ # http://www.zquan.me/article.asp?id=31 # # check root if [ $(id -u) != "0" ]; then echo "ERROR: You are not root, please use root" exit 1 fi echo "---------------------set mysql root password--------------------" mysqlrootpasswd="root" echo "please input the mysql root password: " read -p "(defalt password: root):" mysqlrootpasswd if [ "$mysqlrootpasswd" = "" ]; then mysqlrootpasswd = "root" fi echo "---------------------installation start-------------------------" # update and clear yum -y update ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime rpm -qa|grep httpd rpm -e httpd rpm -qa|grep nginx rpm -e nginx rpm -qa|grep spawn-fcgi rpm -e spawn-fcgi rpm -qa|grep php rpm -e php-mysql rpm -qa|grep mysql rpm -e mysql-server rpm -e perl-DBD-MySQL rpm -e mysql echo "--------------------------install nginx-------------------------" rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm yum -y install nginx chkconfig --level 235 nginx on service nginx start echo "--------------------------install mysql-------------------------" yum -y install mysql-server chkconfig --level 235 mysqld on echo "-----------------install php and spawn-fcgi-----------------------" yum -y install php-cgi php-mysql yum -y install spawn-fcgi echo "spawn-fcgi -C 5 -a 127.0.0.1 -p 9000 -u nginx -g nginx -f /usr/bin/php-cgi" >> /etc/rc.local # modify the nginx.conf, I hope I can write beautiful later................ sed '104,111s/#//g' /etc/nginx/nginx.conf > /etc/nginx/nginx.conf.out mv -f /etc/nginx/nginx.conf.out /etc/nginx/nginx.conf sed 's/index.html index.htm/index.html index.htm index.php/g' /etc/nginx/nginx.conf > /etc/nginx/nginx.conf.out mv -f /etc/nginx/nginx.conf.out /etc/nginx/nginx.conf sed 's:/scripts:/usr/share/nginx/html:g' /etc/nginx/nginx.conf > /etc/nginx/nginx.conf.out mv -f /etc/nginx/nginx.conf.out /etc/nginx/nginx.conf service mysqld start /usr/bin/mysqladmin -u root password $mysqlrootpasswd sed '/22 -j/{h;p;g;s/22 -j/80 -j/g}' /etc/sysconfig/iptables > /etc/sysconfig/iptables.out mv -f /etc/sysconfig/iptables.out /etc/sysconfig/iptables service iptables restart spawn-fcgi -C 5 -a 127.0.0.1 -p 9000 -u nginx -g nginx -f /usr/bin/php-cgi service nginx restart echo "" >> /usr/share/nginx/html/test.php echo "********************************************************************" echo "********************************************************************" echo "** completed! **" echo "********************************************************************" echo "** **" echo "** php info: http://127.0.0.1/test.php **" echo "** nginx config file: /etc/nginx/nginx.conf **" echo "** web dir: /usr/share/nginx/html **" echo "** mysql dir: /usr/bin **" echo "** mysql database dir: /var/lib/mysql **" echo "** php location: /usr/bin **" echo "** **" echo "********************************************************************" echo "** **" echo "** for mysql security, you should run secure setting **" echo "** /usr/bin/mysql_secure_installation **" echo "** **" echo "********************************************************************" echo "mysql root password : $mysqlrootpasswd "