How to make PHP run on other folders?
In a terminal execute the following commands:
sudo chmod 775 home/myusername/Projects/myproject
sudo gedit /etc/apache2/sites-available/default
In the editor, change DocumentRoot /var/www
toDocumentRoot /home/myusername/Projects/myproject
Then you will see <Directory "/var/www">
Change your default /var/www/
directory to /home/myusername/Projects/myproject/
Save and exit the editor.
Now restart your apache service:
sudo service apache2 restart
Also chmod
your second directory.
sudo gedit /etc/apache2/sites-available/default
Create alias in gedit
:
Alias /name /seconddirectory
<Directory /seconddirector>
Options All
AllowOverride All
order allow,deny
allow from all
</Directory>
Now you can point to the directory http://127.0.0.1/your-name
and by 127.0.0.1
to enter the root directory.
You can use php built-in server instead of apache to run html/css and/or php files from a directory
cd /path/to/your/app
php -S localhost:8000
As output you'll get :
Listening on localhost:8000
Document root is /path/to/your/app