Skip to content

Instantly share code, notes, and snippets.

@1242035
Last active July 17, 2019 17:14
Show Gist options
  • Select an option

  • Save 1242035/97818c747e949f697f076e7a82462aa9 to your computer and use it in GitHub Desktop.

Select an option

Save 1242035/97818c747e949f697f076e7a82462aa9 to your computer and use it in GitHub Desktop.
Config nginx + php service on window use nssm
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
server {
listen 80;
server_name 127.0.0.1;
root H:/amela/laboro-web/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
1> download (http://nssm.cc/download)
2> extract to folder (ex: H:\server\nssm)
3> download nginx (http://nginx.org/en/download.html) window version
4> extract to folder (ex: H:\server\nginx)
5> download php (https://windows.php.net/download/) - (ex: https://windows.php.net/downloads/releases/php-7.3.7-Win32-VC15-x64.zip)
6> extract to folder (ex: H:\server\php)
7> add (H:\server\nssm) (H:\server\nginx) (H:\server\php) to system variable
8> install nginx service by open command promt and run "nssm install nginx"
in tab "Application"
Path: H:\server\nginx\nginx.exe
Startup directory: H:\server\nginx
Service name: "nginx"
click "Install service"
9> install php fastcgi service by open command promt and run "nssm install php-fastcgi"
in tab "Application"
Path: H:\server\php\php-cgi.exe
Startup directory: H:\server\php
Arguments: -b 127.0.0.1:9000
Service name: "php-fastcgi"
click "Install service"
10> modify nginx.conf like attach
11> add folder sites at H:\server\nginx\sites
12> add default.conf like attach
13> add example laravel site conf like example.conf
14> open window service ( window + R and enter "msconfig.msc")
15> start php-fastcgi service
16> start nginx service
17> open browser enter "localhost" (default site)
18> open browser enter "127.0.0.1" (laravel site)
19> have fun ^-^
#user nobody;
worker_processes auto;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
include ../sites/*.conf;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment