美文网首页
内置PHP配置多站点:

内置PHP配置多站点:

作者: wxking | 来源:发表于2018-03-15 17:32 被阅读0次

    内置PHP配置多站点:

    1.修改/private/etc/hosts 文件,建议用编辑器打开

    最后一行加入你的网站名称(自定义),参考如下:

    127.0.0.1 www.test.com

    2.修改/private/etc/apache2/httpd.conf 文件,建议用编辑器打开

    查找“httpd-vhosts.conf”,找到如下代码:

    #Include conf/extra/httpd-vhosts.conf

    去掉最前面的#,并保存(保存的时候需要输入密码)

    3.修改/private/etc/apache2/extra/httpd-vhosts.conf文件  ,建议用编辑器打开

    滚动到最下面,看到如下2段类似的代码:

        ServerAdmin webmaster@dummy-host.example.com

        DocumentRoot "/usr/docs/dummy-host.example.com"

        ServerName dummy-host.example.com

        ServerAlias www.dummy-host.example.com

        ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"

        CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common

        ServerAdmin webmaster@dummy-host2.example.com

        DocumentRoot "/usr/docs/dummy-host2.example.com"

        ServerName dummy-host2.example.com

        ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"

        CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common

    修改后如下,其实只是复制一段,然后修改了“DocumentRoot”(文件夹地址)和“ServerName”(访问域名,需要与第一步的设置吻合) 第一段是新增的自定的域名,第二,第三段是为了保证localhost,127.0.0.1的方式仍然可以登陆(其实也是自定的方式,只不过把域名特地写成习惯的localhost和127.0.0.1)

        ServerAdmin webmaster@dummy-host.example.com

    DocumentRoot "/Library/WebServer/Documents/"

        ServerName www.test.com

        ServerAlias www.dummy-host.example.com

        ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"

        CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common

        ServerAdmin webmaster@dummy-host.example.com

    DocumentRoot "/Library/WebServer/Documents"

        ServerName localhost

        ServerAlias www.dummy-host.example.com

        ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"

        CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common

        ServerAdmin webmaster@dummy-host2.example.com

      DocumentRoot "/Library/WebServer/Documents"

        ServerName 127.0.0.1

        ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"

        CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common

    4.重启apache即可,终端命令:sudo apachectl restart

    5.如果还要新增域名,将重复第1和第3步,

    相关文章

      网友评论

          本文标题:内置PHP配置多站点:

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