博客
关于我
在CentOS 8上安装与配置Apache虚拟主机
阅读量:206 次
发布时间:2019-02-28

本文共 4027 字,大约阅读时间需要 13 分钟。

????

?????Centos 8

Web???apache
??IP?192.168.3.21
Shell???root

?root?????sudo???????????????


??httpd??

????????/etc/httpd/conf/httpd.conf

??Apache???

# yum??httpd?????[root@linuxcool ~]# yum install httpd-devel.x86_64 httpd.x86_64 httpd-tools.x86_64 -y

?????

[root@linuxcool ~]# httpd -vServer version: Apache/2.4.6 (CentOS)Server built: Apr  2 2020 13:13:23

??httpd???

[root@linuxcool ~]# systemctl start httpd.service[root@linuxcool ~]# systemctl status httpd.service? httpd.service - The Apache HTTP Server   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)   Active: active (running) since Fri 2020-05-22 12:23:03 CST; 25s ago   Docs: man:httpd(8) man:apachectl(8)   Main PID: 952 (httpd)   Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"   Tasks: 6   Memory: 3.6M   CGroup: /system.slice/httpd.service   ??952 /usr/sbin/httpd -DFOREGROUND   ??953 /usr/sbin/httpd -DFOREGROUND   ??954 /usr/sbin/httpd -DFOREGROUND   ??955 /usr/sbin/httpd -DFOREGROUND   ??956 /usr/sbin/httpd -DFOREGROUND   ??957 /usr/sbin/httpd -DFOREGROUND

??

????IP???????

# ????http://192.168.3.21/

?????????/var/www/html?????index.html?????????????????

# ?????????index.html[root@linuxcool ~]# cd /var/www/html[root@linuxcool /var/www/html]# touch index.html[root@linuxcool /var/www/html]# vi index.html

????????

Welcome

This is Apache Site!


??Apache????

???????

[root@linuxcool ~]# mkdir -p /var/www/web1[root@linuxcool ~]# mkdir -p /var/www/web2

???????

[root@linuxcool ~]# chown -R apache: /var/www/web2/

???????????

[root@linuxcool ~]# vim /etc/httpd/conf.d/web1.conf

???????

ServerName web1.com ServerAlias www.web1.com ServerAdmin webmaster@example.com DocumentRoot /var/www/web1
Options -Indexes +FollowSymLinks AllowOverride All
ErrorLog /var/log/httpd/example.com-error.log CustomLog /var/log/httpd/example.com-access.log combined

??httpd???

[root@linuxcool ~]# systemctl restart httpd.service

???????

# ????http://www.web1.com/http://www.web2.com/

Apache??

  • ???????????1??
  • ExpiresActive on ExpiresByType text/css "access plus 1 days" ExpiresByType text/javascript "access plus 1 days" ExpiresByType image/* "access plus 1 days"
    1. ??GZIP???
    2. DeflateCompressionLevel 6 AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html SetEnvIfNoCase Request_URI .(?:html|htm)$ no-gzip dont-vary SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary SetEnvIfNoCase Request_URI .(?:pdf|doc)$ no-gzip dont-vary
      1. ?????????
      2. # ???upload??ProxyPass /upload !
        1. ??/upload?????403?????404????
        2. RedirectMatch 404 ^/upload/$
          1. ??TRACE???
          2. TraceEnable off
            1. ????????
            2. RewriteEngine onRewriteCond %{REQUEST_URI} ^/RewriteRule ^/ /sso/ [R=permanent,L]
              1. ??proxy?????
              2. Timeout 600ProxyTimeout 600

                Apache????

                ?????/usr/local/apache2

                ??????/usr/local/apache2/conf/httpd.conf
                ?????????/usr/local/apache2/conf/vhost/

                ???????????????????????????

                # ??????www.baidu.comroot@ubuntu:~# /root/vhost.sh

                ?????

                ServerName www.baidu.com ServerAlias www.baidu.com ServerAdmin support@example.com DocumentRoot /home/wwwroot/www.baidu.com
                Options -Indexes +FollowSymLinks AllowOverride All
                ErrorLog /var/log/apache2/baidu.com-error.log CustomLog /var/log/apache2/baidu.com-access.log combined ProxyPass /ajp://192.168.122.100:8019/ ProxyPassReverse /ajp://192.168.122.100:8019/

                ??Apache???

                # ??apache??/etc/init.d/apache2 restart

                ????

                • CentOS 8 ??????Apache???????1
                • RHEL7 ????Apache?????2

    转载地址:http://vtxi.baihongyu.com/

    你可能感兴趣的文章
    Openlayers高级交互(15/20):显示海量多边形,10ms加载完成
    查看>>
    Openlayers高级交互(16/20):两个多边形的交集、差集、并集处理
    查看>>
    Openlayers高级交互(17/20):通过坐标显示多边形,计算出最大幅宽
    查看>>
    Openlayers高级交互(18/20):根据feature,将图形适配到最可视化窗口
    查看>>
    Openlayers高级交互(19/20): 地图上点击某处,列表中显示对应位置
    查看>>
    Openlayers高级交互(2/20):清除所有图层的有效方法
    查看>>
    Openlayers高级交互(20/20):超级数据聚合,页面不再混乱
    查看>>
    Openlayers高级交互(3/20):动态添加 layer 到 layerGroup,并动态删除
    查看>>
    Openlayers高级交互(4/20):手绘多边形,导出KML文件,可以自定义name和style
    查看>>
    Openlayers高级交互(5/20):右键点击,获取该点下多个图层的feature信息
    查看>>
    Openlayers高级交互(6/20):绘制某点,判断它是否在一个电子围栏内
    查看>>
    Openlayers高级交互(7/20):点击某点弹出窗口,自动播放视频
    查看>>
    Openlayers高级交互(8/20):选取feature,平移feature
    查看>>
    Openlayers高级交互(9/20):编辑图形(放缩、平移、变形、旋转),停止编辑
    查看>>
    Openlayers:DMS-DD坐标形式互相转换
    查看>>
    openlayers:圆孔相机根据卫星经度、纬度、高度、半径比例推算绘制地面的拍摄的区域
    查看>>
    OpenLDAP(2.4.3x)服务器搭建及配置说明
    查看>>
    OpenLDAP编译安装及配置
    查看>>
    Openmax IL (二)Android多媒体编解码Component
    查看>>
    OpenMCU(一):STM32F407 FreeRTOS移植
    查看>>