centos7安装配置apache(httpd)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7安装配置apache(httpd)相关的知识,希望对你有一定的参考价值。

  1. 安装:
    yum  -y  install  httpd
  2. 支持目录索引:
    a. 首页索引:
    vim /etc/httpd/conf.d/welcome.conf
    技术分享图片
    b. 自定义索引样式:
    vim /etc/httpd/conf/httpd.conf
    技术分享图片
  3. 支持php
    技术分享图片
  4. 开启pathinfo:
    技术分享图片
  5. 解决跨域:
    技术分享图片
  6. 开启rewrite功能:
    技术分享图片
  7. 配置虚拟主机:
    技术分享图片
  8. 配置文件参考:
    ServerRoot "/etc/httpd"
    Listen 80
    Include conf.modules.d/*.conf
    User apache
    Group apache
    ServerAdmin [email protected]
    <Directory />
    AllowOverride none
    Require all denied
    </Directory>
    DocumentRoot "/var/www/html"
    <Directory "/var/www">
    AllowOverride None
    Require all granted
    </Directory>
    <Directory "/var/www/html">
    Header set Access-Control-Allow-Origin *
    Options Indexes FollowSymLinks
    IndexStyleSheet "/css/style.css"
    IndexOptions FancyIndexing HTMLTable ScanHTMLTitles FoldersFirst NameWidth=85 DescriptionWidth=128 IconWidth=16 IconHeight=16 VersionSort Charset=UTF-8
    AllowOverride all
    Require all granted
    AcceptPathInfo on
    </Directory>
    <IfModule dir_module>
    DirectoryIndex index.html
    </IfModule>
    <Files ".ht*">
    Require all denied
    </Files>
    ErrorLog "logs/error_log"
    LogLevel warn
    <IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
    CustomLog "logs/access_log" combined
    </IfModule>
    <IfModule alias_module>
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
    </IfModule>
    <Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
    </Directory>
    <IfModule mime_module>
    TypesConfig /etc/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType text/html .shtml
    AddType application/x-httpd-php .php .phtml .php3 .inc
    AddOutputFilter INCLUDES .shtml
    </IfModule>
    AddDefaultCharset UTF-8
    <IfModule mime_magic_module>
    MIMEMagicFile conf/magic
    </IfModule>
    EnableSendfile on
    IncludeOptional conf.d/*.conf
    <VirtualHost *:80>
    ServerName virtual.dollar.com
    DocumentRoot "/var/www/html/virtual/"
    DirectoryIndex index.php index.html
    <Directory "/var/www/html/virtual/">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    </VirtualHost>

以上是关于centos7安装配置apache(httpd)的主要内容,如果未能解决你的问题,请参考以下文章

CentOS7安装配置Apache HTTP Server

Centos7-yum部署配置LAMP-之LAMP及php-fpm实现反代动态资源

httpd安装与配置(centos7) 2

CentOS7 构建httpd+svn+ifsvnadmin配置

centos7 apache提供文件下载

Centos7 apache2.4.29(httpd) 安装