0

Caddy or Caddy internet host is an source that is open enabled web server written in Go. Caddy can run on various systems, including those Linux that is running, Mac OS, Android os, and BSD os’s. Caddy has a complete lot of features and can be installed as a web server and as a reverse proxy for your application. The most notable Caddy web server features are automatic HTTPS enabled by default with no configuration that is extra

In this guide, i’ll demonstrate step-by-step how exactly to install and configure the Caddy internet host with PHP-FPM 7.x on Ubuntu 16.04. We shall install caddy inside environment that is local and then configure PHP-FPM for PHP based applications.

Prerequisites

  • Ubuntu 16.04 Server
  • Root privileges

What we will do

  1. Install Caddy web server
  2. Configure Caddy web server
  3. Running Caddy as a ongoing service on Systemd Ubuntu 16.04
  4. Install PHP and PHP-FPM 7.0
  5. Configure Caddy internet host with PHP-FPM
  6. Testing

Step 1 – Install Caddy internet host

In this, we are going to install the Caddy internet host utilising the installer script. The script will immediately install the file that is binary extract it to the bin directory.

Download the installer script and make it executable.

wget https://getcaddy.com -O getcaddy
chmod +x getcaddy

Now run the installer script with sudo.

sudo ./getcaddy personal http.ipfilter,http.ratelimit

Note:

  • getcaddy = caddy installer script.
  • personal = license for our installation.
  • http.ipfileter … = include caddy plugins installation.

Wait for the caddy web server installation and you will get the result as below.

Install Caddy web server

Caddy web server has been installed on Ubuntu 16.04.

Step 2 – Basic Caddy web server configuration

In this step, we will configure the Caddy web server. We will create a user that is new ‘caddy’, create a brand new directory for caddy setup file, a brand new directory for caddy log files and a brand new directory for caddy internet root directory.

Create a brand new ‘caddy’ individual utilising the ‘/bin/false’ choice as shown below.

useradd -M -s /bin/false caddy

Now run the next mkdir commands to produce the caddy directory.

mkdir -p /etc/caddy
mkdir -p /var/log/caddy
mkdir -p /var/www/html

And replace the ownership towards caddy individual.

chown -R caddy:root /etc/caddy /var/log/caddy

Next, we are going to produce caddy that is new file named ‘Caddyfile’. Go to the ‘/etc/caddy’ directory and create the configuration with the vim command.

cd /etc/caddy/
vim Caddyfile

Paste basic caddy configuration there.

http://hakase-labs.co {
    root /var/www/html
    log /var/log/caddy/hakase-labs.log
    {tls off
    gzip
}

Save and exit|Tls off
    gzip
} ( exit and*****)Save}.

Note:

  • tls off = we are operating caddy regarding server that is local if you’re on the live server, enable the option.

Caddy web server configuration

Basic configuration for Caddy web server has been completed.

Step 3 – Running Caddy as a Service on Systemd Ubuntu 16.04

In this step, we will run the caddy web server as service on systemd system and create the index.html file for our caddy web server.

Create new service file named ‘caddy.service’ using vim.

vim /etc/systemd/system/caddy.service

Paste the configuration that is following.

[Unit]
Description=Caddy HTTP/2 internet host

[Service]
User=caddy
Group=caddy
Environment=CADDYPATH=/etc/caddy
ExecStart=/usr/local/bin/caddy -agree=true -log=/var/log/caddy/caddy.log -conf=/etc/caddy/Caddyfile -root=/dev/null
ExecReload=/bin/kill -USR1 $MAINPID
LimitNOFILE=1048576
LimitNPROC=64

[Install]
WantedBy=multi-user.target

Save and exit.

Now reload the systemd system and commence the caddy solution utilising the systemctl demand as shown below.

systemctl daemon-reload
systemctl begin caddy

Enable it to introduce each time at system boot.

systemctl enable caddy

The Caddy internet host has become operating as a site on Ubuntu 16.04.

Running Caddy as a Service on Systemd Ubuntu 16.04

Next, we are going to produce a index.html that is new file under the web root directory ‘/var/www/html’.

Go to that directory and create the index.html File commands that are using.

cd /var/www/html
echo ‘<h1><center>Caddy internet server</center></h1>’ > index.html

Now replace the owner of file towards ‘caddy’ individual and team.

chown -R caddy:caddy /var/www/html

The index.html file was developed. Start the net web browser and kind the domain title target mine is:

http://hakase-labs.co/

And you will get the index page that we’ve created.( that you typed on the ‘Caddyfile’ configuration,******)

Caddy web server is running

Step 4 – Install PHP and PHP-FPM 7.0

In this step, we will install PHP-FPM packages from the Ubuntu repository.

Run the command that is apt.

sudo apt install php7.0-fpm that is-y php7.0-cli Curl

After the installation is complete, we shall configure the setup declare PHP-FPM.

Go towards ‘/etc/php/7.0/fpm’ Edit and directory the pool configuration file ‘www’conf’ using vim.

cd /etc/php/7.0/fpm
vim pool.d/www.conf

Uncomment lines below.

listen.owner =******************)listen.group that is www-data =******************)listen.mode that is www-data = 0660

( exit and*****)Save.

Now include the ‘caddy’ individual towards ‘www-data’ team.

usermod -a -G www-data caddy

Start the PHP-FPM solution and allow it to introduce each time at system boot.

systemctl start******************)systemctl that is php7.0-fpm enable php7.0-fpm

PHP-FPM installation and configuration for our Caddy web server installation have been completed.

Install PHP and PHP-FPM 7.0

Check the PHP-FPM socket file process using the netstat command below.

netstat -pl | grep php

Step 5 – Configure Caddy web server with PHP-FPM

After the PHP-FPM installation and configuration, we will add PHP-FPM support to the Caddy web server.

Go to the ‘/etc/caddy’ configuration directory and edit the configuration file ‘Caddyfile’ using vim.

cd /etc/caddy
vim Caddyfile

Now add the PHP-FPM that is following configuration caddy under your domain title bracket as below.

http://hakase-labs.co {
    root /var/www/html
    log /var/log/caddy/hakase-labs.log
    errors /var/log/caddy/errors.log
    tls off
    gzip

    # PHP-FPM Configuration for Caddy
    fastcgi / /run/php/php7.0-fpm.sock php {
        ext .php
        split .php
        index index.php
    }
}

Save and exit.

Restart the caddy internet host while the PHP-FPM solution.

systemctl restart caddy
systemctl restart php7.0-fpm

The Caddy internet host setup with PHP-FPM was finished.

Configure Caddy web server with PHP-FPM

Step 6 – Testing

Go towards internet root directory ‘/var/ww/html’ and produce the phpinfo file ‘info.php’.

cd /var/www/html
echo ‘<?php phpinfo(); ?>’ > info.php

Open your on line web browser and kind the Caddy internet host Address installation as below.

http://hakase-labs.co/info.php

And you’re going to get the PHP information web page as shown below.

Testing Caddy Web Server

Installation for Caddy internet host with PHP-FPM on Ubuntu 16.04 was finished effectively.

The significance of Your Reputation as a Freelance innovative

Previous article

Just how to Create e-mail MailBox consumer Account in ISPManager Hosting control interface

Next article

You may also like

Comments

Leave a Reply

More in Linux