CentOS6.5自动化安装LAMP脚本

CentOS6.5自动化安装LAMP脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
#date:2014-8-31
#blog:lizhenliang.blog.51cto.com
########## function ##########
depend_pkg ()
{
    
yum 
install 
gcc gcc-c++ 
make 
cmake ncurses-devel libxml2-devel \
    
perl-devel libcurl-devel libgcrypt libgcrypt-devel libxslt \
    
libxslt-devel pcre-devel openssl-devel wget -y
}
cat 
<<END
        
1.[
install 
apache2.4]
        
2.[
install 
mysql5.5]
        
3.[
install 
php5.4]
END
read 
-p 
"Please input number : " 
NUM
case 
$NUM 
in
1)
########## Install Depend Pkg ##########
depend_pkg;
WorkDIR=
/usr/local/src
cd 
$WorkDIR
[ -f 
"apr-1.5.1.tar.gz" 
] || wget http:
//mirror
.bit.edu.cn
/apache/apr/apr-1
.5.1.
tar
.gz
[ -f 
"apr-util-1.5.3.tar.gz" 
] || wget http:
//mirror
.bit.edu.cn
/apache/apr/apr-util-1
.5.3.
tar
.gz
[ -f 
"httpd-2.4.10.tar.gz" 
] || wget http:
//mirror
.bit.edu.cn
/apache/httpd/httpd-2
.4.10.
tar
.gz
ls 

xargs 
-I 
file 
tar 
zxvf 
file 
-C $WorkDIR
cd 
apr-1.5.1
.
/configure 
--prefix=
/usr/local/apr
make 
&& 
make 
install
if 
[ $? -
eq 
0 ];
then
    
cd 
$WorkDIR
    
cd 
apr-util-1.5.3
    
.
/configure 
--prefix=
/usr/local/apr-util 
--with-apr=
/usr/local/apr
    
make 
&& 
make 
install
else
    
echo 
"------ apr make failed. ------"
    
exit 
1
fi
########## Install Apache ##########
HTTPDIR=
/usr/local/apache2
.4
if 
[ $? -
eq 
0 ];
then
    
cd 
$WorkDIR
    
cd 
httpd-2.4.10
    
.
/configure 
-prefix=$HTTPDIR -
enable
-so -
enable
-rewrite -
enable
-modules=all \
--with-apr=
/usr/local/apr 
--with-apr-util=
/usr/local/apr-util
make 
&& 
make 
install
else
    
echo 
"------ apr-util make failed. ------"
    
exit 
1
fi
if 
[ $? -
eq 
0 ];
then
    
CONF=$HTTPDIR
/conf/httpd
.conf
    
cp 
$HTTPDIR
/bin/apachectl 
/etc/init
.d
/httpd
    
chmod 
+x 
/etc/init
.d
/httpd
    
sed 
-i 
"s/#ServerName www.example.com:80/ServerName ${IP}:80/g" 
$CONF
    
sed 
-i 
's/DirectoryIndex index.html/DirectoryIndex index.php index.html/g' 
$CONF
    
sed 
-i 
"391 s/^/AddType application\/x-httpd-php .php/" 
$CONF
    
/etc/init
.d
/httpd 
start
    
IP=`
ifconfig 
eth0 |
grep 
"inet addr" 
|
cut 
-d: -f2 |
awk 
'{print $1}'
`
    
Urlcode=`curl -o 
/dev/null 
-s -w 
"%{http_code}" 
$IP
/index
.html` 
    
[ $Urlcode -
eq 
200 ] && 
echo 
"Apache install success." 
|| 
echo 
"Apache install failed."
else
    
echo 
"------ apache make failed. ------"
    
exit 
1
fi
;;
2)
########## Install Depend Pkg ##########
depend_pkg;
########## Install Mysql ##########
/usr/sbin/groupadd 
mysql
/usr/sbin/useradd 
-g mysql -s 
/sbin/nologin 
mysql
WorkDIR=
/usr/local/src
MYSQLDIR=
/usr/local/mysql5
.5
cd 
$WorkDIR
[ -f 
"mysql-5.5.39.tar.gz" 
] || wget http:
//cdn
.mysql.com
/Downloads/MySQL-5
.5
/mysql-5
.5.39.
tar
.gz
tar 
zxvf mysql-5.5.39.
tar
.gz
cd 
mysql-5.5.39
cmake -DCMAKE_INSTALL_PREFIX=$MYSQLDIR \
-DSYSCONFDIR=$MYSQLDIR
/etc 
\
-DMYSQL_DATADIR=$MYSQLDIR
/data 
\
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make 
&& 
make 
install
if 
[ $? -
eq 
0 ];
then
    
$MYSQLDIR
/scripts/mysql_install_db 
\
    
--basedir=$MYSQLDIR --datadir=$MYSQLDIR
/data/ 
--user=mysql 1>
/dev/null
    
mkdir 
$MYSQLDIR
/etc
    
cp 
support-files
/my-medium
.cnf $MYSQLDIR
/etc/my
.cnf
    
cp 
support-files
/mysql
.server 
/etc/init
.d
/mysqld
    
rm 
-rf 
/etc/my
.cnf
    
#echo "PATH=$PATH:$MYSQLDIR/bin" >> /etc/profile 
    
#. /etc/profile
    
chmod 
+x 
/etc/init
.d
/mysqld
    
chown 
-R root.mysql $MYSQLDIR
    
chown 
-R mysql.mysql $MYSQLDIR
/data/
    
$MYSQLDIR
/bin/mysqld_safe 
--user=mysql&
    
$MYSQLDIR
/bin/mysqladmin 
-u root password 
'123.com'
    
