为MacOS Sierra设置LocalHost服务器以使用PHP和Apache [英] Setting up LocalHost server for MacOS Sierra to use PHP and apache

查看:85
本文介绍了为MacOS Sierra设置LocalHost服务器以使用PHP和Apache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意: 我不会撒谎,我对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. I did try and read some online tutorials such as this one, but this all seems to be more than I need.

我学到一些知识,然后编写了一些要在本地测试的最小PHP代码.但是,这似乎意味着我需要使用服务器.显然LocalHost可以达到这个目的.因此,我创建了一个目录~/Sites,该目录存储不同的目录,每个目录都包含一个小型网站(每个目录都包含诸如资产,css,js等子目录以及实际的html页面).

I have some learned and then made some minimal PHP code that I want to test locally. However, that appears to mean that I need to use a server. Apparently LocalHost can serve that purpose. 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/a_website/index.html)的根指定为本地主机,以便查看我的PHP代码是否有效? /p>

How do I set-up whatever I need to set-up so that I can specify the root of one of this small websites (e.g. ~/Sites/a_website/index.html) as the local host so I can see if my PHP code works?

推荐答案

继续下载 XAMPP ,这可能是最受欢迎的本地开发环境.

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":

启动Apache Web服务器.您的计算机现在正在作为本地主机环境"运行.

Start the Apache Web Server. Your computer is now running as a 'localhost environment'.

如果您进入浏览器并输入localhost,则应该出现橙色的欢迎使用XAMPP"页面.

If you go to your browser and type localhost, you should be greeted by a orange "Welcome to XAMPP" page.

在Finder中,导航到Applications > XAMPP > xamppfiles > htdocs,在这里您可以创建网站".例如:在htdocs目录中,我将创建一个名为test的文件夹,其中将是我相关的HTML,CSS,PHP等-如果现在在浏览器中访问localhost/test,我会看到该站点就像我将其托管在网上一样.

In Finder, navigate to Applications > XAMPP > xamppfiles > htdocs, which is where you "create your sites". 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.

随时问任何其他问题.

这篇关于为MacOS Sierra设置LocalHost服务器以使用PHP和Apache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