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

    你可能感兴趣的文章
    PostgreSQL 9.6 同步多副本 与 remote_apply事务同步级别 应用场景分析
    查看>>
    Postgresql CopyManager 流式批量数据入库
    查看>>
    PostgreSQL cube 插件 - 多维空间对象
    查看>>
    PostgreSQL Daily Maintenance - cluster table
    查看>>
    PostgreSQL on Linux 最佳部署手册
    查看>>
    PostgreSQL Oracle 兼容性之 - pipelined
    查看>>
    PostgreSQL Point-In-Time Recovery (Incremental Backup)
    查看>>
    postgresql Streaming Replication监控与注意事项
    查看>>
    postgresql 不需要付费_使用数据传输在PostgreSQL执行 外部连接运算符
    查看>>
    postgresql 主从配置_生产环境postgresql主从环境配置
    查看>>
    postgresql 函数&存储过程 ; 递归查询
    查看>>
    PostgreSQL 分组聚合查询中 filter 子句替换 case when
    查看>>
    PostgreSQL 同步流复制锁瓶颈分析
    查看>>
    PostgreSQL 备份与还原命令 pg_dump
    查看>>
    Postgresql 外部表插件postgres_fdw的安装和使用
    查看>>
    PostgreSQL 如何从崩溃状态恢复(上)
    查看>>
    PostgreSQL 存储过程基本语法
    查看>>
    PostgreSQL 实现批量更新、删除、插入
    查看>>
    PostgreSQL 导入 .gz 备份文件
    查看>>
    PostgreSQL 批量插入&更新数据时报错(ERROR: ON CONFLICT DO UPDATE command cannot affect row a second time)
    查看>>