MAC 配置多域名小记

2020-11-24  本文已影响0人  東玖零

最近学习了一些Vue的知识,可以创建前段项目了,但没有后台接口,就寻思着整一个后台小项目对接前端项目,阿里云50元左右就能购买一年使用的虚拟主机,虽然空间小了点但200M学习还是够了,不过就是能运行php,那么就简单整个php小项目,能说上是项目那肯定得上个框架,查了一下 cakephp(cakephp-2.x-11.8m)、laravel(laravel-8.x-365k)都不错,虽然我不会但有个学习的大概思路,

mac版本升级了,按上一篇文章说到配置多域名,在/etc/apache2/extra/httpd-vhosts.conf中新增了域名,重启服务器后还是无法访问。

'#配置localhost 防止配置了其他域名localhost无法使用'
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/Library/WebServer/Documents"
    ServerName localhost
    ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
    <Directory /Library/WebServer/Documents>
        Require all granted
    </Directory>
</VirtualHost>
'#配置ceshi.cn'
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/Users/xxx/WebServer"
    ServerName ceshi.cn
    ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
    <Directory /Users/xxx/WebServer>
        Require all granted
    </Directory>
</VirtualHost>

<Directory /Library/WebServer/Documents>
改为
<Directory "/Library/WebServer/Documents">

<Directory /Users/xxx/WebServer>
改为
<Directory "/Users/xxx/WebServer">

sudo apachectl restart 输入密码重启就能正常访问了。

上一篇下一篇

猜你喜欢

热点阅读