编译安装LAMP,实现多虚拟主机

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
实验:编译安装LAMP,实现多虚拟主机,一个虚拟主机blog.magedu.com 一个虚拟主机 bbb.magedu.com
环境:两台主机
一台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.80.%' identified by 'magedu';
mysql>grant all on discuz.* to discuz@'192.168.80.%' identified by 'magedu';
 
 
2 实现编译安装httpd
#安装相关的依赖包
yum install gcc prce-devel openssl-devel expat-devel -y
 
#编译安装
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=/usr/local/httpd \
--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=/usr/local/httpd/bin:$PATH' > /etc/profile.d/httpd.sh
. /etc/profile.d/httpd.sh
 
 
#启动文件
vim /usr/lib/systemd/system/httpd.service
    [Service]
    Type=forking
    #EnvironmentFile=/etc/sysconfig/httpd
    ExecStart=/usr/local/httpd/bin/httpd $OPTIONS -k start
    ExecReload=/usr/local/httpd/bin/httpd  $OPTIONS -k graceful
    ExecStop=/bin/kill -WINCH ${MAINPID}
 
#配置httpd
vim /usr/local/httpd/conf/httpd.conf
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 bbs.magedu.com
    documentroot /data/discuz
    <directory /data/discuz>
        require all granted
    </directory>
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/discuz/$1
</virtualhost>   
 
 
#解压两个项目
tar xvf wordpress-5.2.2-zh_CN.tar.gz  -C /data/
unzip Discuz_X3.3_SC_UTF8.zip 
mv upload/*  /data/discuz/
 
 
#设置站点ACL权限,主要是用于生成wordpress/wp-config.php文件。
mkdir /data/{wordpress,discuz}
setfacl -Rm u:apache:rwx /data/{wordpress,discuz}
     
 
3 实现编译安装php 需要epel
#安装相关的依赖包
yum install libxml2-devel bzip2-devel libmcrypt-devel
 
#编译安装
tar xvf php-7.3.7.tar.xz
cd php-7.3.7/
./configure --prefix=/usr/local/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
 
[root@localhost7e php-7.3.7]#pwd
/usr/local/src/php-7.3.7
 
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 /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf
cd php-fpm.d/
cp www.conf.default www.conf
 
 
 
#配置php-rpm配置文件(基本不用设置)
vim /etc/php-fpm.d/www.conf
user = apache
group = apache
#确保运行php-fpm进程的用户对session目录有读写权限(测试没有此文件)
mkdir /var/lib/php/session
chown apache.apache /var/lib/php/session
 
 
 
systemctl restart httpd
service php-fpm start
 
 
4 /etc/hosts
blog.magedu.com forum.magedu.com<br><br>5测试

 

 

posted @   yuanbangchen  阅读(29)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
· AI 智能体引爆开源社区「GitHub 热点速览」
点击右上角即可分享
微信分享提示