macos必做的设置

by Philipp Haidenbauer

菲利普·海登鲍尔(Philipp Haidenbauer)

如何在MacOS上设置PHP,CaddyServer和Kirby —以及为什么要这样做 (How to set up PHP, CaddyServer, and Kirby on MacOS — and why you should do it)

Recently Kirby Version 3.0 was released. As I have worked with Version 2 for quite some time in the past, I figured why not give it a try?

最近发布了Kirby 3.0 版 。 在过去的很长时间里,我一直在使用Version 2,所以我想为什么不尝试一下呢?

Just before Christmas, I bought a brand new MacBook Air, so it was obvious that I would like to try Kirby right away on it. I stumbled upon a great article on how to set up CaddyServer and PHP on MacOS. But I changed some of it.

圣诞节即将来临之前,我购买了全新的MacBook Air,因此很明显我想立即尝试使用Kirby。 我偶然发现了一篇很棒的文章,关于如何在MacOS上设置CaddyServer和PHP。 但是我改变了一些。

CaddyServer,PHP和Kirby (CaddyServer, PHP and Kirby)

Let’s get started with a brief overview of what software I’m talking about.

让我们从我正在谈论的软件的简要概述开始。

PHP (PHP)

I don’t think I have much to say about PHP. It’s probably one of the oldest Scripting Languages out there in the WebWorld. PHP was “the” language for making your website “dynamic”. And it was also the first language I discovered and learned to play around with.

我认为关于PHP我没有太多要说的。 它可能是WebWorld中最古老的脚本语言之一。 PHP是使网站“动态”的“语言”。 这也是我发现并学会使用的第一语言。

Caddy服务器 (CaddyServer)

Is a small but very powerful Web-Server which I discovered a few months ago. It has some really nice features like automatic SSL / HTTPs and a really easy configuration file (which you will see later). And it’s blazing fast. :)

是我几个月前发现的小型但功能强大的Web服务器。 它具有一些非常好的功能,例如自动SSL / HTTPs和一个非常简单的配置文件(稍后您将看到)。 而且速度很快。 :)

柯比 (Kirby)

Another great tool I discovered a few years ago. Basically, it’s a CMS (Content Management System) based on a simple FileStructure. Even if you don’t know much about PHP, it’s relatively simple to get into creating templates for pages and extending the whole functionality.

我几年前发现的另一个很棒的工具。 基本上,这是一个基于简单FileStructure的CMS(内容管理系统)。 即使您对PHP不太了解,但为页面创建模板并扩展整个功能还是相对简单的。

为什么? (Why?)

Now that you know about all three projects, you might be asking why you should use them together. Well, there are multiple reasons for it:

既然您了解了这三个项目,您可能会问为什么要同时使用它们。 好吧,有多种原因:

  • MacOS comes with a default apache2 installation, but as you might know, Apache is one of the biggest HTTP servers out there. It’s widely adopted, but it has one downside. It eats memory and CPU like no other web-server out there. So if you’re on the go, it also eats battery like crazy and I don’t like that.

    MacOS带有默认的apache2安装,但是您可能知道,Apache是​​目前最大的HTTP服务器之一。 它被广泛采用,但有一个缺点。 它像其他网络服务器一样消耗内存和CPU。 因此,如果您在旅途中,它还会像疯了一样吃掉电池,而我不喜欢那样。

  • Caddy is very lightweight and doesn’t really use much Memory / CPU / Battery.球童非常轻巧,实际上并没有使用太多的内存/ CPU /电池。
  • Kirby, as I’ve said is easy to customize and extend. As it’s a CMS, you don’t need to worry about a database or application-specific logic from the beginning. That way you can prototype pretty fast, which leads to faster results and more satisfaction as you get things done. :)正如我所说,柯比很容易定制和扩展。 由于它是CMS,因此从一开始就无需担心数据库或特定于应用程序的逻辑。 这样一来,您就可以非常快速地进行原型制作,从而可以更快地获得结果并在完成工作时获得更高的满意度。 :)

Without further ado, let’s get into setting it up:

事不宜迟,让我们开始进行设置:

首先 (First of all)

It’s essential to have homebrew installed, as package management get’s a whole lot easier with it.

安装自制软件至关重要,因为软件包管理变得非常容易。

You can install it with a simple command:

您可以使用简单的命令进行安装:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

PHP (PHP)

Now that we have a package manager, it’s time to install the correct PHP-version. Kirby needs at least PHP7.1 so I installed 7.2 :)

现在我们有了一个软件包管理器,是时候安装正确PHP版本了。 Kirby至少需要PHP7.1,所以我安装了7.2 :)

brew install php@7.2

