标签:一键 lamp 脚本
此脚本根据网上的进行了大量的修改,在RHEL5上做了实际测试,本人亲测有效。
运行次脚本有2个注意点:
1.在根目录下新建work目录,将光盘没有的rpm包放入其中,如果没有联网,将需要的rpm包也放入其中
2.将apache的服务启动脚本httpd,放入work目录
#!/bin/sh #Copyright(c) 2010-2015 jwh5566 (419288922@qq.com) #install LAMP #Version 0.1.2 #Date 20150602 #------------add yum source------------------------ #rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm #rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm #------------install gcc------------------------ #yum install gcc-c++ gcc ncurses-devel wget openssl openssl-devel zlib-devel unzip ntp libxml2-devel -y yum groupinstall "Development Libraries" "Development Tools" #RHEL6 no need install Development Libraries #--------------time sync-------------------- #ntpdate tiger.sina.com.cn hwclock -w service iptables stop sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g‘ /etc/selinux/config setenforce 0 yum -y remove httpd php mysql-server mysql php-mysql installLog="/root/instalog.log" function checkLog(){ [ $? -eq 0 ] && echo "Successfull! " || echo "configure is error,pls check it." && [ -f $installLog ] && tail -30 $installLog && exit 1 } function msg(){ echo -n "now,Scripts is ‘$1‘ apache, this maybe take several mins, pls wait..." } function apr_err (){ echo -n "apr is configure err." } [ ! -f apr-1.5.2.tar.gz ] && wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz [ ! -f apr-util-1.5.4.tar.gz ] && wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz [ ! -f pcre-8.36.tar.gz ] && wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.36/pcre-8.36.tar.gz yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs -y tar xf apr-1.5.2.tar.gz cd apr-1.5.2 ./configure --prefix=/usr/local/apr make && make install echo "apr is finished." cd .. tar xf apr-util-1.5.4.tar.gz cd apr-util-1.5.4 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make && make install echo "apr-util is finished." cd .. tar xf pcre-8.36.tar.gz cd pcre-8.36 ./configure --prefix=/usr/local/pcre >>$installLog make && make install echo "pcre is finished." cd .. groupadd apache useradd -g apache -s /usr/sbin/nologin apache mkdir /usr/local/apache chown -R apache:apache /usr/local/apache [ ! -f httpd-2.4.12.tar.gz ] && wget http://apache.fayea.com/httpd/httpd-2.4.12.tar.gz tar xf httpd-2.4.12.tar.gz [ ! -d ./httpd-2.4.12/srclib ] && echo "flies install err " && exit \cp -rf ./apr-1.5.2 ./httpd-2.4.12/srclib/apr \cp -rf ./apr-util-1.5.4 ./httpd-2.4.12/srclib/apr-util cd httpd-2.4.12 ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewrite --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-included-apr --with-pcre=/usr/local/pcre/bin/pcre-config [ $? != 0 ] && echo "ERROR: Apache configure err" make 2>&1 [ $? != 0 ] && echo "ERROR: Apache make err" make install 2>&1 [ $? != 0 ] && echo "ERROR: Apache install err" echo ‘PidFile "/var/run/httpd.pid"‘ >>/etc/httpd/httpd.conf cd .. cp httpd /etc/init.d/httpd chmod +x /etc/init.d/httpd # \cp ./build/rpm/httpd.init /etc/init.d/httpd # chmod 755 /etc/init.d/httpd chkconfig --add httpd chkconfig --level 35 httpd on chkconfig --list httpd echo "export PATH=$PATH:/usr/local/apache/bin" > /etc/profile.d/httpd.sh sed -i ‘/#ServerName/a\ServerName localhost‘ /etc/httpd/httpd.conf chown -R apache:apache /usr/local/apache service httpd start ps -ef | grep httpd echo "=============apache install OK !!!!============" sleep 3 groupadd mysql useradd -g mysql -s /usr/sbin/nologin mysql mkdir -p /data/mysql chown -R mysql:mysql /data/mysql chmod o-rx /data/mysql [ ! -f mysql-5.6.25-linux-glibc2.5-x86_64.tar.gz ] && wget http://mysql.mirror.kangaroot.net/Downloads/MySQL-5.6/mysql-5.6.25-linux-glibc2.5-x86_64.tar.gz tar xf mysql-5.6.25-linux-glibc2.5-x86_64.tar.gz -C /usr/local cd /usr/local ln -sv mysql-5.6.25-linux-glibc2.5-x86_64 mysql cd mysql chown mysql.mysql /usr/local/mysql/* ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql >>$installLog chown -R root /usr/local/mysql/* cp support-files/mysql.server /etc/init.d/mysqld chkconfig --add mysqld chkconfig --list mysqld cp support-files/my-default.cnf /etc/my.cnf sed -i ‘/datadir/a\datadir = /data/mysql‘ /etc/my.cnf echo "export PATH=$PATH:/usr/local/mysql/bin" > /etc/profile.d/mysql.sh ln -s /usr/local/mysql/include/mysql /usr/include/mysql ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql service mysqld start ps -ef |grep mysqld echo "=============MYSQL install OK !!!!============" cd /work yum localinstall libmcrypt-2.5.7-5.el5.x86_64.rpm libmcrypt-devel-2.5.7-5.el5.x86_64.rpm mhash-0.9.2-6.el5.x86_64.rpm mhash-devel-0.9.2-6.el5.x86_64.rpm --nogpgcheck mkdir -p /usr/local/jpeg [ ! -f php-5.4.41.tar.gz ] && wget http://cn2.php.net/distributions/php-5.4.41.tar.gz tar xf php-5.4.41.tar.gz cd php-5.4.41 ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir=/usr/local/jpeg --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts >>$installLog [ $? != 0 ] && exit make make install cp ./php.ini-production /etc/php.ini sed -i ‘s#;date.timezone =#date.timezone = PRC#‘ /etc/php.ini sed -i ‘s#expose_php = On#expose_php = OFF#‘ /etc/php.ini sed -i ‘/AddType text\/html .shtml/aAddType application\/x-httpd-php .php\nAddType application/x-httpd-php-source .phps\n‘ /etc/httpd/httpd.conf sed -i ‘s/DirectoryIndex index.html/aDirectoryIndex index.php index.html/‘ /etc/httpd/httpd.conf service httpd restart ps -ef | grep httpd #----------------¨index.php------------------ cat > /usr/local/apache/htdocs/index.php << EOF <?php phpinfo(); ?> EOF echo "=============PHP install OK !!!!============" echo "=============LAMP install OK !!!!============"
打开浏览器地址,显示如下:
本文出自 “Linux is belong to you” 博客,请务必保留此出处http://jwh5566.blog.51cto.com/7394620/1658094
标签:一键 lamp 脚本
原文地址:http://jwh5566.blog.51cto.com/7394620/1658094