author:JevonWei

版权声明:原创作品


    #!/bin/bash

定义变量

    export MDB=$(rpm -qa *mariadb*)
export HTT=$(rpm -qa *httpd*)
export MDB_USER=$(getent passwd mysql)
export HTT_USER=$(getent passwd apache)

配置yum源

fun_yum() {
if [ -d /etc/yum.repos.d/backup ]; then
mv -f /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup
else
mkdir /etc/yum.repos.d/backup && mv -f /etc/yum.repos.d/*.repo /etc/repos.d/backup
fi
cat > /etc/yum.repos.d/lamp.repo <<EOF
[base]
name=danran
baseurl=https://mirrors.aliyun.com/centos/7.3.1611/os/x86_64/
gpgcheck=0
enable=1 [epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/7/x86_64/
gpgcheck=0
enable=1
EOF yum clean all
}

前期准备

fun_prepare() {
systemctl stop firewalld
systemctl disable firewalld
iptables -F
setenforce 0
sed -ri.bak 's/(^SELINUX=).*/\1permissive/' /etc/selinux/config
echo "export PATH=/usr/local/apache24/bin:/usr/local/mysql/bin:$PATH" > /etc/profile.d/lamp.sh
source /etc/profile.d/lamp.sh
if [ -n "$MDB" ];then
yum -y remove *mariadb*
fi
if [ -n "$HTT" ];then
yum -y remove *httpd*
else
useradd -r -s /sbin/nologin apache -m
fi
yum -y install bzip2 gzip wget pcre-devel openssl-devel libxml2-devel bzip2-devel libmcrypt-devel libaio*
yum -y groupinstall "development tools" # cd /usr/local/src
# ls /usr/local/src | xargs -n1 tar xf
if [ -e /usr/local/src ];then
cd /usr/local/src
if [[ ! -e /usr/local/src/apr-1.5.2.tar.bz2 ]];then
wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.bz2
tar xf apr-1.5.2.tar.bz2
else
tar xf apr-1.5.2.tar.bz2
fi if [[ ! -e /usr/local/src/apr-util-1.5.4.tar.bz2 ]];then
wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.bz2
tar xvf apr-util-1.5.4.tar.bz2
else
tar xvf apr-util-1.5.4.tar.bz2
fi if [[ ! -e /usr/local/src/httpd-2.4.27.tar,bz2 ]];then
wget http://apache.fayea.com/httpd/httpd-2.4.27.tar.bz2
tar xvf httpd-*.tar.bz2
else# tar xvf httpd-*.tar.bz2 fi if [[ ! -e /usr/local/src/mariadb-10.2.7-linux-x86_64.tar.gz ]];then
wget http://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.2.7/bintar-linux-x86_64/mariadb-10.2.7-linux-x86_64.tar.gz
tar xvf mariadb-10.2.7-linux-x86_64.tar.gz
else
tar xvf mariadb-10.2.7-linux-x86_64.tar.gz
fi if [[ ! -e /usr/local/src/php-7.1.7.tar.bz2 ]];then
wget http://cn2.php.net/distributions/php-7.1.7.tar.bz2
tar xvf php-7.1.7.tar.bz2
else
tar xvf php-7.1.7.tar.bz2
fi if [[ ! -e /usr/local/src/wordpress-4.8-zh_CN.tar.gz ]];then
wget wget https://cn.wordpress.org/wordpress-4.8.1-zh_CN.tar.gz
tar xvf wordpress-4.8-zh_CN.tar.gz
else
tar xvf wordpress-4.8-zh_CN.tar.gz
fi
else
mkdir /usr/local/src -p
cd /usr/local/src
wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.bz2
wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.bz2
wget http://apache.fayea.com/httpd/httpd-2.4.27.tar.bz2
wget http://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.2.7/bintar-linux-x86_64/mariadb-10.2.7-linux-x86_64.tar.gz
wget http://cn2.php.net/distributions/php-7.1.7.tar.bz2
wget https://cn.wordpress.org/wordpress-4.8.1-zh_CN.tar.gz
ls | xargs -n1 tar xf
fi

}

httpd编译安装

