Prerequisites were successfully installed. I installed Elastic Stack on Ubuntu 20.04 LTS. I followed all steps on this link (up to #2. Install and Configure Kibana on Ubuntu which I did not need). No problem whatsoever.
After installation is complete, I visited: example.com/magento and I got 403 Forbidden. I understand this is a permission issue, but before I installed Magento, I followed this guide and I set the permissions properly as highlighted below:
cd /var/www/html/<magento install directory>
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chown -R :www-data . # Ubuntu
chmod u+x bin/magento
When I first installed Magento 2, I was able to see it on the main domain without https and in the example/Magento directory. I think the problem is in my Nginx configuration file and more specifically in the SSL/ports which are as follows:
## Configure nginx for Magento 2
upstream fastcgi_backend {
server unix:/var/run/php/php7.4-fpm.sock;
}
server {
root /var/www/example.com/html/directory;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$args;
}
# pass PHP scripts to FastCGI server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
} #closing server tag
## New block for magento
server {
listen 8080;
server_name example.com www.example.com;
set $MAGE_ROOT /var/www/example.com/html/directory/magento;
# set $MAGE_MODE default;
set $MAGE_MODE production;
include /var/www/example.com/html/directory/magento/nginx.conf.sample;
}
# Set up a proxy
# source: https://devdocs.magento.com/guides/v2.4/install-gde/prereq/es-config-nginx.html
include /etc/nginx/conf.d/*.conf;
server {
if ($host = www.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 ;
listen [::]:80 ;
server_name example.com www.example.com;
return 404; # managed by Certbot
}
include /etc/nginx/conf.d/*.conf; is linked to a new file /etc/nginx/conf.d/magento_es_auth.conf with the following contents:
server {
listen 8080;
location /_cluster/health {
proxy_pass http://localhost:9200/_cluster/health;
}
}
sudo nginx -t
Returns:
nginx: [warn] conflicting server name "" on 0.0.0.0:8080, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
SSL certificate renewal sudo certbot renew --dry-run passed!
Nginx.confi.sample includes this content: nginx.conf.sample
How can I fix this and what went wrong?