Installing NginX
If you are installing Nginx on MacOSX, i recommend using homebrew. Once you have home brew running, install nginx via:
brew install nginx
Once you have it installed, there are a few notes of where you will need to get your nginx running. You nginx config file will be in:
/usr/local/etc/nginx/nginx.conf
if you are install it on Linux either debian or ubuntu. Just do this in terminal:
sudo apt-get install nginx
Setting up Php for NginX
Once you have installed Nginx, you may want to get Php5.4 running. Using homebrew, you can install php-fpm (Php fast process manager) that is a process listening on your (default) port 9000. You can now set nginx to forward any php script requests to this process by adding the following: PHP-FPM Configuration in the nginx.conf
location ~ .php$ {
#root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
You might find that the config may have this section of code commented out already. Just uncomment and restart your nginx server.
sudo nginx -s reload
Something interesting is to check your hosts file (if you are using mac), it will be the file at /etc/hosts. To edit, type this command:
sudo nano /etc/hosts
Some configuration parameters which you will find useful.
index index.php index.htm index.html; #Can be placed on the Http level if FPM is activated.
root /Users/[your user id]/Sites/; #This will point to your sites folder on mac. Note [user id], use yours! This can be placed in the Server level