网站首页 > 技术教程 正文
一、前言
最近想要部署一个纯前端的静态页面,项目的内容很简单,也就是一些简单的html、css、js、jpg、mp3等静态资源,不涉及后端开发。
之前一直都是使用Tomcat来部署项目的,因为涉及后端接口等方面的内容,这次再用它来部署纯前端的东西,显得大材小用,过于笨重。
此时,使用nginx,便是最合适的选择了,轻量、简单、灵活。
二、nginx安装下载
我的服务器是在腾讯云上买的,操作系统是Centos,Linux中的一种。
安装使用自带的命令yum即可
yum install nginx
三、nginx配置
安装完,nginx的相关目录就都有了,最重要的一个配置文件nginx.conf在于
/etc/nginx/nginx.conf
我们一般在这里配置完项目的相关信息的配置,如访问权限、访问端口、访问机器、访问项目、访问文件等:
#1.注意user使用root,以便轻松访问任何文件
user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
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;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
server {
#2.这里监听我们常用的80端口
listen 80;
#3.这里配置机器地址,一般是本机localhost
server_name localhost;
#4.这里配置项目根路径
root /root/love;
#5.这里配置项目的访问页面
index index.html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
四、nginx命令
配置完毕,我们便可启动nginx,完成部署,如果期间修改配置文件,我们则在reload下即可,下面罗列下几个常用的命令:
#启动nginx
systemctl start nginx.service
#停止nginx
systemctl stop nginx.service
#重新加载nginx配置
systemctl reload nginx.service
#查看nginx状态
systemctl status nginx.service
猜你喜欢
- 2024-10-10 推荐几个开源的个人独立博客系统(开源个人博客源码下载)
- 2024-10-10 Kubernetes 之 Nginx 动静态 PV 持久存储 下篇
- 2024-10-10 FreeMarker-静态模板的使用与生成
- 2024-10-10 使用nginx做前端服务器可以设置类似的静态文件客户端缓存
- 2024-09-12 「nginx」十、nginx的location配置详解
- 2024-09-12 Nginx配置文件(nginx配置文件位置)
- 2024-09-12 基于nginx反向代理实现网站静态页面与动态页面自动切换
- 2024-09-12 nginx学习总结(nginx入门教程)
- 2024-09-12 除了负载均衡,Nginx还可以做很多,限流、缓存、黑白名单等
- 2024-09-12 Nginx网站服务(nginxweb服务器)
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)