NginxWindows详细安装部署教程1、下载nginx包
2、下载完成后,在指定位置解压缩,不要直接双击。
3、运⾏cmd,进⼊解压的指定⽬录下
4、启动nginx服务,启动命令为:start nginx,启动时会⼀闪⽽过是正常的
5、查看任务进程是否存在,命令:tasklist /fi "imagename "
6、进⼊解压缩⽬录,在conf⽬录下到f使⽤txt⽂本打开即可,到server这个节点,进⾏修改
需修改的下图四个地⽅
⽂件内容如下
#user nobody;
worker_processes 1;
#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 pes;
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;
server {
listen 8888;//输⼊端⼝号
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root D:/nginx-1.16.1/html/dist; //输⼊包的地址
index index.html index.htm;
try_files $uri $uri/ @router;
}
location @router{
#rewrite ^.*/index.html last;
rewrite ^(.+)$ /index.html last;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500502503504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass 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;
php软件安装包# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
7、修改完成后保存,使⽤以下命令检查⼀下配置⽂件是否正确,后⾯是f⽂件的路径,successful就说明正确了命令:nginx -t -c /nginx-1.16.1/f
8、如果程序没启动就直接start nginx启动,如果已经启动了就使⽤以下命令重新加载配置⽂件并重启
命令:nginx -s reload
9、之后就打开浏览器访问刚才的域名及端⼝localhost:8888,出现欢迎页就说明部署成功了
10、关闭nginx服务使⽤以下命令,同样也是⼀闪⽽过是正常的,看⼀下是否进程已消失即可
快速停⽌:nginx -s stop
完整有序的关闭:nginx -s quit
11、把安装包放在D:\nginx-1.16.1\html⽬录下,进⾏解压
12、在dos指定路径下,输⼊命令:nginx -s reload,重启
13、打开浏览器访问localhost:8888,就可以访问⾃⼰的项⽬了
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论