There are also some extensions which are needed:

还需要一些扩展:

brew install freetype jpeg libpng gd

Caddy服务器 (CaddyServer)

Now that we have PHP and some dependencies installed we can now install CaddyServer.

现在我们已经安装了PHP和一些依赖项,现在我们可以安装CaddyServer。

Simply download the suitable Version from https://caddyserver.com/download.

只需从https://caddyserver.com/download下载合适的版本。

You will receive a zip file. Extract it and copy the executable to a path inside your $PATH (in my case /Users/phaidenbauer/bin/):

您将收到一个zip文件。 解压缩它并将可执行文件复制到$ PATH内的路径(在我的情况下为/Users/phaidenbauer/bin/ ):

unzip caddy_v0.11.2_darwin_amd64_personal.zipcp caddy /Users/phaidenbauer/bin/caddy

柯比 (Kirby)

Next one is Kirby. Again download the zip from https://getkirby.com/try.Extract it somewhere you have your projects. In my case that’s /Users/phaidenbauer/development/.

下一个是柯比。 再次从https://getkirby.com/try下载zip文件。将其解压缩到您拥有项目的位置。 在我的情况下是/Users/phaidenbauer/development/

The next essential thing to get this whole thing running is the Caddyfile which tells Caddy what to do :)

要使整个程序运行起来,下一个必不可少的事情是Caddyfile,它告诉Caddy该怎么做:)

localhost:8080tls offroot ./gzip
rewrite {    r .*    to {path} {path}/ /index.php?{path}&{query}}
fastcgi / 127.0.0.1:9000 phpon startup launchctl load -w /Users/phaidenbauer/Library/LaunchAgents/homebrew.mxcl.php@7.2.pliston shutdown launchctl unload -w /Users/phaidenbauer/Library/LaunchAgents/homebrew.mxcl.php@7.2.plist

Let’s go through it:

让我们来看一下:

localhost:8080 tells it on which Port it should listen. If you don't want to run it as root (or via set_cap) you should use something above 1024.

localhost:8080告诉它应该在哪个端口上监听。 如果您不想以root身份(或通过set_cap )运行它,则应使用1024以上的值。

tls off disables the built-in SSL / HTTPS feature, as we are only working locally.

tls off禁用内置的SSL / HTTPS功能,因为我们仅在本地工作。

root ./ sets the root-path of the serving directory.

root ./设置服务目录的根路径。

gzip enables the gzip-compression for responses.

gzip启用gzip-compression进行响应。

rewrite { r .* to {path} {path}/ /index.php?{path}&{query} } rewrites all incoming URLs to suite Kirby’s needs. (It’s probably not the best solution but it works fine for my development environment.)

rewrite { r .* to {path} {path}/ /index.php?{path}&{query} }重写所有传入的URL以适应Kirby的需要。 (这可能不是最好的解决方案,但对于我的开发环境来说效果很好。)

fastcgi / 127.0.0.1:9000 php tells caddy to forward requests to a FastCGI-server. Which is, in our, case PHP.

fastcgi / 127.0.0.1:9000 php告诉球童将请求转发到FastCGI服务器。 就我们而言,这就是PHP。

Now we have two special functions.

现在,我们有两个特殊功能。

on startup launchctl load -w /Users/phaidenbauer/Library/LaunchAgents/homebrew.mxcl.php@7.2.pliston shutdown launchctl unload -w /Users/phaidenbauer/Library/LaunchAgents/homebrew.mxcl.php@7.2.plist

As I mentioned earlier it is just a MacBook Air, so I don’t want to have PHP running all the time. Especially when I don’t need it. The great thing is caddy can run commands on events. In this case, we use the startup and shutdown event to start and stop PHP. Great! No more waste of RAM and CPU while checking emails.

正如我前面提到的,它只是MacBook Air,所以我不想一直运行PHP。 特别是当我不需要它时。 很棒的事情是,球童可以在事件上运行命令。 在这种情况下,我们使用启动和关闭事件来启动和停止PHP。 大! 检查电子邮件时,不再浪费RAM和CPU。

开始整个事情:) (Start the whole thing :))

Now we are pretty much set. The last thing to do is start them all together and start working:

现在我们已经准备好了。 最后要做的是一起启动它们并开始工作:

cd /Users/phaidenbauer/development/fly.phaidenbauer.comcaddy

You should see something like this:

您应该会看到以下内容:

Activating privacy features... done.http://localhost:8080WARNING: File descriptor limit 4864 is too low for production servers. At least 8192 is recommended. Fix with `ulimit -n 8192`.

And that's it. Take your favorite browser and surf to http://localhost:8080. Depending on if you downloaded the Kirby-Plainkit or Kirby-Starter kit you should see a simple “Hello” or a simple gallery.

