zoukankan      html  css  js  c++  java
  • mac apache配置虚拟主机

    设置虚拟主机

    1. 在终端运行“sudo vi /etc/apache2/httpd.conf”,打开Apche的配置文件
    2. 在httpd.conf中找到“#Include /private/etc/apache2/extra/httpd-vhosts.conf”,去掉前面的“#”,并去掉/private,不用去private里那个设置,保存并退出。
    3. 运行“sudo apachectl restart”,重启Apache后就开启了虚拟主机配置功能。
    4. 运行“sudo vi /etc/apache2/extra/httpd-vhosts.conf”,就打开了配置虚拟主机文件httpd-vhost.conf,配置虚拟主机了。需要注意的是该文件默认开启了两个作为例子的虚拟主机:
    [plain] view plain copy
     
     print?
    1. <VirtualHost *:80>  
    2.      ServerAdmin webmaster@dummy-host.example.com  
    3.      DocumentRoot "/usr/docs/dummy-host.example.com"  
    4.      ServerName dummy-host.example.com  
    5.      ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"  
    6.      CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common  
    7. </VirtualHost>
  
    8. 
<VirtualHost *:80>  
    9.      ServerAdmin webmaster@dummy-host2.example.com  
    10.      DocumentRoot "/usr/docs/dummy-host2.example.com"  
    11.      ServerName dummy-host2.example.com  
    12.      ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"  
    13.      CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common  
    14. </VirtualHost>  

    而实际上,这两个虚拟主机是不存在的,在没有配置任何其他虚拟主机时,可能会导致访问localhost时出现如下提示.

    [plain] view plain copy
     
     print?
    1. Forbidden  
    2. You don't have permission to access /index.php on this server  

    最简单的办法就是在它们每行前面加上#,注释掉就好了,这样既能参考又不导致其他问题。

    增加如下配置

    <VirtualHost *:80>
    #ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/Users/admin/wang/djangoprojects/ai123"
    ServerName www.vai123.ai
    ServerAlias vai123.ai
    WSGIScriptAlias / /Users/admin/wang/djangoprojects/ai123/ai123/wsgi_local.py
    Alias /static/ /Users/admin/wang/djangoprojects/ai123/static/
    Alias /uploads/ /Users/admin/wang/djangoprojects/ai123/uploads/
    <Directory "/Users/admin/wang/djangoprojects/ai123">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
    </Directory>
    ErrorLog "/var/log/apache2/vai123.ai-error_log"
    # CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
    </VirtualHost>

  • 相关阅读:
    nginx article
    学习历程
    GRPC
    学习记录
    JAVA知识点记录
    flag
    读的文章
    This usually happens because your environment has changed since running `npm install`.
    expandedRowKeys、expandedRowsChange、expand
    服务端高并发分布式架构演进之路
  • 原文地址:https://www.cnblogs.com/xqnq2007/p/7364158.html
Copyright © 2011-2022 走看看