CADDY

Testing Sequential Write Speed 
$ dd if=/dev/zero of=/tmp/tempfile bs=1M count=1024 conv=fdatasync
Testing Sequential Read Speed
$ sudo sh -c "/usr/bin/echo 3 > /proc/sys/vm/drop_caches"
$ dd if=/tmp/tempfile of=/dev/null bs=1M count=1024

$ lsb_release -a //current Debian version OR  $ cat /etc/debian_version
$ cat /proc/cpuinfo
$ sudo dpkg --configure -a
$ sudo nano /etc/hosts
$ sudo hostnamectl set-hostname new-one
$ newgrp

$ apt-get update --allow-releaseinfo-change -y
$ apt-get install --reinstall ca-certificates -y
$ apt-get upgrade -y
$ apt-get install nano wget curl perl sudo -y
$ sudo apt -y dist-upgrade
$ sudo apt --purge autoremove -y
$ sudo apt update && sudo apt upgrade -y
$ apt -y purge Apache2* bind* exim* ufw firewalld libapache2-mod-php*

================MySql==========================================
$ apt install -y mariadb-server mariadb-client
$ systemctl status mariadb
$ mariadb_secure_installation
$ mysql -u root -p
--Enter password:
Maria DB [(none)]>
> CREATE DATABASE rome;
> CREATE USER 'user_name'@localhost IDENTIFIED BY 'password';
> GRANT ALL PRIVILEGES ON *.* TO 'db_name'@localhost IDENTIFIED BY 'password';
> FLUSH PRIVILEGES;
> SHOW GRANTS FOR 'db_name'@localhost;
> SHOW DATABASES;
> Exit;

==========Install PHP==================
$ sudo apt -y install php software-properties-common libmcrypt-dev libreadline-dev mcrypt
$ sudo apt -y install php-common php-mysql php-xml php-xmlrpc php-curl php-gd php-imagick php-cli php-fpm php-json php-imap php-mbstring php-opcache php-soap php-dev php-cgi php-zip php-intl php-bcmath php-pear

apt -y purge Apache2* bind* exim* ufw firewalld libapache2-mod-php*

========Install Webmin===============
$ curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh
$ sh setup-repos.sh
$ apt -y install webmin --install-recommends
( change port: $ sudo nano -w /etc/webmin/miniserv.conf )

==============Install Caddy=========================
$ sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
$ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
$ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
$ chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg
$ chmod o+r /etc/apt/sources.list.d/caddy-stable.list
$ sudo apt update
$ sudo apt install caddy

$ sudo systemctl enable --now caddy
$ sudo systemctl status caddy
Open http://i.p in your browser 

apt -y purge Apache2* bind* exim* ufw firewalld libapache2-mod-php*

=========Making Website==================

$ sudo mkdir /usr/share/caddy/domain1
$ nano /usr/share/caddy/domain1/index.php

Working with CaddyFile
$ nano /etc/caddy/Caddyfile    //caddyfile holds all the domain info.
===========Very Basic cong. ==============================
:80 {
    root * /usr/share/caddy
    file_server
    # reverse_proxy localhost:8080
    # php_fastcgi localhost:9000
}

$ systemctl reload caddy
==============OR with fpm=======================
domain:80 {
    tls xxx@xxx.com
    root * /usr/share/caddy/domain1
    file_server
    encode zstd gzip
    php_fastcgi unix//run/php/php8.2-fpm.sock
    log {
        output file /var/log/caddy/access.log
        format console
    }
}
==========Use as proxy server===========================
domain:80 {
    tls xxx@xxx.com
    /usr/share/caddy/domain1
    file_server
    encode zstd gzip
    reverse_proxy localhost:3000
    log {
        output file /var/log/caddy/access.log
        format console
    }
}
$ sudo systemctl restart caddy

=============Install Adminer on Debian=============
$ sudo mkdir /usr/share/caddy/adminer
$ sudo wget https://www.adminer.org/latest.php -O /usr/share/caddy/adminer/index.php
$ sudo mysql
$ SET PASSWORD FOR 'root'@'localhost' = PASSWORD("my-password");
$ FLUSH PRIVILEGES;
$ exit;
Option://$ sudo ufw allow from any to any port 8070 proto tcp
$ sudo nano /etc/caddy/Caddyfile
:8070 {   
        root * /usr/share/caddy/adminer
        encode gzip zstd
        php_fastcgi unix//run/php/php7.4-fpm.sock

        # Enable the static file server.
        file_server
}
$ sudo systemctl restart caddy
http://i.p:8070

Important ! ==========Enabling Automatic HTTPS===========
In the first line of the Caddyfile, you specify the domains that Caddy should manage.
example.com:80 {
    tls email@example.com
    root * /var/www/html
    file_server
}
tls email@example.com indicates to Caddy that it should use Let's Encrypt to secure
domain using the provided email address for notifications.


Posted : Thursday 27th of August 2015 @ 11:46 AM— Tags : caddy