There are many tutorials around how to build a REST API in php, but they all seem to be either focused on using XAMPP (i.e. they explain where to put the PHP sources for XAMPP only, referring to the htdocs
-folder) or they completely skip such explanations. So my question is: when I am working on a LAMP-stack on Ubuntu where websites and php scripts to be viewed/executed on localhost are “deployed” to /var/www/html
, where do I have to put the code for the REST API, to be able to use it on localhost? I tried to put them into /var/www
or /var/www/html/
but that did not work. Any hints would be appreciated!
1
It is related to what folder do you choose in config. For example, default place for site folders in /etc/apache2/sites-available/mySite.local.conf
There is listen port and document root path for your site path. You can change document root for your site(s) with DocumentRoot
key like this:
DocumentRoot /var/www/mySite/
Then you need to enable site:
sudo a2ensite mySite.local.conf
After it, you need to restart apache2
sudo service apache2 reload