标签:something util dev 配置文件 tab red 相关 systemctl openssl
准备:两台主机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}
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
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
echo -e "${col_start}配置man帮助${col_end}"
echo ‘MANDATORY_MANPATH ? ${ins_path}/man‘ >> /etc/man_db.conf
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
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now httpd.service
###php、wordpress脚本
#! /bin/bash
#
col_start="\033[32m"
col_end="\033[0m"
tar_path=/usr/local/src/
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}
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
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
echo -e "${col_start}配置man帮助${col_end}"
echo ‘MANDATORY_MANPATH ? ${ins_path}/man‘ >> /etc/man_db.conf
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
测试如下
标签:something util dev 配置文件 tab red 相关 systemctl openssl
原文地址:https://blog.51cto.com/13812780/2546076