[英]Setting up LocalHost server for MacOS Sierra to use PHP and apache
Note : I am not going to lie, I know pretty much nothing about apache, servers, local host, etc so please pardon my ignorance - if there is a comprehensive or a great review out there for these things, please point me in their direction. 注意 :我不会撒谎,我对apache,服务器,本地主机等一无所知,所以请原谅我的无知-如果对这些事情有全面的评论,请给我指出方向。 I did try and read some online tutorials such as this one , but this all seems to be more than I need.
我确实尝试阅读了一些在线教程,例如本教程,但这似乎超出了我的需要。
I have some learned and then made some minimal PHP code that I want to test locally. 我了解了一些知识,然后制作了一些要在本地测试的最小PHP代码。 However, that appears to mean that I need to use a server.
但是,这似乎意味着我需要使用服务器。 Apparently LocalHost can serve that purpose.
显然LocalHost可以达到这个目的。 So I have made a directory
~/Sites
which stores different directories each housing a small website (each with subdirectories such as assets, css, js, etc and the actually html pages). 因此,我创建了一个目录
~/Sites
,该目录存储了不同的目录,每个目录都包含一个小型网站(每个目录都包含子目录,例如资产,css,js等,以及实际的html页面)。
How do I set-up whatever I need to set-up so that I can specify the root of one of this small websites (eg ~/Sites/a_website/index.html
) as the local host so I can see if my PHP code works? 如何设置我需要设置的内容,以便可以将其中一个小型网站的根目录(例如
~/Sites/a_website/index.html
)指定为本地主机,因此可以查看我的PHP代码是否作品?
Go ahead and download XAMPP , which is probably the most popular local environment for development. 继续下载XAMPP ,它可能是最受欢迎的本地开发环境。
Once it's installed, open the XAMPP Control Panel, and click "Manage Servers": 安装完成后,打开XAMPP控制面板,然后单击“管理服务器”:
Start the Apache Web Server. 启动Apache Web服务器。 Your computer is now running as a 'localhost environment'.
您的计算机现在正在作为“本地主机环境”运行。
If you go to your browser and type localhost
, you should be greeted by a orange "Welcome to XAMPP" page. 如果你到你的浏览器,键入
localhost
,你应该用橙色“欢迎XAMPP”页面映入眼帘。
In Finder, navigate to Applications > XAMPP > xamppfiles > htdocs
, which is where you "create your sites". 在Finder中,导航到“
Applications > XAMPP > xamppfiles > htdocs
,您可以在其中“创建站点”。 For example: inside the htdocs
directory, I would make a folder called test
which inside would be my relevant HTML, CSS, PHP etc - if I now went in my browser to localhost/test
, I would see that site just like I would if it was hosted online. 例如:在
htdocs
目录中,我将创建一个名为test
的文件夹,其中将是我相关的HTML,CSS,PHP等-如果现在我在浏览器中访问localhost/test
,则我将看到该站点,就像它是在线托管的。
Feel free to ask any further questions. 随时提出任何其他问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.