fun_httpd() {
cd /usr/local/src
mv apr-1.5.2 httpd-2.4.27/srclib/apr
mv apr-util-1.5.4 httpd-2.4.27/srclib/apr-util
cd httpd-2.4.27/
./configure --prefix=/usr/local/apache24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
make && make install
if [ -z "$HTT_USER" ];then
useradd -r apache -s /sbin/nologin
fi
sed -ri 's/(User )daemon/\1apache/' /usr/local/apache24/conf/httpd.conf
sed -ri 's/(Group )daemon/\1apache/' /usr/local/apache24/conf/httpd.conf
apachectl start

}

mariadb二进制安装

fun_mariadb() {
cd /usr/local/src
if [ -z "$MDB_USER" ];then
useradd -r mysql -s /sbin/nologin -d /usr/local/mysqldb -m
fi
mv mariadb-10.2.7-linux-x86_64 /usr/local/mysql
chgrp -R mysql /usr/local/mysql
cd /usr/local/mysql
scripts/mysql_install_db --datadir=/usr/local/mysqldb --user=mysql
[ ! -e /etc/mysql ] && mkdir /etc/mysql
cp /usr/local/mysql/support-files/my-huge.cnf /etc/mysql/my.cnf sed -ri '/\[mysqld\]/a\datadir =/usr/local/mysqldb\ninnodb_file_per_table = ON\nskip_name_resolve = ON' /etc/mysql/my.cnf
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
service mysqld start
mysql -e "create database blog;grant all on blog.* to 'blog'@172.%.%.%' identified by 'blog';"
. /etc/profile.d/lamp.sh

}

PHP编译安装

fun_php() {
cd /usr/local/src/php-7.1.7
./configure --prefix=/usr/local/php --enable-mysqlnd --with-mysqli=mysqlnd --with-openssl --enable-mbstring --with-png-dir --with-jpeg-dir --with-freetype-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache24/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2
make && make install
cp php.ini-production /etc/php.ini sed -ri '/IfModule mime_module/a\ AddType application/x-httpd-php .php\nAddType application/x-httpd-php-source .phps' /usr/local/apache24/conf/httpd.conf
sed -ri 's/(^[[:space:]]+DirectoryIndex).*/\1 index.html index.php/' /usr/local/apache24/conf/httpd.conf
}

wordpress安装

