From wiki: Nginx (pronounced “engine-x”) is an open source reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols, as well as a load balancer, HTTP cache, and a web server (origin server). The nginx project started with a strong focus on high concurrency, high performance and low memory usage. It is licensed under the 2-clause BSD-like license and it runs on Linux, BSD variants, Mac OS X, Solaris, AIX, HP-UX, as well as on other *nix flavors. It also has a proof of concept port for Microsoft Windows.
- Step 1: install nginx with command:
- brew install nginx
- step 2: Prepare for start nginx service
- sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchDaemons
- sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
- step 3: You can also do some basic configuration by specifying the location file is feeding up.
- By default, nginx is running on port 8080, so you can verify if the server is running of not by visiting :http://localhost
- Also, if you want to stop the servie, you can run this command
- sudo launchctl unload -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
The nginx configuration file is located in /usr/local/etc/nginx/
Here is an example for some basic setting:
…
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
root /var/www/virtual/test.com/htdocs;
index index.html inde.htm;
location / {
default_type “text/html”;
try_files $uri.html $uri $uri/ /index.html;
}
…
you need to restart nginx service to have the new setting loaded up, so with this simple change, port is changed to 80 from 8080 and you can visit your site from http://localhost.
Enjoy!