美文网首页
Mac OS Brew安装apache配置虚拟主机

Mac OS Brew安装apache配置虚拟主机

作者: 无疆wj | 来源:发表于2022-03-30 09:47 被阅读0次

    mac os 10.15.7

    // 内置的apache
    // 停用
    sudo apachectl stop
    // 禁止开机启动
    sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
    
    //安装
    brew install httpd
    
    # /usr/local/etc/httpd/httpd.conf
    ...
    Listen 80
    ...
    ServerName www.example.com:80
    ...
    #引入自定义虚拟主机配置文件
    Include /usr/local/etc/httpd/vhosts/*.conf
    
    #配置虚拟主机
    <VirtualHost *:80>
        DocumentRoot "***/a.test"
        ServerName "a.test"
        ServerAlias "www.a.test"
        <Directory "***/a.test">
            AllowOverride None
            Require all granted
        </Directory>
    </VirtualHost>
    
    #监听端口(局域网访问)
    Listen 9000
    <VirtualHost *:9000>
        DocumentRoot "***/a.test"
        ServerName "a.test"
        ServerAlias "www.a.test"
        <Directory "***/a.test">
            AllowOverride None
            Require all granted
        </Directory>
    </VirtualHost>
    
    //host
    127.0.0.1 a.test
    127.0.0.1 www.a.test
    

    访问
    http://a.test
    http://127.0.0.1:9000

    配置php支持

    # /usr/local/etc/httpd/httpd.conf
    ...
    LoadModule php_module /usr/local/opt/php@8.1/lib/httpd/modules/libphp.so
    ...
    <IfModule dir_module>
        DirectoryIndex index.html index.php
    </IfModule>
    
    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>
    

    相关文章

      网友评论

          本文标题:Mac OS Brew安装apache配置虚拟主机

          本文链接:https://www.haomeiwen.com/subject/txfbjrtx.html