fun_wordpress() {
cd /usr/local/src
cp -a wordpress /usr/local/apache24/htdocs/blog
chown -R apache /usr/local/apache24/htdocs/blog setfacl -m u:daemon:rwx /app/httpd24/htdocs/blog/
# 或
# cp /usr/local/apache24/htdocs/blog/wp-config-sample.php /usr/local/apache24/htdocs/blog/wp-config.php
# sed -ri 's/database_name_here/blog/' /usr/local/apache24/htdocs/blog/wp-config.php
# sed -ri 's/username_here/blog/' /usr/local/apache24/htdocs/blog/wp-config.php
# sed -ri 's/password_here/blog/' /usr/local/apache24/htdocs/blog/wp-config.php
# rm -f /usr/local/apache24/htdocs/index.html } fun_yum
fun_prepare
fun_httpd
fun_mariadb
fun_php
fun_wordpress
apachectl stop
apachectl start
service mysqld restart
echo "安装完毕"
echo "账号密码为blog"
echo "请尽快登录验证" unset MDB HTT MDB_USER HTT_USER exit

LAMP一键安装的更多相关文章

  1. CentOS LAMP一键安装网站环境及添加域名

    一般的VPS用户普遍使用一键安装包和WEB管理面板居多,在一键安装包中,使用LAMP和LNMP的普遍居多. 第一个版本的LAMP环境包安装过程以及建站过程分享出来. 第一.LAMP一键包环境的安装 目 ...

  2. LAMP一键安装脚本 from:秋水逸冰

    Install LAMP(Linux + Apache + MySQL + PHP ) for CentOS/Redhat/Fedora 项目地址:https://github.com/teddysu ...

  3. phpstudy linux (lnmp,lamp)一键安装

    phpStudy for Linux 支持Apache/Nginx/Tengine/Lighttpd, 支持php5.2/5.3/5.4/5.5切换 已经在centos-6.5,debian-7.4. ...

  4. lamp 一键安装

    下载安装(ssh登录服务器,执行如下操作即可,需要用到root用户权限来安装) 源码编译安装 wget http://dl.wdlinux.cn:5180/lanmp_laster.tar.gz ta ...

  5. 转:CentOS/Debian/Ubuntu一键安装LAMP(Apache/MySQL/PHP)环境

    CentOS/Debian/Ubuntu一键安装LAMP(Apache/MySQL/PHP) 今天遇到一个网友提到需要在Linux VPS服务器中安装LAMP(Apache/MySQL/PHP)网站环 ...

  6. LAMP一键安装包(Python版)

    去年有出一个python整的LAMP自动安装,不过比较傻,直接调用的yum 去安装了XXX...不过这次一样有用shell..我也想如何不调用shell 来弄一个LAMP自动安装部署啥啥的..不过尼玛 ...

  7. lamp一键配置 --转自秋水

    https://teddysun.com/lamp LAMP一键安装脚本 最后修改于:2015年11月08日 / 秋水逸冰 / 54,300 次围观 973 本脚本适用环境: 系统支持:CentOS/ ...

  8. CentOS下LAMP一键yum安装脚本

    本脚本适用环境: 系统支持:CentOS/Redhat/Fedora 内存要求:≥64M 硬盘要求:2GB以上的剩余空间 服务器必须配置好软件源和可连接外网 必须具有系统 root 权限 建议使用干净 ...

  9. LAMP一键安装包-CentOS 5/6下自动编译安装Apache,MySQL,PHP

    http://www.centos.bz/lamp/ 此安装包已经不再维护,请使用新版http://www.centos.bz/ezhttp/. 适用环境: 系统支持:CentOS-5 (32bit/ ...

随机推荐

  1. 使用pdfbox分页保存pdf为图片

    一.背景 pdfbox作为Apache开源的PDF操作工具,允许创建新的PDF文档,操作现有文档,以及从文档中提取内容的能力.Apache PDFBox还包括一些命令行实用工具.本文楼主主要介绍其中的 ...

  2. Easy DataGrid 实现动态列、行

    Easy DataGrid 实现动态列.行 前端代码: <title>展示销售的实时数据</title> <script type="text/javascri ...

  3. mybatis入门介绍一

    首先介绍一下Mybatis是什么?mybatis是Java的持久层框架, JAVA操作数据库是通过jdbc来操作的,而mybatis是对jdbc的封装. 使用mybatis之后,开发者只需要关注sql ...

  4. nopCommerce 3.9 大波浪系列 之 可退款的支付宝插件(下)

    一.回顾 支付宝插件源码下载地址:点击下载 上篇介绍了使用支付宝插件进行支付,全额退款,部分退款还有插件的多店铺配置,本文介绍下如何实现的. 二.前期准备 插件主要有3个功能: 多店铺插件配置 支付功 ...

  5. mysql忘记密码,修改密码重新安装的一些问题

    前言 想要装cobra,却意外发现mysql连接失败,命令行连一下发现无论怎么样都连不上了. 我能想到的密码都用上了,糟糕!看来只能修改密码,或者重装了. 最后是重装搞定的,当然也发现了正确的修改密码 ...

  6. 《撸轮子系列》之LoadPE

    前言 我新书<Python爬虫开发与项目实战>出版了. 这本书包括基础篇,中级篇和深入篇三个部分,不仅适合零基础的朋友入门,也适合有一定基础的爬虫爱好者进阶,如果你不会分布式爬虫,不会千万 ...

  7. python基础===随机打印txt文件中的某一行

    def find(): txt = open(r'F:\send1.txt','rb') data = txt.read().decode('utf-8') #python3一定要加上这句不然会编码报 ...

  8. Oracle B-tree、位图、全文索引三大索引性能比较及优缺点汇总

    引言:大家都知道“效率”是数据库中非常重要的一个指标,如何提高效率大家可能都会想起索引,但索引又这么多种,什么场合应该使用什么索引呢?哪种索引可以提高我们的效率,哪种索引可以让我们的效率大大降低(有时 ...

  9. 基于tensorflow的‘端到端’的字符型验证码识别源码整理(github源码分享)

    基于tensorflow的‘端到端’的字符型验证码识别 1   Abstract 验证码(CAPTCHA)的诞生本身是为了自动区分 自然人 和 机器人 的一套公开方法, 但是近几年的人工智能技术的发展 ...

  10. Linux命令的学习

    mkdir -p 创建目录 (make directorys) p递归创建 ls -l(long)d(direcitory)显示目录或者文件 cd 切换目录  从"/"开始目录,/ ...