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. [学习笔记] Splay Tree 从入门到放弃

    前几天由于出行计划没有更博QwQ (其实是因为调试死活调不出来了TAT我好菜啊) 伸展树 伸展树(英语:Splay Tree)是一种二叉查找树,它能在O(log n)内完成插入.查找和删除操作.它是由 ...

  2. Android文件上传与下载

    文件上传与下载 文件上传 -- 服务端 以Tomcat为服务器,Android客服端访问Servlet,经Servlet处理逻辑,最终将文件上传,这里就是简单模拟该功能,就将文件上传到本机的D:\\u ...

  3. 35. leetcode 501. Find Mode in Binary Search Tree

    501. Find Mode in Binary Search Tree Given a binary search tree (BST) with duplicates, find all the  ...

  4. struts2相关简单介绍

    一 Struts2环境配置 1.准备jar包,核心jar包有: 2.创建Struts2项目并导入jar包 3.在Struts2项目中src下创建Struts.xml配置文件 4.在Web.xml文件中 ...

  5. ABP+AdminLTE+Bootstrap Table权限管理系统第九节--AdminLTE模板页搭建

    AdminLTE 官网地址:https://adminlte.io/themes/AdminLTE/index2.html 首先去官网下载包下来,然后引入项目. 然后我们在web层添加区域Admin以 ...

  6. css中的几个小tip(二)

    margin的塌陷现象 (一)在标准文档流中, 垂直方向存在margin的塌陷现象 先上段代码: <style type="text/css"> .box{ width ...

  7. 配置AIX系统互信关系

    解释: 信任关系指一台远程服务器的用户以相同的用户名接入到另外一台服务器,而无需提供口令. 双机之间建立信任关系后,可以使用“rcp”和“rlogin”等命令. 操作步骤: 1.以root用户登录双机 ...

  8. POJ-1861-NETWORK 解题报告

    Network Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16628   Accepted: 6597   Specia ...

  9. java运算符优先级与流程控制

    1. Java 的方法Method (函数 Function), 功能, 动作 1) 方法就是函数: y=f(x)=3x+6; 2) 方法的语法   (修饰词)(返回值类型)(方法名)(参数列表){  ...

  10. Oracle存储过程和函数使用方法

    一.存储过程(PROCEDURE) 使用过程, 不仅可以简化客户端应用程序的开发和维护,而且可以提高应用程序的运行性能.  CREATE [OR REPLACE] PROCUDURE procedur ...