Binary installation of word press of LAMP architecture

Preparation: Two hosts,
one to install httpd, php service 10.0.0.171, and
mariadb service 10.0.0.181

Database script

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 script

#!/bin/bash
# **
#Author: DOU
#Date: 2020-10-31
#FileName: install_httpd2.4.sh
#Description: The test script
# **
# #Prompt
information color
col_start="\033[32m "
col_end="\033[0m" #Store
download package path
tar_path=/usr/local/src/ #Install
install path
ins_path=/apps/httpd #Related
package
apr=apr-1.7.0.tar.gz
aprutil=apr -util-1.6.1.tar.gz
httpd=httpd-2.4.46.tar.gz

Install related packages

echo -e "${col_start}Install related packages${col_end}"
yum -y install wget gcc make pcre-devel openssl-devel expat-devel

Download the source code and unzip

echo -e "${col_start} download the source code and unzip ${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}

Combine the source code of apr and apr-util with the source code of httpd, compile and install the three together

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

Create apache account

echo -e "${col_start}Create apache account${col_end}"
useradd -r -s /sbin/nologin apache

Modify the configuration file

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

Configure environment variables

echo -e "${col_start} configure environment variables ${col_end}" echo'PATH
="${ins_path}/bin:$PATH"'> /etc/profile.d/httpd.sh
. /etc/profile.d /httpd.sh

Configure man help

echo -e "${col_start} configuration man help${col_end}"
echo'MANDATORY_MANPATH ${ins_path}/man' >> /etc/man_db.conf

Create a service unit file and set the startup to start

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 script

#! /bin/bash

*****

author: DOU

date: 2020-10-31

fileName: install_httpd2.4.sh

description: The test script

*****

#

Prompt message color

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

Store download package path

tar_path=/usr/local/src/

Install httpd path

ins_path=/apps/httpd

Related packages

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

Install related packages

echo -e "${col_start}Install related packages${col_end}"
yum -y install wget gcc make pcre-devel openssl-devel expat-devel

Download the source code and unzip

echo -e "${col_start} download the source code and unzip ${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}

Combine the source code of apr and apr-util with the source code of httpd, compile and install the three together

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

Create apache account

echo -e "${col_start}Create apache account${col_end}"
useradd -r -s /sbin/nologin apache

Modify the configuration file

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

Configure environment variables

echo -e "${col_start} configure environment variables ${col_end}" echo'PATH
="${ins_path}/bin:$PATH"'> /etc/profile.d/httpd.sh
. /etc/profile.d /httpd.sh

Configure man help

echo -e "${col_start} configuration man help${col_end}"
echo'MANDATORY_MANPATH ${ins_path}/man' >> /etc/man_db.conf

Create a service unit file and set the startup to start

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

The test is as follows

Binary installation of word press of LAMP architecture

Binary installation of word press of LAMP architecture

Binary installation of word press of LAMP architecture

Binary installation of word press of LAMP architecture

Binary installation of word press of LAMP architecture

Binary installation of word press of LAMP architecture

Guess you like

Origin blog.51cto.com/13812780/2546076