previously I was using Apache and I used to put php files under /var/www/. Likewise where should I put my files in nginx server. I am using Ubuntu 12.04.
1 Answer
That depends on your configuration. You can put your doc root wherever you want. /var/www is often used by default, but not always.
In addition, it depends on how you've configured any handlers for PHP. Nginx doesn't run your PHP, PHP does. (This was the same for Apache... you were likely using an Apache module version of PHP, or CGI.) If you haven't configured this yet, look into PHP-FPM.
5 Comments
Manojkumar
should I always edit config file for a small change, say i want to execute test.php which out puts phpinfo() ? Can't I put the file in some default location which nginx can read ( like /var/www in apache2 OR /xampp/htdocs/ in Xampp-apache)
Brad
@ManojKumar Sure you can. You can configure whatever path you want.
Manojkumar
No Brad, what I am asking is - if you type localhost in browser, it will display 'Welcome to nginx!'. In which file this is written. I want to edit it to show some other message.
Brad
@ManojKumar Please read again. Configure your path accordingly. If you don't know what that path is now, check
/etc/nginx/sites-enabled/defaultManojkumar
Thanks Brad, I got it - it is /usr/share/nginx/www
/etc/nginx/sites-available.