Cannot Access .php File Through Browser (Edited)
I set up a VPS and created a folder inside the /home/ directory named share-br. I’m trying to access an index.php file located at /home/share-br/index.php through my browser.
The URL I’m using is:
http:///share-br/index.php
However, the browser returns a 404 error, and the page doesn’t load.
How can I access my PHP file on the server?
Answers
Tiago Oliveira
3 days ago
Rating
The /home/ directory is not meant to serve web content directly. To make your PHP file accessible via the browser, you need to place it in a directory that your web server serves, such as /var/www/html/.
Steps to fix it:
Install a web server (like Apache) and the necessary PHP components:
After installation, start and enable the web server:
Now, move your PHP file to a directory accessible by the web server:
After moving the file, try accessing it via your browser:
Now, your PHP file should be accessible through the web server.
Alessandro Gallo
5 days ago
Rating
That's not how web services work.
You need a web server that can handle HTTP requests and serve files. Either you write an HTTP server to do that, or you use Nginx, Apache, or PHP-FPM to handle PHP scripts.