条件:Centos6.6      
 事先将急需的源码包打包放在lamp.tar.gz中,并解压到/root下

条件:Centos六.6      
 事先将索要的源码包打包放在lamp.tar.gz中,并解压到/root下

搭建lamp的脚本,搭建lamp脚本

环境:Centos六.陆      
 事先将索要的源码包打包放在lamp.tar.gz中,并解压到/root下

[[email protected] ~]# cat /etc/centos-release 
CentOS release 6.6 (Final)
[[email protected] ~]# uname -a
Linux zengqingfu 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

[[email protected]澳门金沙国际,
~]# ls
anaconda-ks.cfg lamp.sh phpMyAdmin-4.2.5-all-languages.tar.gz 模板
avg_score.awk lamp.tar.gz pxe_kickstart.sh 视频
cmake-2.8.6.tar.gz libmcrypt-2.5.8.tar.gz
rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 图片
history.txt lines sturecord.txt 文档
httpd-2.2.17.tar.gz mcrypt-2.6.8.tar.gz test 下载
input.txt mhash-0.9.9.9.tar.gz var_of_shell.sh 音乐
install.log mysql-5.5.22.tar.gz
ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz 桌面
install.log.syslog php-5.3.28.tar.gz 公共的

履行步骤:每一步执行之后的出口进程简单了

[[email protected] ~]# ./lamp.sh y   加载光盘搭建本地yum仓库(可选的,已经搭建好yum仓库的可以不执行,直接到下一步)

[[email protected] ~]# ./lamp.sh a    安装Apache web服务

[[email protected] ~]# ./lamp.sh m     安装mysql

[[email protected] ~]# ./lamp.sh p     编译安装PHP


[[email protected] ~]# ./lamp.sh P(大写的)      再次安装PHP,并修改httpd.conf以支持PHP解析


[[email protected] ~]# ./lamp.sh o          测试PHP能否成功连接MySQL,http网页能否解析PHP

