{"id":23,"date":"2020-08-23T00:53:11","date_gmt":"2020-08-23T05:53:11","guid":{"rendered":"https:\/\/sourceopen.com\/?p=23"},"modified":"2020-08-23T16:31:29","modified_gmt":"2020-08-23T21:31:29","slug":"fix-file-not-found-with-php-on-openbsd-httpd","status":"publish","type":"post","link":"https:\/\/sourceopen.com\/index.php\/fix-file-not-found-with-php-on-openbsd-httpd\/","title":{"rendered":"Fix &#8220;File Not Found&#8221; with PHP on OpenBSD httpd"},"content":{"rendered":"\n<p>When setting up my WordPress site on OpenBSD 6.7 using this <a rel=\"noreferrer noopener\" href=\"https:\/\/www.vultr.com\/docs\/running-wordpress-on-openbsd-6-6-with-openbsd-s-httpd\" target=\"_blank\">nice tutorial<\/a> I ran into an error during installation of PHP. Every time I tried to load a .php page all I got was a message saying:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>File not found.<\/code><\/pre>\n\n\n\n<p>Not very informative at all! But I guess this goes along with the security consciousness of OpenBSD&#8211; an information leak could be used in nefarious ways. It turns out I had chosen a different chroot directory for my httpd web server, rather than the default \/var\/www. When configuring php-fpm I did not edit enough of the config file.<\/p>\n\n\n\n<p>You see php-fpm communicates with httpd via a unix domain socket. That socket need to be accessible by the webservers AFTER is has chroot-ed into the web directory. So in my httpd.conf I have something like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> location \"*.php*\" {\n            fastcgi socket \"\/run\/php-fpm.sock\"\n    }<\/code><\/pre>\n\n\n\n<p>This means that httpd should send php requests to php-fpm through the socket at \/run\/php-fpm.sock. This path is relative to the chroot directory of the web server. So I needed to edit my \/etc\/php-fpm.conf file to change the chroot directive to point to MY custom chroot directory for my httpd server, rather than to the default one:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;snip other config stuff>\n...\n; Chroot to this directory at the start. This value must be defined as an\n; absolute path. When this value is not set, chroot is not used.\n; Note: you can prefix with '$prefix' to chroot to the pool prefix or one\n; of its subdirectories. If the pool prefix is not set, the global prefix\n; will be used instead.\n; Note: chrooting is a great security feature and should be used whenever\n;       possible. However, all PHP paths will be relative to the chroot\n;       (error_log, sessions.save_path, ...).\n; Default Value: not set\nchroot = \/&lt;my>\/&lt;chroot>\/&lt;path>\n<\/code><\/pre>\n\n\n\n<p>Now I could get php to work and a simple:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> &lt;?php phpinfo(); ?><\/code><\/pre>\n\n\n\n<p>page would work just fine! For the record this was PHP-7.4.x with php-frm on OpenBSD 6.7 using the build in httpd.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When setting up my WordPress site on OpenBSD 6.7 using this nice tutorial I ran into an error during installation of PHP. Every time I tried to load a .php page all I got was a message saying: Not very &hellip; <a href=\"https:\/\/sourceopen.com\/index.php\/fix-file-not-found-with-php-on-openbsd-httpd\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[22,4,7,2,17,21,20,19],"_links":{"self":[{"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/posts\/23"}],"collection":[{"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":3,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":37,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/posts\/23\/revisions\/37"}],"wp:attachment":[{"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sourceopen.com\/index.php\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}