$MYSQLDIR
/bin/mysql 
-uroot -p
'123.com' 
-e 
"show databases;"
    
[ $? -
eq 
0 ] && 
echo 
"MySQL install success." 
|| 
echo 
"MySQL install failed."
else
    
echo 
"------mysql cmake failed.------"
    
exit 
fi
;;
3)
########## Install Depend Pkg ##########
depend_pkg;
########## Install GD ##########
yum 
install 
gd freetype freetype-devel libpng libpng-devel zlib zlib-devel libjpeg* -y
########## Install PHP ##########
WorkDIR=
/usr/local/src
PHPDIR=
/usr/local/php5
.4
PHPCONF=$PHPDIR
/etc/php
.ini
cd 
$WorkDIR
[ -f 
"php-5.4.31.tar.gz" 
] || wget http:
//cn2
.php.net
/distributions/php-5
.4.31.
tar
.gz
tar 
zxvf php-5.4.31.
tar
.gz 
cd 
php-5.4.31
.
/configure 
-prefix=$PHPDIR \
--with-config-
file
-path=$PHPDIR
/etc 
\
--with-apxs2=
/usr/local/apache2
.4
/bin/apxs 
\
--with-mysql=
/usr/local/mysql5
.5 \
--with-mysqli=
/usr/local/mysql5
.5
/bin/mysql_config 
\
--
enable
-soap --
enable
-bcmath --
enable
-zip --
enable
-
ftp 
\
--
enable
-mbstring --with-gd --with-libxml-
dir 
--with-jpeg-
dir 
\
--with-png-
dir 
--with-freetype-
dir 
--with-zlib \
--with-libxml-
dir
=
/usr 
--with-curl --with-xsl --with-openssl
make 
&& 
make 
install
if 
[ $? -
eq 
0 ];
then
    
cp 
php.ini-production $PHPCONF
    
echo 
"data.timezone = Asia\Shanghai" 
>> $PHPCONF
    
sed 
-i 
's/upload_max_filesize = 2M/ upload_max_filesize = 50M/g' 
$PHPCONF
    
sed 
-i 
's/display_errors = Off/display_errors = On/g' 
$PHPCONF
    
echo 
"<?php phpinfo();?>" 

/usr/local/apache2
.4
/htdocs/index
.php
    
/etc/init
.d
/httpd 
restart 
    
/etc/init
.d
/mysqld 
restart &>
/dev/null
    
IP=`
ifconfig 
eth0 |
grep 
"inet addr" 
|
cut 
-d: -f2 |
awk 
'{print $1}'
`
    
Urlcode=`curl -o 
/dev/null 
-s -w 
"%{http_code}" 
$IP
/index
.php`
    
[ $Urlcode -
eq 
200 ] && 
echo 
"PHP install success." 
|| 
echo 
"PHP install failed."
    
echo 
"/usr/local/apache/bin/apachectl start" 
>> 
/etc/rc
.
local
    
chkconfig mysqld on
else
    
echo 
"------ php make failed. ------"
    
exit 
1
fi
;;
*)
    
echo 
"Please input number 1 2 3."
esac

使用方法:

wKioL1QDBE_y1nBRAADgD4vjJCw081.jpg

Shell脚本能力薄弱,有错误之处,还望指正。谢谢!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/109039.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • SPPnet论文总结

    SPPnet论文总结小菜看了SPPNet这篇论文之后,也是参考了前人的博客,结合自己的一些观点写了这篇论文总结。这里参考的连接如下:[http://blog.csdn.net/u013078356/article/details/50865183]论文:《SpatialPyramidPoolinginDeepConvolutionalNetwo

    2022年6月7日
    31
  • 激光slam综述_激光slam原理

    激光slam综述_激光slam原理本篇是记录曾书格老师的课程《激光slam理论与实践》先贴一下个人总结(有理解的不正确的,麻烦指出来):第一章:激光SLAM简要介绍1、输出Metricalmap尺度地图,slam分为两种:基于滤波的filter-based的SLAM,和Graph-based的SLAM。2、(1)基于Graph-based的代表是cartographer,可以修复t时刻之前的误差分为两部…

    2022年8月23日
    6
  • 测试19

    测试19一、Linux必备知识linux作为现在最流行的软件环境系统,一定需要掌握,目前的招聘要求都需要有linux能力。二、Shell脚本掌握shell脚本,包括shell基础与应用、shell逻辑控

    2022年7月1日
    25
  • 《Getting Started with WebRTC》第一章 WebRTC介绍

    《Getting Started with WebRTC》第一章 WebRTC介绍

    2022年1月22日
    475
  • java sortedset用法_Java SortedSet headSet()用法及代码示例[通俗易懂]

    java sortedset用法_Java SortedSet headSet()用法及代码示例[通俗易懂]Java中的SortedSet接口的headSet()方法用于返回此集合中其元素严格小于参数toElement的部分的视图。此方法返回的集合由该集合支持,因此返回集合中的更改会反映在该集合中,反之亦然。此方法返回的set支持此set支持的所有可选set操作。注意:如果试图插入超出其范围的元素,则此方法返回的集合将引发IllegalArgumentException。用法:SortedSethea…

    2022年8月31日
    5
  • python编写怎么换行_python表示换行

    广告关闭腾讯云11.11云上盛惠,精选热门产品助力上云,云服务器首年88元起,买的越多返的越多,最高返5000元!windows换行符是’rn’,unixlinux的换行符为’n’,mac的换行符为’r’,在python中,对换行符进行了统一处理,定义为’n。到此这篇关于python代码中怎么换行的文章就介绍到这了,更多相关python写代码怎么换行内容请搜索zalou.cn以前的文章或继续浏…

    2022年4月9日
    229

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号