Question

403 Forbidden when changing index.html to index.php

I hope someone can help me here. I just want to change the index.html to index.php, but when I do so I get the 403 forbidden error. I followed a bunch of tutorials on permission and installing php etc. to no avail. I am a complete newbie, so most of the time I don’t really know what I am doing but I am trying to follow the tutorials.

If someone could give me complete newbie intructions on how to solve this, I’d be very grateful. I learned how to access files and other simple stuff but not much more.

I am using nginx on ubuntu. With the html files my website works fine, but I need it .php to run something.


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @karpred , I had to start new answer again :D Thanks for the latest result, and please provide one couple more. So, it will be two files: get_me_and_remove_me_2 and get_me_and_remove_me_3

1.

For sudoer:

sudo grep -e server_name -e root -e index -e include /etc/nginx/sites-available/* > ~/get_me_and_remove_me_2 && sudo cp /home/$USER/get_me_and_remove_me_2 /var/www/

For root:

grep -e server_name -e root -e index -e include /etc/nginx/sites-available/* > /var/www/get_me_and_remove_me_2

2.

For sudoer:

sudo ls -la /etc/nginx/sites-enabled/  > ~/get_me_and_remove_me_3 && sudo cp /home/$USER/get_me_and_remove_me_3 /var/www/

For root:

sudo ls -la /etc/nginx/sites-enabled/  > /var/www/get_me_and_remove_me_3
KFSys
Site Moderator
Site Moderator badge
September 30, 2020

Hi @karpred,

It seems like you might not have PHP installed.

Please follow the last reply from @Yannek, they provided you with steps on how to install PHP on your droplet. See if that works.

KFSys
Site Moderator
Site Moderator badge
September 28, 2020

Hello @karpred,

You need to check 2 or 3 things In your domain’s Nginx configuration file.

The first is your root or referred to as DocumentRoot directive. In your case it’s /var/www/html but are you sure that’s where your files are located? Enter that directory and see if the files are there or located in another folder named after your domain. If it’s the second option just add the domain in your root directive :

root /var/www/html

to be

root /var/www/html/domain.com

That’s only if the files are in the said folder.

The next thing to change would be the server_name

server_name _;

You should change it to include your domain

server_name domain.com www.domain.com;

After you make those changes, restart nginx and see if your website works properly now.

Regards, KFSys