TITLE Caddy Command Prompt
ECHO Shuting down CADDY and subprocesses if running.
taskkill /IM caddy.exe /f /t
ECHO Starting CADDY .
REM PHP FastCGI on windows by default stops after 500 requests due to memory and reliability, but does not restart.
REM Setting PHP_FCGI_MAX_REQUESTS to 0 prevents this behaviour, but you must set a task to restart entire process set periodically
set PHP_FCGI_MAX_REQUESTS=0
:start
REM loop to restart - http://stackoverflow.com/a/34458348/6244
REM Whenever caddy is killed (by the other script, should restart automatically.)
ECHO ReStarting Caddy after shutdown
Echo Restarting Caddy after Shutdown >> c:\logs\filerestarts.txt
date /t >> c:\logs\filerestarts.txt
time /t >> c:\logs\filerestarts.txt
date /t
time /t
goto start
Dont work.
logs
2018/11/02 09:13:11 [INFO] Certificate for mysite. example. com is already being obtained elsewhere and stored; waiting
2018/11/02 09:13:50 [INFO] Certificate for mysite. example. com is already being obtained elsewhere and stored; waiting
So logs ok?
__
I am php web developer and easy configure a web server on Linux. Every day I use Open Server, XAMMP, Denver e.t.c. And caddy… Any official instructions? Manual? Documentation?
Caddy seems to think that another Caddy instance using the same file system is in the middle of certificate acquisition, and is waiting for it to finish.
Unless you’re trying to run Caddy in a fleet configuration, my guess is that you killed the Caddy process in the middle of a HTTP validation attempt.
I believe that Caddy puts down lock files during the challenge-response process that you’ll need to delete.
Before doing that, though, it’s worth changing all the site labels in your Caddyfile to HTTP-only, starting Caddy, and verifying that your sites work fine for when we fix the issue caused by the interrupted certificate requisitioning.
It looks like you’re trying to acquire certificates for the literal FQDN test.example.com.
Unless you actually own that domain, and can rectify the fact that it has no DNS A records by pointing it at your own server, Caddy will never be able to acquire a HTTPS certificate from LetsEncrypt for it.
I suggest disabling HTTPS entirely for that site, because as long as Caddy can’t do what you’ve configured it to do, it will give you the error and exit instead of launching.
Run.
Logs:
2018/11/02 11:08:32 http://test.example.com
2018/11/02 11:08:32 [INFO] Nonblocking Command “C:\caddy\php\php-cgi.exe -b 6545” with ID 85c3c4d1-4285-451b-bf0e-cc49772b2172
Try in browser http://test.example.com Browser “error” No ip for such site…etc.
Try 127.0.0.1
404 Site 127.0.0.1 is not served on this interface
localhost?
2018/11/02 11:09:22 [INFO] 127.0.0.1 - No such site at :80 (Remote: 127.0.0.1, Referer: )
Browsing to http://test.example.com will naturally fail unless you control the responding DNS server and respond to queries for that domain with the IP address of your own server.
127.0.0.1 and localhost will both fail because your browser signals to the HTTP server what site you’re asking for, but neither match the hostname you specified in the Caddyfile, which is test.example.com.
I don’t know how to do this on a Windows shell off the top of my head, but you could get around it by making a request to your server and manually specifying the hostname. curl -H "Host:test.example.com" http://localhost/ would do this on Linux.
I have a very simple setup which I usually take along and use everywhere.
I have a caddy.exe lying in the same file as the bats and subfolders for the PHP versions.
caddy.bat caddy -conf="caddyconf.txt"
(I just prefer my caddyfile having a txt ending so I dont need to select an editor all the time)
php73.bat PHP73\php-cgi.exe -b 127.0.0.1:9000
(obviously my caddyfile has fastcgi / 127.0.0.1:9000 php)
you also can turn this into a one bat only setup when you let caddy start PHP with on startup in your caddyfile, although the current setup allows you to swap PHP versions just by closing one php bat and starting another which is a real godsend when trying for multiple PHP versions.