编译安装LAMP,实现多虚拟主机,一个虚拟主机blog.magedu.com 一个虚拟主机 forum.magedu.com

3 篇文章 0 订阅

环境:
两台主机:一台apache+php-fpm ,一台mariadb
软件版本:
apr-1.7.0.tar.bz2
apr-util-1.6.1.tar.bz2
httpd-2.4.39.tar.bz2
php-7.3.7.tar.xz
Discuz_X3.3_SC_UTF8.zip
wordpress-5.2.2.tar.gz
mariadb-10.2.25-linux-x86_64.tar.gz

1 实现mariadb

mysql>create database wordpress;
mysql>create database discuz;
mysql>grant all on wordpress.* to wordpress@'192.168.37.%' identified by 'magedu';
mysql>grant all on discuz.* to discuz@'192.168.37.%' identified by 'magedu';

2 实现编译安装httpd
1)安装相关的包

yum install gcc prce-devel openssl-devel expat-devel -y

2)编译安装

for p in *.bz2 ;do tar xvf $p;done
mv apr-1.7.0 httpd-2.4.39/srclib/apr
mv apr-util-1.6.1 httpd-2.4.39/srclib/apr-util

useradd -r -s /sbin/nologin apache
cd httpd-2.4.39/

./configure \
--prefix=/app/httpd24 \
--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 4 && make install

环境变量和启动

echo 'PATH=/app/httpd24/bin:$PATH' > /etc/profile.d/httpd24.sh
. /etc/profile.d/httpd24.sh


LoadModule proxy_module modules/mod_proxy.so 
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
DirectoryIndex index.php index.html   
User apache
Group apache
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ProxyRequests Off

<virtualhost *:80>
servername blog.magedu.com
documentroot /data/wordpress
<directory /data/wordpress>
require all granted
</directory>
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/wordpress/$1
</virtualhost>


<virtualhost *:80>
servername forum.magedu.com
documentroot /data/discuz
<directory /data/discuz>
require all granted
</directory>
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/discuz/$1
</virtualhost>    

mkdir /data/{wordpress,discuz}

setfacl -Rm u:apache:rwx /data/{wordpress,discuz}

3 实现编译安装php
(1)

yum install libxml2-devel bzip2-devel libmcrypt-devel

(2)

tar xvf php-7.3.7.tar.xz 
cd php-7.3.7/
./configure --prefix=/app/php --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets --enable-fpm --enable-maintainer-zts --disable-fileinfo
make && make install

cp php.ini-production /etc/php.ini
cp  sapi/fpm/init.d.php-fpm  /etc/init.d/php-fpm 
chmod +x /etc/init.d/php-fpm
cd /app/php/etc
cp php-fpm.conf.default php-fpm.conf
cd php-fpm.d/
cp www.conf.default www.conf
vim www.conf
user = apache
group = apache

service php-fpm start

4 /etc/hosts

blog.magedu.com forum.magedu.com

lastb |awk '/ssh/{print $3}'|sort |uniq -c|sort -nr|while read count ip;do if [ $count  -gt 10 ];then iptables -A INPUT -s $ip -j REJECT ;fi;done
lastb |awk '/ssh/{ip[$3]++}END{for(i in ip){if(ip[i]>10){system("iptables -A INPUT -s "i" -j REJECT")}}}'
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值