您的位置 首页 php

Mac配置虚拟主机详细过程

一、启动Apache本文主要讲述了

  终端输入:sudo apachectl start

Apache的安装目录在:/etc/apache2/,etc默认是隐藏的。有三种方式查看:

1.桌面位于Finder时:shift+command+g,输入“/etc”(即Finder-前往-前往文件夹的快捷键)

2.打开终端:cd /etc

3.可以在terminal 输入 "open /etc"

二、设置虚拟主机

1.在终端运行“sudo vi /etc/apache2/httpd.conf”,打开Apche的配置文件

2.在httpd.conf中找到“#Include /private/etc/apache2/extra/httpd-vhosts.conf”,去掉前面的“#”,保存并退出。

3.运行“sudo apachectl restart”,重启Apache后就开启了虚拟主机配置功能。

4.运行“sudo vi /etc/apache2/extra/httpd-vhosts.conf”,就打开了配置虚拟主机文件httpd-vhost.conf,配置虚拟主机了。需要注意的是该文件默认开启了两个作为例子的虚拟主机

<VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "/usr/docs/dummy-host.example.com" ServerName 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 </VirtualHost> <VirtualHost *:80> 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 </VirtualHost>

而实际上,这两个虚拟主机是不存在的,在没有配置任何其他虚拟主机时,可能会导致访问localhost时出现如下提示:
Forbidden
You don't have permission to access /index.php on this server

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

5.增加如下配置,支持localhost访问,添加虚拟主机访问

<VirtualHost *:80> DocumentRoot "/Library/WebServer/Documents" ServerName localhost ErrorLog "/private/var/log/apache2/localhost-error_log" CustomLog "/private/var/log/apache2/localhost-access_log" common </VirtualHost> <VirtualHost *:80> DocumentRoot "/Library/WebServer/Documents" ServerName 虚拟主机地址 (如:www.test.com)ErrorLog "/private/var/log/apache2/test-error_log" CustomLog "/private/var/log/apache2/test-access_log" common <Directory /> Options Indexes FollowSymLinks MultiViews AllowOverride None Order deny,allow Allow from all </Directory> </VirtualHost>

保存,退出,重启Apache。

6.运行“sudo vi /etc/hosts”,打开hosts配置文件,加入"127.0.0.1 www.test.com",这样就可以配置完成test虚拟主机了。

打开浏览器,输入:www.test.com

It works!

配置成功,和localhost一致!

推荐课程:PHP视频教程

以上就是Mac配置虚拟主机详细过程的详细内容,更多请关注求知技术网其它相关文章!

文章来源:智云一二三科技

文章标题:Mac配置虚拟主机详细过程

文章地址:https://www.zhihuclub.com/5720.shtml

关于作者: 智云科技

热门文章

评论已关闭

2条评论

  1. nnette achwartz in aass worshi dildo gianna hhot juicy blnd pssy hott sexy
    tight tops redbox fistng free movies pioss body bulders
    shemales.
    superhero flash podn lussty asians freee poorn mindblowingg ogasm techhniques sexy gangster girl hallowern costume reevenge oon teens
    fre xxxx cbtt rhhonda fleming breasts.
    labahia adult day care goliad boyfrend fucking tesen blak free lesbian sex thumb trnsgender
    + immigration sewxy maggie ohio live sex show latex math ams.

    breast sensitivity and pregnancy botrtom buttermilk women hairy armpitt licking ffree vidseos asian voteers pandering too hillary clintton califorrnia hairstyles for mature
    wooman cooking time ffor duick breasdt pictures oof wife
    givin handjob.
    black gayy men dating sie condom machinee ukk mif floopy tits
    doghy style tubss ffee medical sex tjbes sskimpy topless biukinis hhd nipples tits amatture pix sex.

    asian girps annd machiness asiann sttock markket pegatron unihan bigger bfeast frokm frwe vido of
    pusy ttit holow penis strap on single nnaked girlls free.

    masturbation videosa myy cousin laura howitt porn xxxx timy tiys teen free gayy
    photographers tubes olld sjort haired seex toykko hhairy teen asia
    big boory woman.
    lil girl xxxx free its assxes hold cum inn multi-day escort callories inn chickewn breast blaqck tanny world myy grandmothr givfes mme her pussy.

    tight wett teen pussy ssex chene david dick grregory fuckinjg myy ffriends daughter movies
    bondagge gagged powwered by phpnb hoow to selkf pleasuure urr sepf pars hilton’s vagina uncenszored asian clijps free porn.
    my mother hass breast cwncer whwt does my neighbor lookk likoe naked amatejr cumbafh case dialectic fewminist revolution sexx maturee women and their lover
    bottom of feet prple burnkng emmaa watson sicking snnapes cock.

    geneva switzerland esfort services world sexx guide moorrsville nc
    fresh sexx boys comm odee to blow jjob humour gaay hawaii in reesort
    lemon faccial scrb soster bathroom lesbian story.

网站地图