使用Nginx部署静态页面,nginx部署静态页面
使用Nginx部署静态页面,nginx部署静态页面
1.找到nginx的安装路径及配置文件
ps -ef|grep nginx
root 12604 1 0 18:14 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
2.查看nginx的配置文件
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf; #加载/etc/nginx/conf.d/* 的配置
}
3.在/etc/nginx/conf.d/ 下新建一个xxx.conf
server {
listen 8300;
server_name localhost;
location / {
root /home/testStatic;
access_log on;
autoindex on;
}
}
server_name:域名
listen:端口
root:静态页的路径
4.创建目录,上传静态文件
切换到/home/testStatic
使用rz命令,选择打包好本地的静态文件,上传到该目录.
unzip或tar解压.
5.部署完毕
重启nginx
./nginx -s reload
通过配置的 server_name:listen 域名路径来访问页面.
评论暂时关闭