Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with OpenID
Advertise on LowEndTalk.com

In this Discussion

[Script] 1 Click Caddy Installer/Manager
New on LowEndTalk? Please read our 'Community Rules' by clicking on it in the right menu!

[Script] 1 Click Caddy Installer/Manager

sayem314sayem314 Member
edited August 2016 in Tutorials

Hello there,

I created a bash script that manage (start|stop|install|update|uninstall) Caddy Web Server.

This script got 24 updates till now. Still in beta. I want to make it more robust and I look forward to hear your feedback/suggestion.

To install this on your vps, run below command. Fresh OS is recommended

wget https://git.io/vra5C -O - -o /dev/null|bash

Installing 'Caddy Web Server Installer'

You have installed 'Caddy Web Server Installer'. Now It's time to run below command to install Caddy Web Server :)

caddy install

Once installed run below command to start it. Make sure your domain is pointed to your ip else you might get some error.

caddy start

I have already installed and running. I'm running reload/restart command.

Restarting Caddy

To check your 'Caddy Web Server' status run below command.

caddy

Checking Caddy status

If you want to see your current version of Caddy/Script/PHP then run below command.

caddy -v

Checking Caddy version

When 'Caddy Web Server' release an update you can update Caddy within few seconds.

caddy update

updating caddy server

After successful update. Run below command.

caddy start

If you have any question about this script ask me here :)

https://github.com/sayem314/Caddy-Web-Server-Installer

Programs must be written for people to read, and only incidentally for machines to execute.