下边看完整代码:

  1 [[email protected] ~]# cat lamp.sh 
  2 #!/bin/bash
  3 #Filename: lamp.sh
  4 #Author: Zeng Qingfu
  5 #####
  6 if [ $# -ne 1 ];then
  7     echo '''
  8         Usage:input one option at a time;order to install lamp:first y,second a,third m,fourth p,fifth P,sixth o;
  9         Options:y[install yum and stop iptables,selinux];a[install httpd];m[install mysql];p[install php];o[djust httpd.conf,test,install phpMyAdmin];
 10     '''
 11         exit 1
 12 elif [ $# -eq 1 ];then
 13     if [ $1 != "a" -a $1 != "m" -a $1 != "p" -a $1 != "o" -a $1 != "y" -a $1 != "P" -o $1 == "h" ];then
 14          echo '''
 15              Usage:input one option at a time;order to install lamp:first y,second a,third m,fourth p,fifth o;
 16              Options:y[install yum and stop iptables,selinux];a[install httpd];m[install mysql];p[install php];o[djust httpd.conf,test,install phpMyAdmin];
 17          '''
 18         exit 1
 19     fi
 20 fi
 21 
 22 case $1 in
 23 
 24 y)
 25 ######stop  iptables and off selinux  and set yum repository################
 26 service iptables stop
 27 chkconfig iptables off
 28 setenforce 0
 29 sed -i '7 s/enforcing/disabled/' /etc/selinux/config
 30 umount /dev/cdrom
 31 mkdir -p /media/cdrom
 32 mount /dev/cdrom /media/cdrom
 33 cd /etc/yum.r*
 34 mkdir a
 35 mv C* a/
 36 /bin/cp a/*M* ./
 37 sed -i '20 s/0/1/' C*
 38 rpm --import /media/cdrom/*K*
 39 yum -y clean all
 40 yum makecache
 41 ;;
 42 #############################################################################
 43 
 44 a)
 45 echo "installing httpd"
 46 ##---------------install httpd------------------
 47     IP=$(hostname -I | awk '{print $1}')
 48     echo "$IP www.zengqingfu.com" >> /etc/hosts
 49     tar xf httpd-2.2.17.tar.gz -C /usr/src/
 50     rpm -qa make gcc gcc-c++
 51     if  [ $? -eq 0 ];then 
 52         cd /usr/src/httpd-2.2.17/
 53         ./configure --prefix=/usr/local/httpd  --enable-so --enable-rewrite --enable-charset-lite --enable-cgi &&make&&make install  &> /dev/null
 54     else
 55         yum -y install make gcc gcc-c++   &> /dev/null
 56         ./configure --prefix=/usr/local/httpd  --enable-so --enable-rewrite --enable-charset-lite --enable-cgi &&make&&make install  &> /dev/null
 57     fi
 58     ln -s /usr/local/httpd/bin/*  /usr/local/bin/
 59     /bin/cp /usr/local/httpd/bin/apachectl  /etc/init.d/httpd
 60     chmod +x /etc/init.d/httpd
 61     sed -i '1a#chkconfig: 35 85 21\n#description: Startup script for the Apache HTTP Server' /etc/init.d/httpd
 62     sed -n '1,3p' /etc/init.d/httpd
 63     chkconfig --add httpd
 64     chkconfig --list httpd
 65     cd  /usr/local/httpd/conf/
 66     /bin/cp httpd.conf httpd.conf.origin
 67     ROW=$(awk '/#ServerName/{print NR,$0}' httpd.conf | awk '{print $1}')
 68     sed -i "$ROW s/#//;s/example/zengqingfu/" httpd.conf
 69     apachectl -t
 70     [ $? -eq 0 ] && /etc/init.d/httpd start
 71     cat /usr/local/httpd/htdocs/index.html
 72 ;;
 73 
 74 m)
 75 echo "installing mysql"
 76 #########-------------------install mysql-------------------
 77     cd /root
 78     rpm -q mysql-server mysql
 79     rpm -e mysql --nodeps
 80     rpm -e mysql-server --nodeps
 81     rpm -q ncurses-devel
 82     [ $? -ne 0 ] && yum -y install ncurses-devel
 83     cd /root
 84     tar -xf cmake-2.8.6.tar.gz -C /usr/src/  
 85     cd /usr/src/cmake-2.8.6/
 86     ./configure && gmake && gmake install    &> /dev/null
 87     groupadd mysql
 88     useradd -M -s /sbin/nologin -g mysql mysql
 89     cd /root
 90     tar xf mysql-5.5.22.tar.gz -C /usr/src/
 91     cd /usr/src/mysql-5.5.22/
 92     cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci  -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc  && make && make install    &> /dev/null
 93     chown -R mysql:mysql /usr/local/mysql/
 94     cat support-files/my-medium.cnf > /etc/my.cnf
 95     /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/  --datadir=/usr/local/mysql/data/  --user=mysql        &> /dev/null
 96     echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
 97     source /etc/profile
 98     /bin/cp support-files/mysql.server /etc/init.d/mysqld
 99     chmod +x /etc/init.d/mysqld
100     chkconfig --add mysqld
101     /etc/init.d/mysqld start
102     netstat -anpt | grep mysqld
103     mysqladmin -uroot password "123456"
104     mysqladmin -uroot -p123456 password "zengqingfu";history -c
105 ;;
106 
107 p)
108 echo "installing php"
109 #####---------------------install php----------------------
110     rpm -q php && rpm -e php --nodeps
111     rpm -q php-cli && rpm -e php-cli --nodeps
112     rpm -q php-ldap && rpm -e php-ldap --nodeps
113     rpm -q php-common && rpm -e php-common -nodeps
114     rpm -q php-mysql  && rpm -e php-mysql --nodeps
115     rpm -q zlib-devel libxml2-devel  
116     if [ $? -ne 0 ];then
117         yum -y install zlib-devel libxml2-devel    
118     fi
119     cd /root
120     rpm -q libmcrypt || tar xf libmcrypt-2.5.8.tar.gz -C /usr/src/
121     cd /usr/src/libmcrypt-2.5.8/
122     ./configure &&make &&make install &> /dev/null
123     ln -s /usr/local/lib/libmcrypt* /usr/lib
124     cd /root
125     rpm -q mhash ||  tar xf mhash-0.9.9.9.tar.gz -C /usr/src/
126     cd /usr/src/mhash-0.9.9.9/
127     ./configure &&make&&make install  &> /dev/null
128     ln -s /usr/local/lib/libmhash.* /usr/lib/
129     cd /root
130     rpm -q mcrypt || tar xf mcrypt-2.6.8.tar.gz -C /usr/src/
131     cd /usr/src/mcrypt-2.6.8/
132     export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
133     ./configure &&make &&make install    &> /dev/null
134     cd /root
135     tar xf php-5.3.28.tar.gz -C /usr/src/
136     cd /usr/src/php-5.3.28/
137     ./configure --prefix=/usr/local/php5  --with-mcrypt  --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql/ --with-config-file-path=/usr/local/php5 --enable-mbstring && make && make install    &> /dev/null
138     /bin/cp -f php.ini-development /usr/local/php5/php.ini
139     cd /root
140     ROW=$(awk '/^short_open_tag/{print NR,$0}' /usr/local/php5/php.ini | awk '{print $1}') 
141     sed -i "$ROW s/Off/On/" /usr/local/php5/php.ini
142     ROW=$(awk '/default_charset/{print NR,$0}' /usr/local/php5/php.ini | awk '{if(NR==1)print $1}')
143     sed -i "$ROW s/;//;s/iso-8859-1/utf-8/" /usr/local/php5/php.ini 
144     cd /root
145     tar xf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src/
146     cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/
147     cd php-5.3.x/
148     /bin/cp ZendGuardLoader.so /usr/local/php5/lib/php/
149     echo -e "zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so\nzend_loader.enable=1" >> /usr/local/php5/php.ini
150     tail -2 /usr/local/php5/php.ini
151 
152 echo "adjust httpd.conf,test,install phpMyAdmin"
153 #############--------------------adjust httpd.conf---------------
154 ROW=$(awk '/LoadModule php5_module/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{print $1}')
155 sed -i "$ROW a AddType application/x-httpd-php .php" /usr/local/httpd/conf/httpd.conf
156 sed -n "$(($ROW+1)) p" /usr/local/httpd/conf/httpd.conf
157 ROW=$(awk '/DirectoryIndex/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{if(NR==2)print $1}')
158 sed -i "$ROW s/$/ index.php/" /usr/local/httpd/conf/httpd.conf
159 sed -n "$ROW p" /usr/local/httpd/conf/httpd.conf
160 httpd -t
161 [ $? -eq 0 ] && /etc/init.d/httpd restart
162 
163 ;;
164 
165 P)
166   cd /usr/src/php-5.3.28/
167   make install
168   /bin/cp -f php.ini-development /usr/local/php5/php.ini
169   cd /root
170   ROW=$(awk '/^short_open_tag/{print NR,$0}' /usr/local/php5/php.ini | awk '{print $1}') 
171   sed -i "$ROW s/Off/On/" /usr/local/php5/php.ini
172   ROW=$(awk '/default_charset/{print NR,$0}' /usr/local/php5/php.ini | awk '{if(NR==1)print $1}')
173   sed -i "$ROW s/;//;s/iso-8859-1/utf-8/" /usr/local/php5/php.ini 
174   cd /root
175   tar xf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src/
176   cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/
177   cd php-5.3.x/
178   /bin/cp ZendGuardLoader.so /usr/local/php5/lib/php/
179   echo -e "zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so\nzend_loader.enable=1" >> /usr/local/php5/php.ini
180   tail -2 /usr/local/php5/php.ini
181 
182 ROW=$(awk '/LoadModule php5_module/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{print $1}')
183 sed -i "$ROW a AddType application/x-httpd-php .php" /usr/local/httpd/conf/httpd.conf
184 sed -n "$(($ROW+1)) p" /usr/local/httpd/conf/httpd.conf
185 ROW=$(awk '/DirectoryIndex/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{if(NR==2)print $1}')
186 sed -i "$ROW s/$/ index.php/" /usr/local/httpd/conf/httpd.conf
187 sed -n "$ROW p" /usr/local/httpd/conf/httpd.conf
188 httpd -t
189 [ $? -eq 0 ] && /etc/init.d/httpd restart
190 service httpd restart
191 ;;
192 
193 o)
194 ###########----------------------test---------------
195 cd /usr/local/httpd/htdocs/
196 echo -e "<?php\nphpinfo();\n?>" > test.php
197 echo -e "<?php\n\$link=mysql_connect('localhost','root','zengqingfu');\nif(\$link) echo 'Successfully connected mysql';\nmysql_close();\n?>" > test1.php 
198 ##############------install phpMyAdmin----------------
199 cd /root
200 tar xf phpMyAdmin-4.2.5-all-languages.tar.gz
201 mv phpMyAdmin-4.2.5-all-languages /usr/local/httpd/htdocs/phpMyAdmin
202 cd /usr/local/httpd/htdocs/phpMyAdmin/
203 /bin/cp config.sample.inc.php config.inc.php
204 
205 service httpd start
206 ;;
207 esac

 

环境:Centos6.6事先将索要的源码包打包放在lamp.tar.gz中,并解压到/root下
[[email protected]
~]# cat /etc/centos- release…

centos七.三基于源码编写翻译安装LAMP实现wordpress搭建

软件条件:

apr-1.6.2.tar.gz

apr-util-1.6.0.tar.gz

httpd-2.4.27.tar.bz2

php-7.1.10.tar.xz

mariadb-10.2.8-linux-x86_64.tar.gz

wordpress-4.8.1-zh_CN.tar.gz

一、源码编写翻译安装Httpd二.四

(一)安装包组和包

yum groupinstall “development tools”

yum installopenssl-devel expat-devel pcre-devel

(2)解压包

tar xvf apr-1.6.2.tar.gz

tar xvf apr-util-1.6.0.tar.gz

tar xvf httpd-2.4.27.tar.bz2

(3)编写翻译安装:

cp -r apr-1.6.2 httpd-2.4.27/srclib/apr

cp -r apr-util-1.6.0 httpd-2.4.27/srclib/apr-util

cd httpd-2.4.27/

./configure –prefix=/app/httpd24 –sysconfdir=/etc/httpd24 –enable-so
–enable-ssl –enable-rewrite –with-zlib –with-pcre
–with-included-apr –enable-modules=most –enable-mpms-shared=all
–with-mpm=prefork

make -j 四 && make install 用四核编译并安装

(4)修改PATH路径

vim /etc/profile.d/lamp.sh

PATH=/app/httpd24/bin/:$PATH

./etc/profile.d/lamp.sh 生效修改

echo $PATH 查看是还是不是见效

(5)运行服务

apachectl 运转服务

ss -tnl 查看80端口是不是打开

【澳门金沙国际】叁依照源码编写翻译安装LAMP完毕wordpress搭建。二、 贰进制安装mariadb

(一)解压到稳定目录/usr/local/

tar xvf mariadb-10.2.8-linux-x86_64.tar.gz -C /usr/local/

(二)成立1个软连接,恐怕将mariadb-十.二.八-linux-x八6_6四目录名修改为mysql,必须是mysql

cd /usr/local

ln -s mariadb-10.2.8-linux-x86_64/ mysql

(三)成立用户mysql

useradd -r -m -d /app/mysqldb -s /sbin/nologin mysql

(4)生成数据库

cd mysql/

scripts/mysql_install_db –datadir=/app/mysqldb –user=mysql

(5)修改配置文件

mkdir /etc/mysql

cp support-files/my-large.cnf/etc/mysql/my.cnf

vim /etc/mysql/my.cnf 添加底下三行

[mysqld]

datadir = /app/mysqldb 数据库地方

innodb_file_per_table = ON 规定三个数据库表一个文件夹

skip_name_resolve = ON 跳过名字解析

(5)添加服务

cp support-files/mysql.server /etc/init.d/mysqld

chkconfig –add mysqld 添加劳务

chkconfig –list 查看是或不是丰裕成功

(六)制造日志

mkdir /var/log/mariadb

chown mysql /var/log/mariadb/

service mysqld start

(7)修改PATH路径

vi /etc/profile.d/lamp.sh

PATH=/app/httpd24/bin/:/usr/local/mysql/bin/:$PATH

./etc/profile.d/lamp.sh

mysql_secure_installation 运维安全脚本

(八)创造数据库

mysql -uroot -pcentos

create datebase wpdb;

grant all on wpdb.* to
[email protected]’192.168.191.%’
identified by ‘centos’;

grant all on wpdb.* to
[email protected]’127.%’
identified by ‘centos’;

grant all on wpdb.* to
[email protected]’localhost’
identified by ‘centos’;

三、源码编写翻译安装Php

(1)安装正视包

yum install libxml2-devel bzip2-devel libmcrypt-devel(epel)

(2)解压

tar xvf php-7.1.10.tar.xz

(3)编译,安装

cd php-7.1.10/

./configure \

–prefix=/app/php \

–enable-mysqlnd \

–with-mysqli=mysqlnd \

–with-openssl \

–with-pdo-mysql=mysqlnd \

–enable-mbstring \

–with-freetype-dir \

–with-jpeg-dir \

–with-png-dir \

–with-zlib \

–with-libxml-dir=/usr \

–enable-xml \

–enable-sockets \

–with-apxs2=/app/httpd24/bin/apxs \

–with-mcrypt \

–with-config-file-path=/etc \

–with-config-file-scan-dir=/etc/php.d \

–enable-maintainer-zts \

–disable-fileinfo

make -j 4 && make install

(四)修改配置文件

cp php.ini-production /etc/php.ini

vim /etc/httpd24/httpd.conf

在文书尾部加两行

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

修改上边行

<IfModule dir_module>

DirectoryIndex index.php index.html

</IfModule>

(5) 重启服务

apachectl stop

apachectl

4 、测试php和mariadb连接

vim /app/httpd24/htdocs/index.php

<html><body><h1>LAMP</h1></body></html>````<?php````$mysqli``=newmysqli(``"localhost"``,``"root"``,``"centos"``);````if``(mysqli_connect_errno()){````echo``"连接数据库失败!"``;````$mysqli``=null;````exit``;````}````echo``"连接数据库成功!"``;````$mysqli``->close();````phpinfo();``?>

澳门金沙国际 1

5、配置wordpress

(1) 解压

tar xvf wordpress-4.8.1-zh_CN.tar.gz -C /app/httpd24/htdocs

(2)cd /app/httpd24/htdocs

mv wordpress/ blog/

留神:假如想要访问
/app/httpd24/htdocs

(3)修改配置文件

cd /app/httpd24/htdocs/blog/

cp wp-config-sample.php wp-config.php

vim wp-config.php

define(``'DB_NAME'``,``'wpdb'``);````/**MySQL数据库用户名*/``define(``'DB_USER'``,``'wpuser'``);````/**MySQL数据库密码*/``define(``'DB_PASSWORD'``,``'centos'``);````/**MySQL主机*/``define(``'DB_HOST'``,``'localhost'``);

6、登录测试

填写博客音讯

澳门金沙国际 2

软件条件: apr-1.陆.贰.tar.gz apr-util-一.6.0.tar.gz
httpd-2.4.27.tar.bz2 …

[root@zengqingfu ~]# cat /etc/centos-release 
CentOS release 6.6 (Final)
[root@zengqingfu ~]# uname -a
Linux zengqingfu 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@zengqingfu ~]# cat /etc/centos-release 
CentOS release 6.6 (Final)
[root@zengqingfu ~]# uname -a
Linux zengqingfu 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

