{"id":313,"date":"2022-09-27T09:13:37","date_gmt":"2022-09-27T07:13:37","guid":{"rendered":"https:\/\/blog.remyblom.nl\/?p=313"},"modified":"2022-09-28T11:51:15","modified_gmt":"2022-09-28T09:51:15","slug":"nginx-on-macos","status":"publish","type":"post","link":"https:\/\/blog.remyblom.nl\/?p=313","title":{"rendered":"Nginx on macOS"},"content":{"rendered":"\n<p>I once was quite ready with every major update of macOS ruining my apache setup. So I decided to install nginx. Besides, it is by far the better webserver of the two, so that is a win-win!<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"512\" src=\"https:\/\/blog.remyblom.nl\/wp-content\/uploads\/2022\/09\/nginx.png\" alt=\"\" class=\"wp-image-323\" srcset=\"https:\/\/blog.remyblom.nl\/wp-content\/uploads\/2022\/09\/nginx.png 1024w, https:\/\/blog.remyblom.nl\/wp-content\/uploads\/2022\/09\/nginx-300x150.png 300w, https:\/\/blog.remyblom.nl\/wp-content\/uploads\/2022\/09\/nginx-768x384.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>First install Homebrew:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ \/bin\/bash -c \"$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/HEAD\/install.sh)\"<\/code><\/pre>\n\n\n\n<p>The installer will ask you to run some commands, make sure not to miss them. Then install nginx:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ brew install nginx<\/code><\/pre>\n\n\n\n<p>After that start nginx as a service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ brew services start nginx<\/code><\/pre>\n\n\n\n<p>After that I create symlinks so I can just find the documentroot at <code>\/var\/www<\/code> and the config at<code> \/etc\/nginx<\/code> <\/p>\n\n\n\n<p>In the <code>nginx.conf<\/code> make sure to run the webserver as you:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>user remy staff;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">What is a webserver without PHP?<\/h2>\n\n\n\n<p>Okay, call me old-school, but I still do a LOT with PHP, so let&#8217;s brew up some PHP-foo while we&#8217;re at it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ brew install php<\/code><\/pre>\n\n\n\n<p>In <code>\/opt\/homebrew\/etc\/php\/8.1\/php-fpm.d\/www.conf<\/code> specify fpm to run as you and listen to a socket file, rather than a port: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>user = remy\ngroup = staff\nlisten = \/opt\/homebrew\/var\/run\/php-fpm.sock<\/code><\/pre>\n\n\n\n<p>And make sure nginx is configured to forward php to the same socket.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>upstream phpfpm {\n\tserver unix:\/opt\/homebrew\/var\/run\/php-fpm.sock;\n}<\/code><\/pre>\n\n\n\n<p>This should do it&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I once was quite ready with every major update of macOS ruining my apache setup. So I decided to install nginx. Besides, it is by far the better webserver of the two, so that is a win-win! First install Homebrew: The installer will ask you to run some commands, make sure not to miss them. &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.remyblom.nl\/?p=313\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Nginx on macOS&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-313","post","type-post","status-publish","format-standard","hentry","category-config"],"_links":{"self":[{"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=\/wp\/v2\/posts\/313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=313"}],"version-history":[{"count":5,"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=\/wp\/v2\/posts\/313\/revisions"}],"predecessor-version":[{"id":324,"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=\/wp\/v2\/posts\/313\/revisions\/324"}],"wp:attachment":[{"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.remyblom.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}