$ brew install nginx
Setelah install jalankan nginx.
$ sudo nginx
Test apakah nginx sudah running, buka url http://localhost:8080.
Nginx default port adalah 8080, kita akan menggantinya ke port 80.
$ sudo nginx -s stop
Kemudian buka nginx.conf
$ sudo nano /usr/local/etc/nginx/nginx.conf
Ganti
server {
listen 8080;
Menjadi
server {
listen 80;
Simpan konfigurasi.
- Buat direktori bernama
sites-available
dansites-enabled
di/usr/local/etc/nginx/
. - Buat file
foo.conf
di dalam direktorisites-available
. - Paste source code berikut ke file
foo.conf
.
server {
listen 80;
root /Users/ipan/workspace/foo;
index index.php;
server_name beta.foo.dev;
server_name member.foo.dev;
server_name microsite.foo.dev;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
-
Kemudian buat symlink
$ ln -s /usr/local/etc/nginx/sites-available/foo.conf /usr/local/etc/nginx/sites-enabled/foo.conf
-
Lalu buka file
/usr/local/etc/nginx/nginx.conf
, masukan code berikut di dalam section http.
include /usr/local/etc/nginx/sites-enabled/*.conf;
-
Setelah itu buka file hosts
$ sudo nano /etc/hosts
-
Tambahkan host dibawah ini
127.0.0.1 beta.foo.dev
127.0.0.1 member.foo.dev
127.0.0.1 microsite.foo.dev
-
Reload Nginx
$ sudo nginx -s reload
-
Test URL Test URL web, jika masih belum restart notebook.