[root@zengqingfu ~]# ls
anaconda-ks.cfg lamp.sh phpMyAdmin-4.2.5-all-languages.tar.gz 模板
avg_score.awk lamp.tar.gz pxe_kickstart.sh
视频
cmake-2.8.6.tar.gz libmcrypt-2.5.8.tar.gz
rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 图片
history.txt lines sturecord.txt 文档
httpd-2.2.17.tar.gz mcrypt-2.6.8.tar.gz test 下载
input.txt mhash-0.9.9.9.tar.gz var_of_shell.sh 音乐
install.log mysql-5.5.22.tar.gz
ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz 桌面
install.log.syslog php-5.3.28.tar.gz 公共的

[root@zengqingfu ~]# ls
anaconda-ks.cfg lamp.sh phpMyAdmin-4.2.5-all-languages.tar.gz 模板
avg_score.awk lamp.tar.gz pxe_kickstart.sh
视频
cmake-2.8.6.tar.gz libmcrypt-2.5.8.tar.gz
rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 图片
history.txt lines sturecord.txt 文档
httpd-2.2.17.tar.gz mcrypt-2.6.8.tar.gz test 下载
input.txt mhash-0.9.9.9.tar.gz var_of_shell.sh 音乐
install.log mysql-5.5.22.tar.gz
ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz 桌面
install.log.syslog php-5.3.28.tar.gz 公共的