Comments

  • Good stuff, bookmarked.

    Caddy auto starts on system boot right?

  • dailydaily Member

    The idea of making Caddy any easier blows my mind.

  • BochiBochi Member

    @TheOnlyDK said: Caddy auto starts on system boot right?

    Don't see anything in the script right now that would create an init script or such.

  • Nice. Thanks for the effort!

    Thanked by 1sayem314
  • @Bochi said: Don't see anything in the script right now that would create an init script or such.

    I mean the caddy software itself creates the auto start scripts, doesn't it? Like nginx, apache, etc all have their own built in init scripts or systemd start target (or whatever they call it..), I'm assuming the same? Maybe I will try this someday and answer my own question.

  • BochiBochi Member

    @TheOnlyDK said: I mean the caddy software itself creates the auto start scripts, doesn't it?

    Not to my knowledge, caddyserver is just a single executable - which is one of its main features I'd say.

    Thanked by 1sayem314
  • Most of you will know how to do this but I thought I'd share this anyway: https://denbeke.be/blog/servers/running-caddy-server-as-a-service-with-systemd/

    Should be pretty simple to create a bash to create some sort of installer.

    Thanked by 2TheOnlyDK sayem314
  • sayem314sayem314 Member
    edited March 2016

    @TheOnlyDK said: Good stuff, bookmarked.

    Thanks.

    Caddy auto starts on system boot right?

    Unfortunately no! Caddy is portable server. But noted, will work on that. This script still in beta, more to come :)

    I got so sick after posted this, will work on this script after I get well.

    Programs must be written for people to read, and only incidentally for machines to execute.

  • Have any of you been able to run Caddy on Windows10? I can't get it to work:(

  • BochiBochi Member

    @Straykat said: Have any of you been able to run Caddy on Windows10? I can't get it to work:(

    So, which error (message) do you get? Just tried it on a Windows 10 Pro (64bit) without any problems.

  • sayem314sayem314 Member
    edited March 2016

    @Straykat said: Have any of you been able to run Caddy on Windows10?

    Should work fine. Just tried on Windows 7, should work fine on Windows 10

    I can't get it to work:(

    Can you explain more? Any error?

    Programs must be written for people to read, and only incidentally for machines to execute.

    Thanked by 1Straykat
  • mholtmholt Member
    edited March 2016

    This is really cool - thanks for making and sharing it!

    There's also the semi-official installer script here: https://getcaddy.com/ -- should work on every platform, including Windows+cygwin (I've heard it works although I haven't tested that myself).

    We also have a few init scripts that you can use in the https://github.com/mholt/caddy/tree/master/dist/init folder.

    Thanked by 1sayem314
  • @mholt said: This is really cool - thanks for making and sharing it!

    Thank you more for creating such an amazing web server.

    There's also the semi-official installer script here: https://getcaddy.com/ -- should work on every platform, including Windows+cygwin (I've heard it works although I haven't tested that myself).

    I just heard about it now. Will check that.

    We also have a few init scripts that you can use in the https://github.com/mholt/caddy/tree/master/dist/init folder.

    I'm traveling now, I'll work on this script when I come back home.

    Programs must be written for people to read, and only incidentally for machines to execute.

    Thanked by 1mholt
  • Added support for ARM on v2.3 (beta)

    Programs must be written for people to read, and only incidentally for machines to execute.

    Thanked by 1mholt
  • @sayem314, I just deleted the dir and extracted it again and it worked fine.

    Thanked by 1sayem314
  • @sayem314 i tested on 3 vps and find php is not working, just print 502 bad gateway

    www.91yun.co | aka. 91yun.org | TOP Chinese Hosting Review site | 26k PV (3x LEB) a day | Drop me PM to submit offer.

  • @singhigh said: i tested on 3 vps and find php is not working, just print 502 bad gateway

    Should work fine. PHP is working fine on my test. What OS and virt are you using to test?

    Programs must be written for people to read, and only incidentally for machines to execute.

  • running on debian / ubuntu...

    www.91yun.co | aka. 91yun.org | TOP Chinese Hosting Review site | 26k PV (3x LEB) a day | Drop me PM to submit offer.

  • @singhigh said: running on debian / ubuntu...

    Is the domain you typed during installation pointed to your VPS IP? Was PHP installation successful? Did you tried on fresh OS? Are you using latest version (2.3 beta) of this script?

    Programs must be written for people to read, and only incidentally for machines to execute.

  • of course, but how can I check if PHP installation successful?

    www.91yun.co | aka. 91yun.org | TOP Chinese Hosting Review site | 26k PV (3x LEB) a day | Drop me PM to submit offer.

  • sayem314sayem314 Member
    edited April 2016

    @singhigh said: how can I check if PHP installation successful?

    ubuntu/debian > php5-fpm -v

    redhat/centos > php-fpm -v

    Programs must be written for people to read, and only incidentally for machines to execute.

  • i checked it is installed well

    www.91yun.co | aka. 91yun.org | TOP Chinese Hosting Review site | 26k PV (3x LEB) a day | Drop me PM to submit offer.

  • sayem314sayem314 Member
    edited April 2016

    Edit line 212 on '/etc/php5/fpm/php.ini' and change Etag off to on

    then restart php fpm

    Programs must be written for people to read, and only incidentally for machines to execute.

    Thanked by 1singhigh
  • singhighsinghigh Member
    edited April 2016

    hey, still not working, 502 Bad Gateway and my line 212 is a line with ";", not for settings.

    www.91yun.co | aka. 91yun.org | TOP Chinese Hosting Review site | 26k PV (3x LEB) a day | Drop me PM to submit offer.

  • @singhigh said: hey, still not working, 502 Bad Gateway and my line 212 is a line with ";", not for settings.

    Share me your Caddyfile and php5-fpm.ini on PM. Upload to pastebin plz

    Programs must be written for people to read, and only incidentally for machines to execute.

  • sayem314sayem314 Member
    edited August 2016

    version 3.4 released. not very far to stable version :)

    -Added process uptime feature

    -Fixed mixed output of fixphp

    -Fixed minor update issue

    -Fixed restart issue

    -Fixed pidfile issue for init

    N.B: Post has been updated.

    Programs must be written for people to read, and only incidentally for machines to execute.

  • doughnetdoughnet Member
    edited August 2016

    I installed using the script then did the nice and simple: caddy service command but it unfortunately is not adding the startup script. Ideas?

    Debian 8 64bit

    It starts fine with caddy restart or start though.

    EDIT Seems that when I do the command: caddy service it will completely stop working and won't even start back up again. Any ideas?

  • @doughnet said: I installed using the script then did the nice and simple: caddy service command but it unfortunately is not adding the startup script. Ideas?

    Debian 8 64bit

    It starts fine with caddy restart or start though.

    EDIT Seems that when I do the command: caddy service it will completely stop working and won't even start back up again. Any ideas?

    For the moment service is not working as expected. That's why I haven't done it by default. I'd release improved service. For now, disable service. Start manually.

    rm /etc/init/caddy.conf systemctl disable caddy rm /etc/systemd/system/caddy.service

    Then reboot or restart caddy :)

    Programs must be written for people to read, and only incidentally for machines to execute.

  • Okay thanks.

    Is it possible to setup my own script then or will it break the caddy web server still?

  • sayem314sayem314 Member
    edited August 2016

    @doughnet said: Okay thanks.

    Is it possible to setup my own script then or will it break the caddy web server still?

    No. It's possible :)

    BTW, v3.5 released :)

    Added support for Ubuntu 16.04 and 16.10

    Changed service type

    Fixed php7.0 issue

    Added support to restart php along with caddy

    Fixed some error output when installing on CentOS

    @doughnet new service type added to /etc/init.d delete previous service and run 'caddy service' now. reboot and see if it works :)

    Programs must be written for people to read, and only incidentally for machines to execute.

  • @sayem314

    Thank you very much for the update. Removing the service files then upgrading was successful for a bit but then after rebooting it would not come back up again. I did a fresh install with Debian 7 and was able to get it working properly and easily. Seems Debian 8 is being picky with it's services.

  • sayem314sayem314 Member
    edited August 2016

    @doughnet said: Thank you very much for the update.

    :)

    Removing the service files then upgrading was successful for a bit but then after rebooting it would not come back up again.

    Working perfect for me. Till now Tested Operating System is:

    -Ubuntu - 14.04, 14.10.15.04, 16.04.1

    -Debian - 7.11, 8.5

    -CentOS - 6.8 and 7.2

    I did a fresh install with Debian 7 and was able to get it working properly and easily. Seems Debian 8 is being picky with it's services.

    I have tested on Debian 8.5 and it appears service is working perfectly for me. I did power off and power on also reboot, and it's working perfect every time. You might wanna check on fresh install. Probably previously created service was conflicting.

    Programs must be written for people to read, and only incidentally for machines to execute.

    Thanked by 1inthecloudblog
  • Any chance on having an easy method to include plugins?

  • @doughnet said: Any chance on having an easy method to include plugins?

    Not yet. But I'll think about it :)

    Programs must be written for people to read, and only incidentally for machines to execute.

  • Any ideas on why the caddy status command does not work on Debian 7 (fresh install).

    `[email protected]:~# caddy restart

    Shutting down Caddy Web Server... DONE

    Starting Caddy Web Server... DONE [ ok tarting php5-fpm...[....] Reloading PHP5 FastCGI Process Manager: php5-fpm.

    [email protected]:~# caddy status /usr/local/bin/caddy: line 114: [[: 1.00056e+14: syntax error: invalid arithmetic operator (error token is ".00056e+14") /usr/local/bin/caddy: line 116: [[: 1.00056e+14: syntax error: invalid arithmetic operator (error token is ".00056e+14") /usr/local/bin/caddy: line 118: [[: 1.00056e+14: syntax error: invalid arithmetic operator (error token is ".00056e+14") /usr/local/bin/caddy: line 121: 1.00056e+14: syntax error: invalid arithmetic operator (error token is ".00056e+14")

    Caddy Web Server is running Caddy (PID: 4951) is using 12MB RAM System free RAM 1.6GB Uptime -

    [email protected]:~# `

    Also, in theory is it possible to change the wget command from caddyserver.com to always include all the middleware/directives & DNS Providers? Example Link: https://caddyserver.com/download/build?os=linux&arch=amd64&features=filemanager,git,hugo,ipfilter,jwt,locale,mailout,minify,prometheus,ratelimit,realip,search,cloudflare,digitalocean,dnsimple,dyn,gandi,googlecloud,namecheap,rfc2136,route53,vultr

  • sayem314sayem314 Member
    edited August 2016

    @doughnet working fine here on fresh Debian 7.11 x64

    512M VPS / DO

    About DNS challenge, I would say you edit the caddy script and create your custom Caddyfile.

    Programs must be written for people to read, and only incidentally for machines to execute.

  • Unsure why you are not having the same issue I am. Did a fresh install on Digital Ocean, ran caddy script ... get the same results.

    Seems its known that should be using bc for floating point arithmetic in bash. http://stackoverflow.com/questions/5040784/error-in-bash-script-arithmetic-syntax

  • Would it be possible to integrate a "caddy reload" so it does a USR1 signal to reload the configuration file, then gracefully restarts the server. This will help from a bad configuration file causing all the sites to go down.

    Link with details: https://forum.caddyserver.com/t/how-to-have-bad-domain-in-config-skipped/513/2

    MERCI!

  • sayem314sayem314 Member
    edited August 2016

    @doughnet said: Would it be possible to integrate a "caddy reload" so it does a USR1 signal to reload the configuration file, then gracefully restarts the server. This will help from a bad configuration file causing all the sites to go down.

    Thanks! Sounds good! Expect this on next and first stable version :)

    Programs must be written for people to read, and only incidentally for machines to execute.

  • @sayem314 Do you think can you update the script? :)

    RC5 cracker since 1998!

  • graphicgraphic Member

    Caddy easier than easy? Sounds nearly impossible.

    End-to-end encrypted cloud storage, this link gives you 6gb free storage and me +1gb extra storage : sync.com

    Thanked by 1sayem314
  • sayem314sayem314 Member

    @Anna_Parker said: @sayem314 Do you think can you update the script? :)

    The script is working fine ✅ Why break something that is working fine

    Programs must be written for people to read, and only incidentally for machines to execute.

    Thanked by 1Saragoldfarb
  • @sayem314 You've right, it works! After debugging, just edited your script and had to add to wget the --no-check-certificate parameter. It's needed on Debian Stretch's wget. Cheers.

    RC5 cracker since 1998!

  • joepie91joepie91 Member, Provider
    edited May 17

    @Anna_Parker said: @sayem314 You've right, it works! After debugging, just edited your script and had to add to wget the --no-check-certificate parameter. It's needed on Debian Stretch's wget. Cheers.

    Adding that parameter essentially disables TLS validation, which means you don't have any assurances that you're getting a legitimate binary - you've essentially disabled TLS' security. This is a serious security issue.

    The correct solution is to ensure that you have CA root certificates installed on your server, eg. by installing the ca-certificates bundle.

    Thanked by 3sayem314 teamacc Tom
  • joepie91 said: The correct solution is to ensure that you have CA root certificates installed on your server, eg. by installing the ca-certificates bundle.

    Thanks, but the thing is I already have installed ca-certificates bundle (Debian Stretch). And it doesn't help.

    RC5 cracker since 1998!

  • joepie91joepie91 Member, Provider

    @Anna_Parker said:

    joepie91 said: The correct solution is to ensure that you have CA root certificates installed on your server, eg. by installing the ca-certificates bundle.

    Thanks, but the thing is I already have installed ca-certificates bundle (Debian Stretch). And it doesn't help.

    Then you should probably look into why it's failing, because there's no reason for it to fail if you have ca-certificates installed. The obvious possibility is that somebody really is MITMing your connection, in which case you definitely don't want to ignore that error.

  • @joepie91 Tested on two providers with absolutely fresh Debian 9 Stretch x64 templates. I don't think so that reputable providers from here are doing MITM. :)))

    RC5 cracker since 1998!

    Thanked by 1sayem314
  • jarlandjarland Provider

    @joepie91 said:

    @Anna_Parker said:

    joepie91 said: The correct solution is to ensure that you have CA root certificates installed on your server, eg. by installing the ca-certificates bundle.

    Thanks, but the thing is I already have installed ca-certificates bundle (Debian Stretch). And it doesn't help.

    Then you should probably look into why it's failing, because there's no reason for it to fail if you have ca-certificates installed. The obvious possibility is that somebody really is MITMing your connection, in which case you definitely don't want to ignore that error.

    Yeah this fails on legitimate and up to date distros without MITM and I've never cared enough to find out why since I really don't care about secure inbound transfer of publicly available data as long as I can reasonably check that it wasn't altered in transit.

    Maybe time for one of us to stop being lazy and find out why though. Good challenge.

    Thanked by 1Anna_Parker
  • DewlanceVPSDewlanceVPS Member, Provider

    Anyone is using Caddy server?
    Your review on caddy server and experience?

    Cheap $9/Year Hosting(US/UK/Canada/ES) - Cheap Windows VPS Hosting from Dewlance & Linux Xen VPS at low price. PreMadeKb.com WHMCS/Blesta Readymade Knowledgebase
Sign In or Register to comment.