博客
关于我
在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/

    你可能感兴趣的文章
    Objective-C实现alternate disjoint set不相交集算法(附完整源码)
    查看>>
    Objective-C实现alternative list arrange备选列表排列算法(附完整源码)
    查看>>
    Objective-C实现An Armstrong number阿姆斯特朗数算法(附完整源码)
    查看>>
    Objective-C实现anagrams字谜算法(附完整源码)
    查看>>
    Objective-C实现ApproximationMonteCarlo蒙特卡洛方法计算pi值算法 (附完整源码)
    查看>>
    Objective-C实现area under curve曲线下面积算法(附完整源码)
    查看>>
    Objective-C实现arithmetic算术算法(附完整源码)
    查看>>
    Objective-C实现armstrong numbers阿姆斯壮数算法(附完整源码)
    查看>>
    Objective-C实现articulation-points(关键点)(割点)算法(附完整源码)
    查看>>
    Objective-C实现atoi函数功能(附完整源码)
    查看>>
    Objective-C实现average absolute deviation平均绝对偏差算法(附完整源码)
    查看>>
    Objective-C实现average mean平均数算法(附完整源码)
    查看>>
    Objective-C实现average median平均中位数算法(附完整源码)
    查看>>
    Objective-C实现average mode平均模式算法(附完整源码)
    查看>>
    Objective-C实现avl 树算法(附完整源码)
    查看>>
    Objective-C实现AvlTree树算法(附完整源码)
    查看>>
    Objective-C实现backtracking Jump Game回溯跳跃游戏算法(附完整源码)
    查看>>
    Objective-C实现BACKTRACKING 方法查找集合的幂集算法(附完整源码)
    查看>>
    Objective-C实现bailey borwein plouffe算法(附完整源码)
    查看>>
    Objective-C实现balanced parentheses平衡括号表达式算法(附完整源码)
    查看>>