二进制安装 LAMP 架构的 word press

准备:两台主机
一台安装httpd,php服务 10.0.0.171
一台安装mariadb服务 10.0.0.181

数据库脚本

tar_path=/usr/local
db=https://downloads.mariadb.org/interstitial/mariadb-10.2.27/source/mariadb-10.2.27.tar.gz/from/https%3A//archive.mariadb.org/
indb_path=/data/mysql

useradd -r -s /sbin/nologin mysql
tar xvf ${db} -C ${tar_path}
cd ${tar_path}
ln -sv ${db%.tar} mysql
cd mysql
chown -R root.root ./

mkdir ${indb_path} -p
chown -R mysql.mysql ${indb_path}
mkdir
cp support-files/my-huge.cnf /etc/mysql/my.cnf
vim /etc/mysql/my.cnf
[mysqld]

datadir =${indb_path}
skip_name_resolve = ON

vim /etc/profile.d/lamp.sh
PATH=${tar_path}/mysql/bin/:$PATH
. /etc/profile.d/lamp.sh
yum install libaio -y
cd ${tar_path}/mysql;scripts/mysql_install_db  --user=mysql --datadir=${indb_path}
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
service mysqld start

mysql -uroot
mysql> create database wordpress;

mysql> grant all on wordpress.* to wordpress@'10.0.0.%' identified by "123456";

httpd脚本

#!/bin/bash
#**
#Author: DOU
#Date: 2020-10-31
#FileName: install_httpd2.4.sh
#Description: The test script
#**
#
#提示信息颜色
col_start="\033[32m"
col_end="\033[0m"
#存放下载包路径
tar_path=/usr/local/src/
#安装install路径
ins_path=/apps/httpd
#相关包
apr=apr-1.7.0.tar.gz
aprutil=apr-util-1.6.1.tar.gz
httpd=httpd-2.4.46.tar.gz

安装相关包

echo -e "${col_start}安装相关包${col_end}"
yum -y install wget gcc make pcre-devel openssl-devel expat-devel

下载源代码并解压缩

echo -e "${col_start}下载源代码并解压缩${col_end}"
cd ${tar_path}
pwd
wget https://mirror.bit.edu.cn/apache//apr/${apr}
wget https://mirror.bit.edu.cn/apache//apr/${aprutil}
wget https://mirrors.bfsu.edu.cn/apache//httpd/${httpd}

tar xf ${apr}
tar xf ${aprutil}
tar xf ${httpd}

将apr和apr-util源码与httpd源码合并,三者共同编译安装

echo -e "${col_start}编译安装${col_end}"
mv ${apr%.tar} ${httpd%.tar}/srclib/apr
mv ${aprutil%.tar} ${httpd%.tar}/srclib/apr-util
cd ${httpd%.tar*}/
./configure --prefix=${ins_path} --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 -j 2 && make install >/dev/null

创建apache账户

echo -e "${col_start}创建apache账户${col_end}"
useradd -r -s /sbin/nologin apache

修改配置文件

echo -e "${col_start}修改配置文件${col_end}"
sed -i 's/^User./User apache/' ${ins_path}/conf/httpd.conf
sed -i 's/^Group.
/Group apache/' ${ins_path}/conf/httpd.conf

配置环境变量

echo -e "${col_start}配置环境变量${col_end}"
echo 'PATH="${ins_path}/bin:$PATH"' > /etc/profile.d/httpd.sh
. /etc/profile.d/httpd.sh

配置man帮助

echo -e "${col_start}配置man帮助${col_end}"
echo 'MANDATORY_MANPATH   ${ins_path}/man' >> /etc/man_db.conf

创建service unit文件,设置开机启动

echo -e "${col_start}设置开机启动${col_end}"
cat > /lib/systemd/system/httpd.service << EOF
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
Type=forking
ExecStart=${ins_path}/bin/apachectl start
ExecReload=${ins_path}/bin/apachectl graceful
ExecStop=${ins_path}/bin/apachectl stop

We want systemd to give httpd some time to finish gracefully, but still want

it to kill httpd after TimeoutStopSec if something went wrong during the

graceful stop. Normally, Systemd sends SIGTERM signal right after the

ExecStop, which would kill httpd. We are sending useless SIGCONT here to give

httpd time to finish.

KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now httpd.service

###php、wordpress脚本

#! /bin/bash

*****

author: DOU

date: 2020-10-31

fileName: install_httpd2.4.sh

description: The test script

*****

#

提示信息颜色

col_start="\033[32m"
col_end="\033[0m"

存放下载包路径

tar_path=/usr/local/src/

安装httpd路径

ins_path=/apps/httpd

相关包

apr=apr-1.7.0.tar.gz
aprutil=apr-util-1.6.1.tar.gz
httpd=httpd-2.4.46.tar.gz

安装相关包

echo -e "${col_start}安装相关包${col_end}"
yum -y install wget gcc make pcre-devel openssl-devel expat-devel

下载源代码并解压缩

echo -e "${col_start}下载源代码并解压缩${col_end}"
cd ${tar_path}
pwd
wget https://mirror.bit.edu.cn/apache//apr/${apr}
wget https://mirror.bit.edu.cn/apache//apr/${aprutil}
wget https://mirrors.bfsu.edu.cn/apache//httpd/${httpd}

tar xf ${apr}
tar xf ${aprutil}
tar xf ${httpd}

将apr和apr-util源码与httpd源码合并,三者共同编译安装

echo -e "${col_start}编译安装${col_end}"
mv ${apr%.tar} ${httpd%.tar}/srclib/apr
mv ${aprutil%.tar} ${httpd%.tar}/srclib/apr-util
cd ${httpd%.tar*}/
./configure --prefix=${ins_path} --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 -j 2 && make install >/dev/null

创建apache账户

echo -e "${col_start}创建apache账户${col_end}"
useradd -r -s /sbin/nologin apache

修改配置文件

echo -e "${col_start}修改配置文件${col_end}"
sed -i 's/^User./User apache/' ${ins_path}/conf/httpd.conf
sed -i 's/^Group.
/Group apache/' ${ins_path}/conf/httpd.conf

配置环境变量

echo -e "${col_start}配置环境变量${col_end}"
echo 'PATH="${ins_path}/bin:$PATH"' > /etc/profile.d/httpd.sh
. /etc/profile.d/httpd.sh

配置man帮助

echo -e "${col_start}配置man帮助${col_end}"
echo 'MANDATORY_MANPATH   ${ins_path}/man' >> /etc/man_db.conf

创建service unit文件,设置开机启动

echo -e "${col_start}设置开机启动${col_end}"
cat > /lib/systemd/system/httpd.service << EOF
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
Type=forking
ExecStart=${ins_path}/bin/apachectl start
ExecReload=${ins_path}/bin/apachectl graceful
ExecStop=${ins_path}/bin/apachectl stop

# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.

KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now httpd.service

测试如下

二进制安装 LAMP 架构的 word press

二进制安装 LAMP 架构的 word press

二进制安装 LAMP 架构的 word press

二进制安装 LAMP 架构的 word press

二进制安装 LAMP 架构的 word press

二进制安装 LAMP 架构的 word press

上一篇:rockpro64编译aliyun oss


下一篇:一键源码安装lamp环境