I have just installed LAMP and want to create a folder to store all the php and html files. After that run them in http://localhost.
Where and how do i create a folder to store all my files to be executed?

Thanks

Dani AI

Generated

Nice catch by and thanks to for pointing to the webserver document root. A couple of short, practical follow-ups that make working with PHP on a LAMP box easier and help avoid common pitfalls.

Create a tiny PHP test page to confirm PHP is being executed (for example, a file that calls phpinfo()). If the browser shows source instead of formatted output, PHP is not enabled in Apache.

<?php
phpinfo();
?>

Quick troubleshooting and maintenance commands to try (adjust paths to your system):

php -v
apache2ctl -M | grep php
sudo service apache2 restart
# or on systemd systems:
sudo systemctl restart apache2
sudo tail -n 200 /var/log/apache2/error.log

Keep permissions sane so the webserver can read files but they are not world-writable:

sudo chown -R www-data:www-data /path/to/docroot
find /path/to/docroot -type d -exec chmod 755 {} \;
find /path/to/docroot -type f -exec chmod 644 {} \;

If you want project-specific folders instead of the global document root, use virtual hosts or the userdir module. To locate your active document root or vhost settings, search Apache config:

grep -R "DocumentRoot" /etc/apache2

Always check the webserver error log for clues when something fails, avoid storing DB credentials in web-accessible locations, and give each project its own virtual host for clearer URL handling and permissions. Useful references: PHP phpinfo() docs (phpinfo), Apache user directories (mod_userdir), and the Ubuntu LAMP guide (Ubuntu ApacheMySQLPHP).

Recommended Answers

All 4 Replies

put the content in /var/www usually

Found it.

sudo nano /var/www/test.php

Solved

thanks jbennet.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.