These are also the default settings for the php preset. php in the PATH_INFO CGI variable(split), and check for index.php if no file is specified in the URL(index). php extension use fastcgi proxy(ext), store anything after. The breakdown for each option is: If the requested file has the. If you need to configure your php settings with more granularity, you can use the fastcgi directive in the following way. First it directs all requests from the root of your site to the php-fpm socket using the php preset: fastcgi / /var/run/php5-fpm.sock php This tells Caddy how to talk to your php5-fpm service. Set your error log: errors /var/log/caddyerror.log Set your access log: log /var/log/caddyaccess.log You can set more specific options, like file types or compression level, but for this example, default settings are fine: gzip This tells Caddy to enable gzip compression with default values. This is the docroot where our php and html files will go: root /opt/caddywww This is a very cool feature, but for the purposes of this demo, I’m leaving it out. I’m putting this here, because Caddy will automatically setup a certificate with Let’s Encrypt if you use a valid and registered domain name for your site. The following tells Caddy to disable serving sites over TLS. Any other request using a different hostname would receive an error from Caddy. If you want to lock it to a virtual host definition you would simply change this to the following, which will tell Caddy to only answer if port 80 was accessed using. This line tells Caddy to answer on port 80, no matter how it’s called. Let’s sidetrack for a minute, and discuss the Caddyfile and each of the directives, to briefly explain what they mean. The documentation makes it easy to reference the functionality you’re looking for. Once you’ve configured a few options in a Caddyfile, you’ll get the hang of it pretty fast. If you’re used to configuring Nginx or Apache, the format of this file will look unfamiliar. A Caddyfile is Caddy’s configuration file. FPM stands for FastCGI Process Manager FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features (mostly) useful for heavy-loaded sites. Once you’ve downloaded the Caddy binary, extract it: sudo mkdir /opt/caddy-server sudo tar xvzf caddy_linux_amd64_ -C /opt/caddy-serverĬreate the docroot we’ll be using for this example, and give yourself perms to write to it: sudo mkdir /opt/caddywww sudo chown `whoami` /opt/caddywww What is PHP-FPM According to the official article on PHP website. Open a terminal on your Ubuntu 14.04 server or desktop and install php, php-fpm, and curl: sudo apt-get install php5-fpm php5-cli curl I encourage you to follow along in your own dev environment. I’ll be configuring Caddy to use php-fpm. In this post I want to cover how to setup the Caddy web server to serve PHP pages. The project offers a lightweight, powerful web server aimed at lowering the technical barrier to entry for just about anyone wanting to serve content from a self hosted web server. In case you missed it, you can catch it here. A month ago I wrote about an exciting open source project called Caddy.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |