Centos7 under apache2.4.6 Virtual host configuration

Source: Internet
Author: User

  • First check to see if the/etc/httpd/conf/extra/httpd-vhosts.conf exists, if you do not need to create one, the contents are as follows:
    <virtualhost *:8080>
    #绑定的主域
    ServerName centos7.xxx.com
    #绑定的子域名
    Serveralias localhost
    #网站主目录
    documentroot/var/www/html/
    #日志配置
    Errorlog/var/log/httpd/error.log
    Customlog/var/log/httpd/access.log Common
    #ServerSignature OFF
    </VirtualHost>
    #测试一的配置
    <directory "/var/www/html/" >
    Options FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>

  • Confirm the following configuration entries for the Apache master configuration file (/etc/httpd/conf/httpd.conf):
    Include conf/extra/httpd-vhosts.conf
    Some words cancel the comment, do not add manually;

  • Added 127.0.0.1 test.com www.test.com in/etc/hosts
  • Assigning permissions to a Web directory: Chmod-r-t $path
  • Detect configuration file correctness: Apachectl configtest
  • Restart Apache:systemctl Restart httpd
  • PS: It is important to note that the Apache httpd.conf:

    # 该虚拟主机根目录权限相关设置<Directory />    # 允许根目录中的.htaccess生效并覆盖此处设置    AllowOverride All    # 允许该目录的所有用户操作权限    Require all granted</Directory>

    Centos7 under apache2.4.6 Virtual host configuration

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.