Getting started
These instructions help you setup a local development environment that can access the services on this UNC Open Web server. First, use the form below to generate and download a configuration file. Then, follow the instructions under the heading for your operating system.
Generate nginx.conf
- Fill out the fields below.
- Click Generate.
- A new window or tab appears with your configuration in it.
- With that window selected, go to the File menu and click Save As or Save Page As. Or, if Save As is disabled in your browser, copy and paste the configuration into a new text file instead.
- Save the file with the name nginx.conf in an easy to remember location. You will move it shortly.
Mac OS X
Install MacPorts
- Visit http://www.macports.org/install.php
- Download the .dmg file for your OS version (Tiger, Leopard, or Snow Leopard).
- Open the .dmg file when it finishes downloading.
- Double click the .pkg file inside.
- Work through the installer.
Install nginx
- Open a Terminal window (Applications -> Utilities -> Terminal).
- Update MacPorts by running the following command and entering your admin password if prompted:
sudo port -v selfupdate
- Install nginx with the command:
sudo port install nginx
Configure nginx
- Move the config file you generated into place:
sudo mv ~/Downloads/nginx.conf /opt/local/etc/nginx/nginx.conf
- Move the default mimetypes file into place:
sudo mv /opt/local/etc/nginx/mime.types.example /opt/local/etc/nginx/mime.types
- Make sure Apache is disabled on your Mac by going to Apple menu -> System Preferences -> Sharing and unchecking the Web Sharing box.
Run, stop, or restart nginx
Nginx does not run automatically when you boot. When starting it, you may receive a firewall prompt to allow or disallow nginx to accept incoming connections. You can safely disallow nginx from accepting incoming connections so that you can access your local web server only from your local machine. This selection keeps your machine safe.
- Open a Terminal window (Applications -> Utilities -> Terminal).
- Start nginx with the command:
sudo nginx
- Stop nginx with the command:
sudo nginx -s quit
- Restart nginx with the following command if you make configuration changes:
sudo nginx -s reload
Test your setup
- Right-click this test file link and select Save as.
- Save the file as nginx_test.html in your home directory Sites folder.
- Click this link to test your local setup.
Go forth and code
The nginx configuration makes the Sites folder in your Mac home folder web accessible via the URL http://localhost/local/. Develop your applications in that folder or a subfolder.
Linux (Ubuntu)
Install nginx
- Start Synaptic (System -> Admin -> Synaptic package manager).
- Type nginx in the Quick Search box.
- Click the little box next to nginx.
- Choose Choose for Installation.
- Click Apply.
- Click Apply again.
Configure nginx
- Open a terminal window.
- Make a public_html folder in your home directory:
mkdir ~/public_html
- Move the file you generated into the nginx sites directory:
sudo cp nginx.conf /etc/nginx/sites-available/uowlocal
- In /etc/nginx/sites-enabled, remove the default and link in unclocal:
cd /etc/nginx/sites-enabled
sudo rm default
sudo ln -s /etc/nginx/sites-available/uowlocal
- Make sure Apache is not running or set to run on boot.
Run, stop, or restart nginx
Nginx should start automatically when your computer boots. On a laptop with wireless that starts after login, nginx fails to start so you'll need to start it manually.
- Open a terminal window.
- Start nginx with the command:
sudo nginx
- Stop nginx with the command:
sudo nginx -s quit
- Restart nginx with the following command if you make configuration changes:
sudo nginx -s reload
Test your setup
- Right-click this test file link and select Save as.
- Save the file as nginx_test.html in your home directory public_html folder.
- Click this link to test your local setup.
Go forth and code
The nginx configuration makes the public_html folder in your home folder web accessible via the URL http://localhost/local/. Develop your applications in that folder or a subfolder.
Windows
Install nginx
- Download the latest stable version for Windows from the nginx home page.
- Unzip the .zip file you downloaded.
- Rename the unzipped folder to nginx.
- Move the nginx folder to the root of your hard drive (e.g., C:\).
Configure nginx
- Move the config file you generated into the nginx/conf folder.
- Click OK to overwrite any file with the same name.
Run, stop, or restart nginx
Nginx does not run automatically when you boot. When starting it, you may receive a firewall prompt to allow or disallow nginx to accept incoming connections. You can safely disallow nginx from accepting incoming connections so that you can access your local web server only from your local machine. This selection keeps your machine safe.
- Open the Start menu.
- Click Run.
- Enter cmd to start the command prompt.
- Change to the nginx folder you moved earlier.
cd \nginx
- Start nginx with the command:
start nginx.exe
- Stop nginx with the command:
nginx.exe -s quit
- Restart nginx with the following command if you make configuration changes. Note that this does not work very well on Windows and may hang the server.
nginx.exe -s reload
Test your setup
- Right-click this test file link and select Save as.
- Save the file as nginx_test.html in the nginx/html folder.
- Click this link to test your local setup.
Go forth and code
The nginx configuration makes the nginx/html folder in the root of your hard drive web accessible via the URL http://localhost/local/. Develop your applications in that folder or a subfolder.