CentOS6.5自动化安装LAMP脚本

本文涉及的产品
RDS MySQL DuckDB 分析主实例,基础系列 4核8GB
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
RDS DuckDB + QuickBI 企业套餐,8核32GB + QuickBI 专业版
简介:
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脚本能力薄弱,有错误之处,还望指正。谢谢!



本文转自 李振良OK 51CTO博客,原文链接:http://blog.51cto.com/lizhenliang/1547140,如需转载请自行联系原作者

相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
相关文章
|
8月前
|
安全 Linux iOS开发
Nessus Professional 10.10 Auto Installer for RHEL 10, AlmaLinux 10, Rocky Linux 10 - Nessus 自动化安装程序
Nessus Professional 10.10 Auto Installer for RHEL 10, AlmaLinux 10, Rocky Linux 10 - Nessus 自动化安装程序
581 6
Nessus Professional 10.10 Auto Installer for RHEL 10, AlmaLinux 10, Rocky Linux 10 - Nessus 自动化安装程序
|
8月前
|
Ubuntu 安全 iOS开发
Nessus Professional 10.10 Auto Installer for Ubuntu 24.04 - Nessus 自动化安装程序
Nessus Professional 10.10 Auto Installer for Ubuntu 24.04 - Nessus 自动化安装程序
1120 5
|
8月前
|
安全 Ubuntu iOS开发
Nessus Professional 10.10 Auto Installer for Windows - Nessus 自动化安装程序
Nessus Professional 10.10 Auto Installer for Windows - Nessus 自动化安装程序
299 3
Nessus Professional 10.10 Auto Installer for Windows - Nessus 自动化安装程序
|
8月前
|
安全 Ubuntu iOS开发
Nessus Professional 10.10 Auto Installer for macOS Tahoe - Nessus 自动化安装程序
Nessus Professional 10.10 Auto Installer for macOS Tahoe - Nessus 自动化安装程序
230 5
|
8月前
|
人工智能 监控 Kubernetes
77_自动化脚本:Makefile与Airflow
在当今AI大模型时代,高效的工作流管理对于模型训练、推理和部署至关重要。随着大模型规模的不断增长和复杂度的提升,传统的手动脚本管理方式已无法满足需求。自动化脚本和工作流调度系统成为构建健壮、可重复、可扩展的LLM Pipeline的关键工具。其中,Makefile作为经典的自动化构建工具,与Airflow作为现代工作流调度平台的结合,为LLM开发团队提供了强大的工作流管理能力。
238 0
|
12月前
|
机器学习/深度学习 Kubernetes 监控
Kubernetes 节点故障自愈方案:结合 Node Problem Detector 与自动化脚本
本文深入探讨了Kubernetes节点故障自愈方案,结合Node Problem Detector(NPD)与自动化脚本,提供技术细节、完整代码示例及实战验证。文章分析了硬件、系统和内核层面的典型故障场景,指出现有监控体系的局限性,并提出基于NPD的实时事件捕获与自动化诊断树的改进方案。通过深度集成NPD、设计自动化修复引擎以及展示内核死锁恢复的实战案例,文章详细说明了自愈流程的实现步骤与性能优势。此外,还提供了生产环境部署指南、高可用架构设计及安全防护措施,并展望了机器学习增强故障预测和混沌工程验证的进阶优化方向。全文约1.2万字,适合希望提升Kubernetes集群稳定性的技术人员阅读。
775 2
|
10月前
|
传感器 人工智能 JavaScript
Playwright实战:写UI自动化脚本,速度直接起飞
简介: 测试工程师老王因UI自动化问题深夜奋战,反映出传统测试工具的局限性。微软开源的Playwright凭借智能等待、跨域操作、移动端模拟与网络拦截等强大功能,正迅速取代Selenium,成为新一代自动化测试标准。其稳定高效的设计显著降低维护成本,助力企业构建高质量测试流程。
|
Linux Shell
Centos或Linux编写一键式Shell脚本删除用户、组指导手册
Centos或Linux编写一键式Shell脚本删除用户、组指导手册
386 4
|
Linux Shell 数据安全/隐私保护
Centos或Linux编写一键式Shell脚本创建用户、组、目录分配权限指导手册
Centos或Linux编写一键式Shell脚本创建用户、组、目录分配权限指导手册
648 3