搭建基于PHP的www服务器
安装MySQL
#!/bin/bash mount |grep "/dev/sr0" if [ "$?" != 0 ];then mount /dev/sr0 /media fi [ "$?" != 0 ]&& echo "fail to mount ! exit " && exit yum -y install gcc-c++ ncurses-devel perl-devel rpm -q gcc-c++ ncurses-devel perl-devel if [ "$?" != 0 ]; then echo "install error " yum -y remove gcc-c++ ncurses-devel perl-devel if [ "$?" != 0 ]; then echo "remove error " fi fi # install Cmake cmake if [ "$?" != 0 ];then cd /root/db/ tar zxf /root/db/cmake-3.1.0-rc3.tar.gz # get the directory after unzip dname=`ls -al /root/db/ |grep "^d" |grep ".*cmake.*"|awk '{print $9}'` echo "directory: "$dname if [ ! -d $dname ]; then echo "fail unzip " exit fi cd /root/db/$dname echo "enter " `pwd` ./bootstrap if [ "$?" == 0 ];then gmake if [ "$?" == 0 ]; then gmake install if [ "$?" == 0 ]; then echo "success" else echo "gmake install fail ! exit " exit fi else echo "gmake fail ! exit " fi else echo " ./bootstrap fail exit " exit fi else echo "Cmake already installed " fi # install mysql cd /root/db/ tar zxvf /root/db/mysql-5.6.20.tar.gz mysqlD=`ls -al /root/db/ |grep "^d" |grep ".*mysql.*"|awk '{print $9}'` echo "mysql directory: "$mysqlD if [ ! -d $mysqlD ]; then echo "mysql fail unzip " exit fi cd /root/db/$mysqlD cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql make && make install # configure mysql echo "PATH=$PATH:/usr/local/mysql/bin/" >> /etc/profile source /etc/profile useradd mysql if [ "$?" != 0 ]; then echo "adduser error " exit fi chown -R mysql:mysql /usr/local/mysql/ cd /usr/local/mysql/ echo "enter "`pwd` ./scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql cp support-files/mysql.server /etc/init.d/mysqld chkconfig mysqld on mv /etc/my.cnf /etc/my.cnf.bk service mysqld start
搭建www服务器以及PHP功能
#!/bin/bash mount |grep "/dev/sr0" if [ "$?" != 0 ]; then mount /dev/sr0 /media fi [ "$?" != 0 ] && echo "fail to mount ! exit " && exit # install gcc-c++ rpm -q gcc-c++ if [ "$?" != 0 ]; then yum -y install gcc-c++ fi # remove httpd rpm -q httpd if [ "$?" == 0 ]; then rpm -e httpd --nodeps fi yum -y install perl-devel freetype-devel libxml2-devel libXpm-devel zlib-devel libpng-devel [ "$?" != 0 ] && echo "perl-devel freetype-devel libxml2-devel libXpm-devel zlib-devel libpng-devel yum error ! exit " && exit # install APR(Apache Portable Runtime) tar -jxvf /root/web/apr-1.5.1.tar.bz2 APR=`ls -al /root/web/ |grep "^d" |grep ".*apr.*"|awk '{print $9}'` [ "$APR" == "" ] && echo " apr unzip error ! exit " && exit cd /root/web/$APR echo "enter " `pwd` ./configure --prefix=/usr/local/apr if [ "$?" == 0 ];then make && make install if [ "$?" == 0 ]; then echo "apr install success" else echo "apr make && make install error ! exit " exit fi else echo "apr ./configure error ! exit " exit fi # install apr-util tar -jvxf /root/web/apr-util-1.5.3.tar.bz2 APRU=`ls -al /root/web/ |grep "^d" |grep ".*apr-util*"|awk '{print $9}'` [ "$APRU" == "" ] && echo " apr-util unzip error ! exit " && exit echo "apr-util "$APRU cd /root/web/$APRU echo "enter "$APRU ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ if [ "$?" == 0 ];then make && make install if [ "$?" == 0 ]; then echo "apr-util install success" else echo "apr-util make && make install error ! exit " exit fi else echo "apr-util ./configure error ! exit " exit fi #install pcre echo "start instal pcre " echo "current directory is : " `pwd` cd /root/web/ tar -jvxf /root/web/pcre-8.35.tar.bz2 PCRE=`ls -al /root/web/ |grep "^d" |grep ".*pcre.*"|awk '{print $9}'` echo "find pcre in /root/web/" $PCRE [ "$PCRE" == "" ] && echo " pcre unzip error ! exit " && exit echo "pcre : "$PCRE cd /root/web/$PCRE echo "enter pcre: " $PCRE ./configure --prefix=/usr/local/pcre if [ "$?" == 0 ];then make && make install if [ "$?" == 0 ]; then echo "pcre install success" else echo "pcre make && make install error ! exit " exit fi else echo "pcre ./configure error ! exit " exit fi #apache install cd /root/web/ tar -jvxf /root/web/httpd-2.4.10.tar.bz2 HTTPD=`ls -al /root/web/ |grep "^d" |grep ".*httpd.*"|awk '{print $9}'` [ "$HTTPD" == "" ] && echo " httpd unzip error ! exit " && exit cd /root/web/$HTTPD ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-cgi --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/ if [ "$?" == 0 ];then make && make install if [ "$?" == 0 ]; then echo "httpd install success" else echo "httpd make && make install error ! exit " exit fi else echo "httpd ./configure error ! exit " exit fi