1. The problem I’m having:
I am trying to install a fresh Magento 2.4.x version on the ubuntu 22.04 server however facing the permission issues in terms of accessing the folder and also 403 error on the browser. Its a kind of mixed up of both the discussions and also followed steps from both the discussions but couldnt make it work.
2. Error messages and/or full log output:
Aug 16 09:07:18 ip-172-26-8-72 caddy[304627]: {"level":"debug","ts":1723799238.8958914,"logger":"http.log.error","msg":"open /home/ubuntu/projects/m2/pub: permission denied","request":{"remote_ip":"162.158.170.232","remote_port":"35594","client_ip":"162.158.170.232","proto":"HTTP/2.0","method":"GET","host":"caddy.selldesk.in","uri":"/","headers":{"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"],"Sec-Fetch-Mode":["navigate"],"Sec-Fetch-User":["?1"],"Cf-Connecting-Ip":["49.204.133.206"],"Accept-Encoding":["gzip, br"],"Sec-Ch-Ua":["\"Not)A;Brand\";v=\"99\", \"Google Chrome\";v=\"127\", \"Chromium\";v=\"127\""],"Sec-Ch-Ua-Mobile":["?0"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"],"Sec-Fetch-Site":["none"],"Priority":["u=0, i"],"X-Forwarded-For":["49.204.133.206"],"Cache-Control":["max-age=0"],"Sec-Ch-Ua-Platform":["\"Linux\""],"Cdn-Loop":["cloudflare"],"Cf-Ray":["8b4045f9fc9ba07e-SIN"],"X-Forwarded-Proto":["https"],"Accept-Language":["en-GB,en;q=0.9"],"Cf-Ipcountry":["IN"],"Cf-Visitor":["{\"scheme\":\"https\"}"],"Sec-Fetch-Dest":["document"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"caddy.selldesk.in"}},"duration":0.000170403,"status":403,"err_id":"wnisg4vcg","err_trace":"fileserver.(*FileServer).ServeHTTP (staticfiles.go:283)"}
Aug 16 09:07:26 ip-172-26-8-72 caddy[304627]: {"level":"debug","ts":1723799246.34881,"logger":"http.handlers.file_server","msg":"sanitized path join","site_root":"/home/ubuntu/projects/m2/pub","fs":"","request_path":"/","result":"/home/ubuntu/projects/m2/pub"}
3. Caddy version:
v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=
4. How I installed and ran 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
sudo apt update
sudo apt install caddy
a. System environment:
Servers specs below:
Ubuntu 20.04
PHP 8.2
MySQL 8
Composer 2.2.24
b. Command:
sudo systemctl enable --now caddy
c. Service/unit/compose file:
d. My complete Caddy config:
{
debug
}
caddy.selldesk.in {
# Set this path to your site's directory.
root * /home/ubuntu/projects/m2/pub
encode gzip
php_fastcgi unix//run/php/php8.2-fpm.sock
# Enable the static file server.
file_server
# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080
# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000
}