1.第一步

项目npm run build 生成dist目录

注意:把mui 中的所有svg注释掉

2.第二步

解压Apache

img

在Apache的bin目录下执行:httpd -t 查看是否出错

3.第三步(以下均在服务端操作)

修改Apache下的conf下的httpd.conf配置文件

37行 Define SRVROOT “E:/Apache”

39行 ServerRoot “E:/Apache”

59行 #Listen 12.34.56.78:80

60行 Listen 8010

61行 Listen 8020

142行 LoadModule proxy_module modules/mod_proxy.so

151行 LoadModule proxy_http_module modules/mod_proxy_http.so

225行 ServerName localhost:8888

233行 Options Indexes FollowSymLinks

234行 AllowOverride None

235行 Order allow,deny

236行 Allow from all

251行 DocumentRoot “C:\“

252行

4.第四步

​ 把dist中的文件拷贝到E:/webapp中

5.第五步

​ 在Apache的bin目录下执行:

​ 安装:$ httpd.exe -k install -n “Apache”

​ 卸载:$ httpd.exe -k uninstall -n “Apache”

​ Win+R: services.msc启动或停止Apache服务器。

6.第六步

​ 在浏览器中输入localhost:8010查看网页显示

7.第七步

​ 配置Apache虚拟目录(允许Apache运行多个项目)

​ 509行: # Virtual hosts

​ 510行:Include conf/extra/httpd-vhosts.conf(打开)

8.第八步(配置反向代理)

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
  <VirtualHost *:8010> 

DocumentRoot "E:/webapp"

<Directory "E:/webapp">

​ Options FollowSymLinks Indexes

​ AllowOverride none

​ Require all granted

</Directory>

Proxyrequests off

<Proxy *>

​ \#规定Deny,Allow的执行顺序, Order Deny,Allow : 先执行Deny,再执行Allow

​ Order Deny,Allow

​ \#全部禁止访问 取值:all none 指定ip

​ Allow from All
</Proxy>
#配置反向代理
ProxyPass /cellphone http://172.24.42.8:4000/cellphone
ProxyPass /banner http://172.24.42.8:4000/banner
ProxyPass /user http://172.24.42.8:4000/user
ProxyPass /like http://172.24.42.8:4000/like
ProxyPass /likelist http://172.24.42.8:4000/likelist
ProxyPass /search http://172.24.42.8:4000/search
ProxyPass /personalized http://172.24.42.8:4000/personalized
ProxyPass /playlist http://172.24.42.8:4000/playlist
ProxyPass /lyric http://172.24.42.8:4000/lyric
ProxyPass /top http://172.24.42.8:4000/top
ProxyPass /toplist http://172.24.42.8:4000/toplist
ProxyPass /comment http://172.24.42.8:4000/comment
ProxyPass /artist http://172.24.42.8:4000/artist
ProxyPass /artists http://172.24.42.8:4000/artists
ProxyPass /song http://172.24.42.8:4000/song

</VirtualHost>

<VirtualHost *:8020>

DocumentRoot "E:/webapp1"

<Directory "E:/webapp1">

​ Options FollowSymLinks Indexes

​ AllowOverride none

​ Require all granted

</Directory>

Proxyrequests off

<Proxy *>

​ \#规定Deny,Allow的执行顺序, Order Deny,Allow : 先执行Deny,再执行Allow

​ Order Deny,Allow

​ \#全部禁止访问 取值:all none 指定ip

​ Allow from All

</Proxy>

​ \#配置反向代理

ProxyPass /cats http://api.zhuishushenqi.com/cats

ProxyPass /book http://api.zhuishushenqi.com/book

ProxyPass /post http://api.zhuishushenqi.com/post

ProxyPass /ranking http://api.zhuishushenqi.com/ranking

ProxyPass /btoc http://api.zhuishushenqi.com/btoc

ProxyPass /atoc http://api.zhuishushenqi.com/atoc

ProxyPass /chapter http://chapter2.zhuishushenqi.com/chapter
</VirtualHost>

注意:

在C:\Windows\System32\drivers\etc的hosts中添加

​ 172.24.42.8(服务器ip) smallan.top(域名)

9.访问

​ smllant.top:8010 smllant.top:8020

10.解决首屏加载比较慢的问题

1.打开 httpd.conf配置文件中下面两个模块的注释

1
2
3
#LoadModule deflate_module modules/mod_deflate.so

#LoadModule headers_module modules/mod_headers.so

2.在httpd.conf配置文件最下面添加

1
2
3
4
5
6
7
<IfModule deflate_module>

SetOutputFilter DEFLATE

DeflateCompressionLevel 9

</IfModule>