There is makehost bashscript. Easiest way to create and delete localhosts for NGINX. This version had been writing for MacOS X. You can fork and write version for your OS.
- Download the script
- Apply permission to execute:
$ chmod +x /path/to/makehost
- Copy the file to your /usr/local/bin directory:
$ sudo cp /path/to/makehost /usr/local/bin/makehost
$ sudo makehost [add | delete] [domain] [optional host_dir]
to create a new virtual host:
$ sudo makehost add mysite.loc
to create a new virtual host with custom directory name:
$ sudo makehost add mysite.loc my_dir
to delete a virtual host
$ sudo makehost delete mysite.loc
to delete a virtual host with custom directory name:
$ sudo makehost delete mysite.loc my_dir
/usr/local/etc/nginx/nginx.conf
worker_processes 1;
error_log /usr/local/var/log/nginx/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$re$
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /usr/local/var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
index index.html index.php;
upstream www-upstream-pool{
server unix:/tmp/php-fpm.sock;
}
include /etc/nginx/conf.d/*.conf;
include /usr/local/etc/nginx/sites-enabled/*.conf;
}
/private/etc/hosts
127.0.0.1 localhost *.loc
255.255.255.255 broadcasthost
::1 localhost