就是这样。 用您喜欢的浏览器浏览http:// localhost:8080 。 根据您下载的是Kirby-Plainkit还是Kirby-Starter套件,您应该看到一个简单的“ Hello”或一个简单的图库。

And that’s it. Happy hacking :)

就是这样。 快乐黑客:)

翻译自: https://www.freecodecamp.org/news/php-caddyserver-und-kirby-on-macos-96811af35394/

macos必做的设置

macos必做的设置_如何在MacOS上设置PHP,CaddyServer和Kirby —以及为什么要这样做相关推荐

  1. icloud电脑设置_如何在Android上设置iCloud电子邮件访问

    icloud电脑设置 Ben Stockton 本·斯托克顿 If you switch from iPhone to Android, you don't have to ditch iCloud ...

  2. mac网络设置_如何在Mac上设置和使用网络位置

    mac网络设置 Peter Werkman/Flickr彼得·韦尔克曼(Peter Werkman)/弗里克(Flickr) The Mac's been around so long that th ...

  3. mac 使用移动硬盘设置_如何在Mac上设置和使用照片

    mac 使用移动硬盘设置 Photos-formerly iPhoto-is macOS's default app for organizing photos. Photos integrates ...

  4. linux设置默认终端模拟器,ubuntu终端默认设置_在Ubuntu Linux上设置默认终端模拟器...

    ubuntu终端默认设置_在Ubuntu Linux上设置默认终端模拟器 ubuntu终端默认设置_在Ubuntu Linux上设置默认终端模拟器 ubuntu终端默认设置 Ubuntu has a ...

  5. shell 统计一个词出现的概率_如何在Mac上设置系统范围的字数统计服务

    在本文中,我们将向您展示如何创建系统范围的服务,使您能够在TextEdit,Safari,Mail或Mac上的任何可让您突出显示文本的应用程序中立即获得字数统计和字符计数.如果您经常发现自己粘贴到空白 ...

  6. 远程ubuntu桌面_如何在Ubuntu上设置远程桌面

    远程ubuntu桌面 J.D. Canchila/Shutterstock JD Canchila /快门 Need to get your hands on a distant Ubuntu Lin ...

  7. chromebook刷机_如何在Chromebook上设置家长控制

    chromebook刷机 Once upon a time, Chromebooks had built-in parental controls. Google removed them but a ...

  8. cardboard 效果_如何在iPhone上设置Google Cardboard

    cardboard 效果 Want to see what this VR thing is about, but don't want to plop down a bunch of cash? G ...

  9. mac 蓝牙键盘 鼠标难用_如何在Mac上设置蓝牙键盘或鼠标

    mac 蓝牙键盘 鼠标难用 Some wireless keyboards come with small dongles to plug in; some can only be set up ov ...

最新文章

  1. UBUNTU 下查看所有的C库函数和查询 LINUX 编成必备
  2. JavaScript实现euclideanDistance欧氏距离算法(附完整源码)
  3. [转载][总结]函数getopt(),getopt_long及其参数optind
  4. [NewLife.XCode]高级增删改
  5. 数学史上最简单却最复杂的公式在此
  6. Bootstrap 编译版文件结构
  7. 正则表达式学习笔记003--问号和加号的认识与应用
  8. 长语音识别_长文本语音识别_语音 识别 - 云+社区 - 腾讯云
  9. Linux安装SmartSVN及破解
  10. HDU-1394 Minimum Inversion Number 线段树+逆序对
  11. 【Web渗透测试】—Web漏洞
  12. 网络工程师中级(知识产权与标准化)
  13. 微信小程序vtabs
  14. 概率论笔记4.1.4数学期望的性质/条件期望
  15. 风儿轻轻地吹,沙儿轻轻地飘
  16. python获取涨停股票_摸索:半天完成Python获取数据,建立每日涨停股票池。
  17. 室内定位算法_【好设计论文】基于行人航迹推算的室内定位算法研究
  18. 介绍一个python工程师必须掌握的 CentOS 命令,nohup
  19. 使用ASP.NET.MVC制作手机接收验证码
  20. 导航系统中的惯性技术

热门文章

  1. MySQL—delete和truncate的区别
  2. 0407 背景相关的作业
  3. 泛型类 0104 c# 1613697523
  4. request-爬取一张图片的练习-答案-私
  5. Postgresql kill用户进程
  6. (转)如何在maven的pom.xml中添加本地jar包
  7. centos 7 firewalld 设置
  8. 【ajax】Ajax $().load() 禁用缓存
  9. 八年数据库之路的感悟
  10. Ajax表格控件实现