Home Server Cara Menginstall Caddy Webserver di Centos 7

Cara Menginstall Caddy Webserver di Centos 7

Cara Menginstall Caddy Webserver di Centos 7
Cara Menginstall Caddy Webserver di Centos 7
Cara Menginstall Caddy Webserver di Centos 7

Content IDCara Menginstall Caddy Webserver di Centos 7. Kali ini Content.id akan mencoba Caddy sebagai webserver. Caddy adalah salah satu light web server besutan Matthew Holt. Caddy merupakan webserver baru yang banyak menarik peminat dengan berbagai feature unik yang menarik, Berikut beberapa feature yang diberikan oleh Caddy Webserver:

  • Secure by Default. Caddy is the only web server that uses HTTPS by default. A hardened TLS stack with modern protocols preserves privacy and exposes MITM attacks.
  • No Dependencies. Written in Go, Caddy binaries are entirely self-contained and run on every platform, including containers. You don’t even need libc.
  • Easy on Beginners. Caddy’s audience ranges from new site developers to seasoned professionals because simple configuration helps you get things done faster.
  • Production-Ready. Caddy is the real deal: a robust web server that is trusted in production environments for thousands of sites.
  • THE CADDYFILE An easy, intuitive way to configure your site. It’s not scripting, and not hard to memorize. Rolls off the fingers. You’ll really like it.
  • CROSS-PLATFORM Windows, macOS, Linux, BSD, Android, Solaris, 32-bit, x64, ARM, mips64… you name it: Caddy probably compiles for it.
  • HTTP/2 It’s time for a faster web. Caddy uses HTTP/2 right out of the box. No thought required. HTTP/1.1 is still used when clients don’t support HTTP/2.
  • Reverse Proxy Caddy can act as a reverse proxy for HTTP requests. You can also proxy transparently (preserve the original Host header) with one line of config.

Pre Instalasi:

Step 1 — Installing the Caddy Binaries

Untuk menjalankan wordpress sobat harus menginstall webserver (caddy) MySQL dan PHP. Untuk langkah awal dalam menjalankan wordpress dengan menggunakan Caddy Webserver di CentOS 7 adalah dengan menginstall Caddy. Berikut langkah menginstall Caddy:

1. Jangan lupa login ke vps
2. Jalankan update dan upgrade jika vpsnya masih Fresh dengan menjalankan perintah yum -y update && upgrade

yum -y update && upgrade
[[email protected] ~]# yum -y update
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror.sfo12.us.leaseweb.net
 * extras: mirror.sfo12.us.leaseweb.net
 * updates: mirror.sfo12.us.leaseweb.net
base                                                     | 3.6 kB     00:00
extras                                                   | 3.4 kB     00:00
updates                                                  | 3.4 kB     00:00

3. Install Caddy webserver

curl https://getcaddy.com | bash -s personal

Hasil Output installasi Caddy di CentOS 7

[[email protected] ~]# curl https://getcaddy.com | bash -s personal
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7380  100  7380    0     0  63428      0 --:--:-- --:--:-- --:--:-- 63620
Downloading Caddy for linux/amd64 (personal license)...
Download verification OK
Putting caddy in /usr/local/bin (may require password)
Caddy 0.11.0 (non-commercial use only)
Successfully installed
[[email protected] ~]#

Step 2 — Creating the User and Group for Caddy

4. Tambahkan user dan group caddy

adduser -r -d /var/www -s /sbin/nologin caddy

Step 3 — Setting Up Necessary Directories

5. Buat directory untuk file configurasi caddy

mkdir /etc/caddy

6. Ubah kepemilikan directory /etc/caddy

chown -R root:caddy /etc/caddy

7. Buat file configurasi webserver caddy dan akan kita edit nanti

touch /etc/caddy/Caddyfile

8. Buat directory untuk konfigurasi SSL Caddy

mkdir /etc/ssl/caddy

9. Ubah kepemilikan directory /etc/ssl/caddy

chown -R root:caddy /etc/ssl/caddy

10. Ubah permisi folder agar hanya bisa di akses oleh root

chmod 0770 /etc/ssl/caddy

11. Buat direktory untuk file website

mkdir /var/www

12. Ubah kepemilikan directory /var/www agar bisa di akses oleh caddy

chown caddy:caddy /var/www

Step 4 — Installing Caddy as a System Service

13. Jalankan perintah berikut agar caddy webserver dapat berjalan secara otomatis ketika booting dan berjalan sebagai system

curl -s https://raw.githubusercontent.com/mholt/caddy/master/dist/init/linux-systemd/caddy.service -o /etc/systemd/system/caddy.service

14. Edit file yang sudah di download untuk merubah agar caddy berjalan sebagai caddy:caddy

vi /etc/systemd/system/caddy.service
; User and group the process will run as.

15. User dan Group www-data dirubah menjadi caddy

; User and group the process will run as.

16. Reload Daemon

systemctl daemon-reload

17. Enable caddy sebagai service

systemctl enable caddy.service

18. Check status caddy apakah sudah berjalan atau tidak

systemctl status caddy.service
● caddy.service - Caddy HTTP/2 web server
   Loaded: loaded (/etc/systemd/system/caddy.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: https://caddyserver.com/docs

Step 5 — Creating a Test Web Page and a Caddyfile

Untuk mengetes apakah caddy sudah berjalan di VPS Centos 7 ada baiknya kita test menggunakan static html

19. Buat file html untuk melakukan test caddy

echo '<h1>Hello World!</h1>' | sudo tee /var/www/index.html

20. Edit file configurasi caddy

vi /etc/caddy/Caddyfile
http:// {
    root /var/www

21. Start caddy webserver

sudo systemctl start caddy

22. Server Caddy sudah terinstall dan dapat diakses di http://ip-address/

Previous articleBagaimana Kita Mencerna Makanan? Perjalanan Makanan di Tubuh Kita
Next articleCara Menginstall MariaDB di Centos 7
Content.id adalah media belajar bersama untuk membangun negerisalam https://content.id


Please enter your comment!
Please enter your name here