After my installation of magento2 on Ubuntu, I get this error on localhost http://localhost/magento2/
– 403 forbidden
I have to change the port to any other like 8080 in file /etc/nginx/sites-available/magento, in order to be able to load the website like this http://localhost:8080/magento2/
I know that nginx is able to server various sites, and I was expecting to use this http://localhost:80/magento2/ but I get error 403 forbidden
In my understanding as far as you have a root directory for each virtual hosts, the web-server will pull the site files from those locations, so it should not matter if this is the same port, if you specific the folder with the content after server name, in my case: http://localhost:80/magento2/
Is there anyone able to advice how this supposed to be configured with nginx?,
thanks
My nginx config for magento is:
upstream fastcgi_backend {
server unix:/run/php/php7.2-fpm.sock;
}
server {
listen 80;
server_name localhost/magento2;
set $MAGE_ROOT /var/www/html/magento2;
include /var/www/html/magento2/nginx.conf.sample;
}
Default is just:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
Best Answer
drop all that and revert to default apache configuration. then create virtual host with proper domain name.
for example
www.mynewshop.com
add this domain to your local hosts file: /etc/hosts
add your domain name to magento base url
then just open it in your browser.