进行步骤:每一步执行之后的输出进程大概了

施行步骤:每一步执行之后的出口进程简单了

[root@zengqingfu ~]# ./lamp.sh y   加载光盘搭建本地yum仓库(可选的,已经搭建好yum仓库的可以不执行,直接到下一步)

[root@zengqingfu ~]# ./lamp.sh a    安装Apache web服务

[root@zengqingfu ~]# ./lamp.sh m     安装mysql

[root@zengqingfu ~]# ./lamp.sh p     编译安装PHP


[root@zengqingfu ~]# ./lamp.sh P(大写的)      再次安装PHP,并修改httpd.conf以支持PHP解析


[root@zengqingfu ~]# ./lamp.sh o          测试PHP能否成功连接MySQL,http网页能否解析PHP
[root@zengqingfu ~]# ./lamp.sh y   加载光盘搭建本地yum仓库(可选的,已经搭建好yum仓库的可以不执行,直接到下一步)

[root@zengqingfu ~]# ./lamp.sh a    安装Apache web服务

[root@zengqingfu ~]# ./lamp.sh m     安装mysql

[root@zengqingfu ~]# ./lamp.sh p     编译安装PHP


[root@zengqingfu ~]# ./lamp.sh P(大写的)      再次安装PHP,并修改httpd.conf以支持PHP解析


[root@zengqingfu ~]# ./lamp.sh o          测试PHP能否成功连接MySQL,http网页能否解析PHP

上边看完整代码:下载lamp.sh

