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. Beautifulsoup和selenium的简单使用

    Beautifulsoup和selenium的简单使用 requests库的复习 好久没用requests了,因为一会儿要写个简单的爬虫,所以还是随便写一点复习下. import requests r ...

  2. 7. leetcode 104. Maximum Depth of Binary Tree

    Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...

  3. CgLib动态代理学习【Spring AOP基础之一】

    如果不了解JDK中proxy动态代理机制的可以先查看上篇文章的内容:Java动态代理学习[Spring AOP基础之一] 由于Java动态代理Proxy.newProxyInstance()的时候会发 ...

  4. Linux操作系统-命令-top

    当我们在执行性能测试的时候,需要关注 业务性能指标(业务监控) 吞吐量(TPS) 响应时间 平均响应时间 50%用户响应时间 90%用户响应时间 标准差 # TPS标准差越小,说明波动越小,系统越稳定 ...

  5. ubuntu 15.10 安装jdk

    转http://www.bkjia.com/xtzh/881605.html 第一步,下载Linux版JDK 可以通过访问Oracle官网下载,或者直接通过命令行下载. lxh@ubuntu:~$ w ...

  6. 【复制】【编码】MySQL复制中的编码问题

    编码背景知识 Latin-1,全称ISO 8859-1 Latin 1 对ASCII的拉丁语扩展 向下兼容ASCII,其编码范围是0x00-0xFF,0x00-0x7F之间完全和ASCII一致,0x8 ...

  7. Oracle高水位2

    --Oracle高水位2---------------------2013/11/24 一.什么是水线(High Water Mark)? 所有的oracle段(segments,在此,为了理解方便, ...

  8. Matlab学习笔记(2)

    1. 在MATLAB中默认最开始出现的是命令窗口,也就是Command Window.对应的文件保存后扩展名一般都 是.mat 真正的程序代码编辑窗口应该新建New Script或者其他的.此时保存的 ...

  9. HTML-CSS相关(2)

    [CSS常用文本属性] 1,字体.字号类: ① font-weight:字体粗细. bold-加粗 noemal-正常 lighter-细体 也可以使用100-900数值,400表示normal,70 ...

  10. Clang之语法抽象语法树AST

    语法分析器的任务是确定某个单词流是否能够与源语言的语法适配,即设定一个称之为上下文无关语言(context-free language)的语言集合,语法分析器建立一颗与(词法分析出的)输入单词流对应的 ...