上边看完整代码:下载lamp.sh

  1 [root@zengqingfu ~]# cat lamp.sh 
  2 #!/bin/bash
  3 #Filename: lamp.sh
  4 #Author: Zeng Qingfu
  5 #####
  6 if [ $# -ne 1 ];then
  7     echo '''
  8         Usage:input one option at a time;order to install lamp:first y,second a,third m,fourth p,fifth P,sixth o;
  9         Options:y[install yum and stop iptables,selinux];a[install httpd];m[install mysql];p[install php];o[djust httpd.conf,test,install phpMyAdmin];
 10     '''
 11         exit 1
 12 elif [ $# -eq 1 ];then
 13     if [ $1 != "a" -a $1 != "m" -a $1 != "p" -a $1 != "o" -a $1 != "y" -a $1 != "P" -o $1 == "h" ];then
 14          echo '''
 15              Usage:input one option at a time;order to install lamp:first y,second a,third m,fourth p,fifth o;
 16              Options:y[install yum and stop iptables,selinux];a[install httpd];m[install mysql];p[install php];o[djust httpd.conf,test,install phpMyAdmin];
 17          '''
 18         exit 1
 19     fi
 20 fi
 21 
 22 case $1 in
 23 
 24 y)
 25 ######stop  iptables and off selinux  and set yum repository################
 26 service iptables stop
 27 chkconfig iptables off
 28 setenforce 0
 29 sed -i '7 s/enforcing/disabled/' /etc/selinux/config
 30 umount /dev/cdrom
 31 mkdir -p /media/cdrom
 32 mount /dev/cdrom /media/cdrom
 33 cd /etc/yum.r*
 34 mkdir a
 35 mv C* a/
 36 /bin/cp a/*M* ./
 37 sed -i '20 s/0/1/' C*
 38 rpm --import /media/cdrom/*K*
 39 yum -y clean all
 40 yum makecache
 41 ;;
 42 #############################################################################
 43 
 44 a)
 45 echo "installing httpd"
 46 ##---------------install httpd------------------
 47     IP=$(hostname -I | awk '{print $1}')
 48     echo "$IP www.zengqingfu.com" >> /etc/hosts
 49     tar xf httpd-2.2.17.tar.gz -C /usr/src/
 50     rpm -qa make gcc gcc-c++
 51     if  [ $? -eq 0 ];then 
 52         cd /usr/src/httpd-2.2.17/
 53         ./configure --prefix=/usr/local/httpd  --enable-so --enable-rewrite --enable-charset-lite --enable-cgi &&make&&make install  &> /dev/null
 54     else
 55         yum -y install make gcc gcc-c++   &> /dev/null
 56         ./configure --prefix=/usr/local/httpd  --enable-so --enable-rewrite --enable-charset-lite --enable-cgi &&make&&make install  &> /dev/null
 57     fi
 58     ln -s /usr/local/httpd/bin/*  /usr/local/bin/
 59     /bin/cp /usr/local/httpd/bin/apachectl  /etc/init.d/httpd
 60     chmod +x /etc/init.d/httpd
 61     sed -i '1a#chkconfig: 35 85 21\n#description: Startup script for the Apache HTTP Server' /etc/init.d/httpd
 62     sed -n '1,3p' /etc/init.d/httpd
 63     chkconfig --add httpd
 64     chkconfig --list httpd
 65     cd  /usr/local/httpd/conf/
 66     /bin/cp httpd.conf httpd.conf.origin
 67     ROW=$(awk '/#ServerName/{print NR,$0}' httpd.conf | awk '{print $1}')
 68     sed -i "$ROW s/#//;s/example/zengqingfu/" httpd.conf
 69     apachectl -t
 70     [ $? -eq 0 ] && /etc/init.d/httpd start
 71     cat /usr/local/httpd/htdocs/index.html
 72 ;;
 73 
 74 m)
 75 echo "installing mysql"
 76 #########-------------------install mysql-------------------
 77     cd /root
 78     rpm -q mysql-server mysql
 79     rpm -e mysql --nodeps
 80     rpm -e mysql-server --nodeps
 81     rpm -q ncurses-devel
 82     [ $? -ne 0 ] && yum -y install ncurses-devel
 83     cd /root
 84     tar -xf cmake-2.8.6.tar.gz -C /usr/src/  
 85     cd /usr/src/cmake-2.8.6/
 86     ./configure && gmake && gmake install    &> /dev/null
 87     groupadd mysql
 88     useradd -M -s /sbin/nologin -g mysql mysql
 89     cd /root
 90     tar xf mysql-5.5.22.tar.gz -C /usr/src/
 91     cd /usr/src/mysql-5.5.22/
 92     cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci  -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc  && make && make install    &> /dev/null
 93     chown -R mysql:mysql /usr/local/mysql/
 94     cat support-files/my-medium.cnf > /etc/my.cnf
 95     /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/  --datadir=/usr/local/mysql/data/  --user=mysql        &> /dev/null
 96     echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
 97     source /etc/profile
 98     /bin/cp support-files/mysql.server /etc/init.d/mysqld
 99     chmod +x /etc/init.d/mysqld
100     chkconfig --add mysqld
101     /etc/init.d/mysqld start
102     netstat -anpt | grep mysqld
103     mysqladmin -uroot password "123456"
104     mysqladmin -uroot -p123456 password "zengqingfu";history -c
105 ;;
106 
107 p)
108 echo "installing php"
109 #####---------------------install php----------------------
110     rpm -q php && rpm -e php --nodeps
111     rpm -q php-cli && rpm -e php-cli --nodeps
112     rpm -q php-ldap && rpm -e php-ldap --nodeps
113     rpm -q php-common && rpm -e php-common -nodeps
114     rpm -q php-mysql  && rpm -e php-mysql --nodeps
115     rpm -q zlib-devel libxml2-devel  
116     if [ $? -ne 0 ];then
117         yum -y install zlib-devel libxml2-devel    
118     fi
119     cd /root
120     rpm -q libmcrypt || tar xf libmcrypt-2.5.8.tar.gz -C /usr/src/
121     cd /usr/src/libmcrypt-2.5.8/
122     ./configure &&make &&make install &> /dev/null
123     ln -s /usr/local/lib/libmcrypt* /usr/lib
124     cd /root
125     rpm -q mhash ||  tar xf mhash-0.9.9.9.tar.gz -C /usr/src/
126     cd /usr/src/mhash-0.9.9.9/
127     ./configure &&make&&make install  &> /dev/null
128     ln -s /usr/local/lib/libmhash.* /usr/lib/
129     cd /root
130     rpm -q mcrypt || tar xf mcrypt-2.6.8.tar.gz -C /usr/src/
131     cd /usr/src/mcrypt-2.6.8/
132     export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
133     ./configure &&make &&make install    &> /dev/null
134     cd /root
135     tar xf php-5.3.28.tar.gz -C /usr/src/
136     cd /usr/src/php-5.3.28/
137     ./configure --prefix=/usr/local/php5  --with-mcrypt  --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql/ --with-config-file-path=/usr/local/php5 --enable-mbstring && make && make install    &> /dev/null
138     /bin/cp -f php.ini-development /usr/local/php5/php.ini
139     cd /root
140     ROW=$(awk '/^short_open_tag/{print NR,$0}' /usr/local/php5/php.ini | awk '{print $1}') 
141     sed -i "$ROW s/Off/On/" /usr/local/php5/php.ini
142     ROW=$(awk '/default_charset/{print NR,$0}' /usr/local/php5/php.ini | awk '{if(NR==1)print $1}')
143     sed -i "$ROW s/;//;s/iso-8859-1/utf-8/" /usr/local/php5/php.ini 
144     cd /root
145     tar xf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src/
146     cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/
147     cd php-5.3.x/
148     /bin/cp ZendGuardLoader.so /usr/local/php5/lib/php/
149     echo -e "zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so\nzend_loader.enable=1" >> /usr/local/php5/php.ini
150     tail -2 /usr/local/php5/php.ini
151 
152 echo "adjust httpd.conf,test,install phpMyAdmin"
153 #############--------------------adjust httpd.conf---------------
154 ROW=$(awk '/LoadModule php5_module/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{print $1}')
155 sed -i "$ROW a AddType application/x-httpd-php .php" /usr/local/httpd/conf/httpd.conf
156 sed -n "$(($ROW+1)) p" /usr/local/httpd/conf/httpd.conf
157 ROW=$(awk '/DirectoryIndex/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{if(NR==2)print $1}')
158 sed -i "$ROW s/$/ index.php/" /usr/local/httpd/conf/httpd.conf
159 sed -n "$ROW p" /usr/local/httpd/conf/httpd.conf
160 httpd -t
161 [ $? -eq 0 ] && /etc/init.d/httpd restart
162 
163 ;;
164 
165 P)
166   cd /usr/src/php-5.3.28/
167   make install
168   /bin/cp -f php.ini-development /usr/local/php5/php.ini
169   cd /root
170   ROW=$(awk '/^short_open_tag/{print NR,$0}' /usr/local/php5/php.ini | awk '{print $1}') 
171   sed -i "$ROW s/Off/On/" /usr/local/php5/php.ini
172   ROW=$(awk '/default_charset/{print NR,$0}' /usr/local/php5/php.ini | awk '{if(NR==1)print $1}')
173   sed -i "$ROW s/;//;s/iso-8859-1/utf-8/" /usr/local/php5/php.ini 
174   cd /root
175   tar xf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src/
176   cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/
177   cd php-5.3.x/
178   /bin/cp ZendGuardLoader.so /usr/local/php5/lib/php/
179   echo -e "zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so\nzend_loader.enable=1" >> /usr/local/php5/php.ini
180   tail -2 /usr/local/php5/php.ini
181 
182 ROW=$(awk '/LoadModule php5_module/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{print $1}')
183 sed -i "$ROW a AddType application/x-httpd-php .php" /usr/local/httpd/conf/httpd.conf
184 sed -n "$(($ROW+1)) p" /usr/local/httpd/conf/httpd.conf
185 ROW=$(awk '/DirectoryIndex/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{if(NR==2)print $1}')
186 sed -i "$ROW s/$/ index.php/" /usr/local/httpd/conf/httpd.conf
187 sed -n "$ROW p" /usr/local/httpd/conf/httpd.conf
188 httpd -t
189 [ $? -eq 0 ] && /etc/init.d/httpd restart
190 service httpd restart
191 ;;
192 
193 o)
194 ###########----------------------test---------------
195 cd /usr/local/httpd/htdocs/
196 echo -e "<?php\nphpinfo();\n?>" > test.php
197 echo -e "<?php\n\$link=mysql_connect('localhost','root','zengqingfu');\nif(\$link) echo 'Successfully connected mysql';\nmysql_close();\n?>" > test1.php 
198 ##############------install phpMyAdmin----------------
199 cd /root
200 tar xf phpMyAdmin-4.2.5-all-languages.tar.gz
201 mv phpMyAdmin-4.2.5-all-languages /usr/local/httpd/htdocs/phpMyAdmin
202 cd /usr/local/httpd/htdocs/phpMyAdmin/
203 /bin/cp config.sample.inc.php config.inc.php
204 
205 service httpd start
206 ;;
207 esac
  1 [root@zengqingfu ~]# cat lamp.sh 
  2 #!/bin/bash
  3 #Filename: lamp.sh
  4 #Author: Zeng Qingfu
  5 #####
  6 if [ $# -ne 1 ];then
  7     echo '''
  8         Usage:input one option at a time;order to install lamp:first y,second a,third m,fourth p,fifth P,sixth o;
  9         Options:y[install yum and stop iptables,selinux];a[install httpd];m[install mysql];p[install php];o[djust httpd.conf,test,install phpMyAdmin];
 10     '''
 11         exit 1
 12 elif [ $# -eq 1 ];then
 13     if [ $1 != "a" -a $1 != "m" -a $1 != "p" -a $1 != "o" -a $1 != "y" -a $1 != "P" -o $1 == "h" ];then
 14          echo '''
 15              Usage:input one option at a time;order to install lamp:first y,second a,third m,fourth p,fifth o;
 16              Options:y[install yum and stop iptables,selinux];a[install httpd];m[install mysql];p[install php];o[djust httpd.conf,test,install phpMyAdmin];
 17          '''
 18         exit 1
 19     fi
 20 fi
 21 
 22 case $1 in
 23 
 24 y)
 25 ######stop  iptables and off selinux  and set yum repository################
 26 service iptables stop
 27 chkconfig iptables off
 28 setenforce 0
 29 sed -i '7 s/enforcing/disabled/' /etc/selinux/config
 30 umount /dev/cdrom
 31 mkdir -p /media/cdrom
 32 mount /dev/cdrom /media/cdrom
 33 cd /etc/yum.r*
 34 mkdir a
 35 mv C* a/
 36 /bin/cp a/*M* ./
 37 sed -i '20 s/0/1/' C*
 38 rpm --import /media/cdrom/*K*
 39 yum -y clean all
 40 yum makecache
 41 ;;
 42 #############################################################################
 43 
 44 a)
 45 echo "installing httpd"
 46 ##---------------install httpd------------------
 47     IP=$(hostname -I | awk '{print $1}')
 48     echo "$IP www.zengqingfu.com" >> /etc/hosts
 49     tar xf httpd-2.2.17.tar.gz -C /usr/src/
 50     rpm -qa make gcc gcc-c++
 51     if  [ $? -eq 0 ];then 
 52         cd /usr/src/httpd-2.2.17/
 53         ./configure --prefix=/usr/local/httpd  --enable-so --enable-rewrite --enable-charset-lite --enable-cgi &&make&&make install  &> /dev/null
 54     else
 55         yum -y install make gcc gcc-c++   &> /dev/null
 56         ./configure --prefix=/usr/local/httpd  --enable-so --enable-rewrite --enable-charset-lite --enable-cgi &&make&&make install  &> /dev/null
 57     fi
 58     ln -s /usr/local/httpd/bin/*  /usr/local/bin/
 59     /bin/cp /usr/local/httpd/bin/apachectl  /etc/init.d/httpd
 60     chmod +x /etc/init.d/httpd
 61     sed -i '1a#chkconfig: 35 85 21\n#description: Startup script for the Apache HTTP Server' /etc/init.d/httpd
 62     sed -n '1,3p' /etc/init.d/httpd
 63     chkconfig --add httpd
 64     chkconfig --list httpd
 65     cd  /usr/local/httpd/conf/
 66     /bin/cp httpd.conf httpd.conf.origin
 67     ROW=$(awk '/#ServerName/{print NR,$0}' httpd.conf | awk '{print $1}')
 68     sed -i "$ROW s/#//;s/example/zengqingfu/" httpd.conf
 69     apachectl -t
 70     [ $? -eq 0 ] && /etc/init.d/httpd start
 71     cat /usr/local/httpd/htdocs/index.html
 72 ;;
 73 
 74 m)
 75 echo "installing mysql"
 76 #########-------------------install mysql-------------------
 77     cd /root
 78     rpm -q mysql-server mysql
 79     rpm -e mysql --nodeps
 80     rpm -e mysql-server --nodeps
 81     rpm -q ncurses-devel
 82     [ $? -ne 0 ] && yum -y install ncurses-devel
 83     cd /root
 84     tar -xf cmake-2.8.6.tar.gz -C /usr/src/  
 85     cd /usr/src/cmake-2.8.6/
 86     ./configure && gmake && gmake install    &> /dev/null
 87     groupadd mysql
 88     useradd -M -s /sbin/nologin -g mysql mysql
 89     cd /root
 90     tar xf mysql-5.5.22.tar.gz -C /usr/src/
 91     cd /usr/src/mysql-5.5.22/
 92     cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci  -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc  && make && make install    &> /dev/null
 93     chown -R mysql:mysql /usr/local/mysql/
 94     cat support-files/my-medium.cnf > /etc/my.cnf
 95     /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/  --datadir=/usr/local/mysql/data/  --user=mysql        &> /dev/null
 96     echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
 97     source /etc/profile
 98     /bin/cp support-files/mysql.server /etc/init.d/mysqld
 99     chmod +x /etc/init.d/mysqld
100     chkconfig --add mysqld
101     /etc/init.d/mysqld start
102     netstat -anpt | grep mysqld
103     mysqladmin -uroot password "123456"
104     mysqladmin -uroot -p123456 password "zengqingfu";history -c
105 ;;
106 
107 p)
108 echo "installing php"
109 #####---------------------install php----------------------
110     rpm -q php && rpm -e php --nodeps
111     rpm -q php-cli && rpm -e php-cli --nodeps
112     rpm -q php-ldap && rpm -e php-ldap --nodeps
113     rpm -q php-common && rpm -e php-common -nodeps
114     rpm -q php-mysql  && rpm -e php-mysql --nodeps
115     rpm -q zlib-devel libxml2-devel  
116     if [ $? -ne 0 ];then
117         yum -y install zlib-devel libxml2-devel    
118     fi
119     cd /root
120     rpm -q libmcrypt || tar xf libmcrypt-2.5.8.tar.gz -C /usr/src/
121     cd /usr/src/libmcrypt-2.5.8/
122     ./configure &&make &&make install &> /dev/null
123     ln -s /usr/local/lib/libmcrypt* /usr/lib
124     cd /root
125     rpm -q mhash ||  tar xf mhash-0.9.9.9.tar.gz -C /usr/src/
126     cd /usr/src/mhash-0.9.9.9/
127     ./configure &&make&&make install  &> /dev/null
128     ln -s /usr/local/lib/libmhash.* /usr/lib/
129     cd /root
130     rpm -q mcrypt || tar xf mcrypt-2.6.8.tar.gz -C /usr/src/
131     cd /usr/src/mcrypt-2.6.8/
132     export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
133     ./configure &&make &&make install    &> /dev/null
134     cd /root
135     tar xf php-5.3.28.tar.gz -C /usr/src/
136     cd /usr/src/php-5.3.28/
137     ./configure --prefix=/usr/local/php5  --with-mcrypt  --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql/ --with-config-file-path=/usr/local/php5 --enable-mbstring && make && make install    &> /dev/null
138     /bin/cp -f php.ini-development /usr/local/php5/php.ini
139     cd /root
140     ROW=$(awk '/^short_open_tag/{print NR,$0}' /usr/local/php5/php.ini | awk '{print $1}') 
141     sed -i "$ROW s/Off/On/" /usr/local/php5/php.ini
142     ROW=$(awk '/default_charset/{print NR,$0}' /usr/local/php5/php.ini | awk '{if(NR==1)print $1}')
143     sed -i "$ROW s/;//;s/iso-8859-1/utf-8/" /usr/local/php5/php.ini 
144     cd /root
145     tar xf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src/
146     cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/
147     cd php-5.3.x/
148     /bin/cp ZendGuardLoader.so /usr/local/php5/lib/php/
149     echo -e "zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so\nzend_loader.enable=1" >> /usr/local/php5/php.ini
150     tail -2 /usr/local/php5/php.ini
151 
152 echo "adjust httpd.conf,test,install phpMyAdmin"
153 #############--------------------adjust httpd.conf---------------
154 ROW=$(awk '/LoadModule php5_module/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{print $1}')
155 sed -i "$ROW a AddType application/x-httpd-php .php" /usr/local/httpd/conf/httpd.conf
156 sed -n "$(($ROW+1)) p" /usr/local/httpd/conf/httpd.conf
157 ROW=$(awk '/DirectoryIndex/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{if(NR==2)print $1}')
158 sed -i "$ROW s/$/ index.php/" /usr/local/httpd/conf/httpd.conf
159 sed -n "$ROW p" /usr/local/httpd/conf/httpd.conf
160 httpd -t
161 [ $? -eq 0 ] && /etc/init.d/httpd restart
162 
163 ;;
164 
165 P)
166   cd /usr/src/php-5.3.28/
167   make install
168   /bin/cp -f php.ini-development /usr/local/php5/php.ini
169   cd /root
170   ROW=$(awk '/^short_open_tag/{print NR,$0}' /usr/local/php5/php.ini | awk '{print $1}') 
171   sed -i "$ROW s/Off/On/" /usr/local/php5/php.ini
172   ROW=$(awk '/default_charset/{print NR,$0}' /usr/local/php5/php.ini | awk '{if(NR==1)print $1}')
173   sed -i "$ROW s/;//;s/iso-8859-1/utf-8/" /usr/local/php5/php.ini 
174   cd /root
175   tar xf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src/
176   cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/
177   cd php-5.3.x/
178   /bin/cp ZendGuardLoader.so /usr/local/php5/lib/php/
179   echo -e "zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so\nzend_loader.enable=1" >> /usr/local/php5/php.ini
180   tail -2 /usr/local/php5/php.ini
181 
182 ROW=$(awk '/LoadModule php5_module/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{print $1}')
183 sed -i "$ROW a AddType application/x-httpd-php .php" /usr/local/httpd/conf/httpd.conf
184 sed -n "$(($ROW+1)) p" /usr/local/httpd/conf/httpd.conf
185 ROW=$(awk '/DirectoryIndex/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{if(NR==2)print $1}')
186 sed -i "$ROW s/$/ index.php/" /usr/local/httpd/conf/httpd.conf
187 sed -n "$ROW p" /usr/local/httpd/conf/httpd.conf
188 httpd -t
189 [ $? -eq 0 ] && /etc/init.d/httpd restart
190 service httpd restart
191 ;;
192 
193 o)
194 ###########----------------------test---------------
195 cd /usr/local/httpd/htdocs/
196 echo -e "<?php\nphpinfo();\n?>" > test.php
197 echo -e "<?php\n\$link=mysql_connect('localhost','root','zengqingfu');\nif(\$link) echo 'Successfully connected mysql';\nmysql_close();\n?>" > test1.php 
198 ##############------install phpMyAdmin----------------
199 cd /root
200 tar xf phpMyAdmin-4.2.5-all-languages.tar.gz
201 mv phpMyAdmin-4.2.5-all-languages /usr/local/httpd/htdocs/phpMyAdmin
202 cd /usr/local/httpd/htdocs/phpMyAdmin/
203 /bin/cp config.sample.inc.php config.inc.php
204 
205 service httpd start
206 ;;
207 esac

 

 

相关文章