web安全day33:人人都要懂的LNMP--nginx的配置和文件理解
2023-09-11 14:14:52 时间
目录
N:nginx web
轻量级软件,支持庞大的并发访问。
配置nginx
下载
wget http://nginx.org/download/nginx-1.20.2.tar.gz
解压
tar–zxvf nginx-1.20.2.tar.gz
进入
cd nginx-1.20.2
配置
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx
编译
make
安装
make install
如果报错误提示:
./configure: error: the HTTP rewrite module requires the PCRE library.表示需要安装依赖
安装依赖
yum -y install pcre-devel openssl openssl-devel
Usage: nginx [-?hvVtTq] [-s signal] [-p prefix] [-e filename] [-c filename] [-g directives] Options: -?,-h : this help -v : show version and exit -V : show version and configure options then exit -t : test configuration and exit -T : test configuration, dump it and exit -q : suppress non-error messages during configuration testing -s signal : send signal to a master process: stop, quit, reopen, reload -p prefix : set prefix path (default: /usr/local/nginx/) -e filename : set error log file (default: logs/error.log) -c filename : set configuration file (default: conf/nginx.conf) -g directives : set global directives out of configuration file
启动nginx服务
./usr/local/nginx/sbin/nginx
如果报错
表示地址或者端口被占用,当出现这个错误时,可能存在80端口被占用的情况。
ss -antpl | grep 80
可以在windows上进行访问来验证。
该主页存放于/usr/local/nginx/html/下的index.html。
cat /usr/local/nginx/html/index.html
停止nginx服务
./usr/local/nginx/sbin/nginx -s stop
重要文件理解
_temp:临时目录
conf:配置文件
nginx.conf文件包括三部分:
//全局配置 #user nobody;//运行用户如果未指定 worker_processes 1;//工作进程数(根据cpu核心数设定) #error_log logs/error.log;//错误日志的文件位置 #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid;//pid文件位置
//I/O事件配置 events { worker_connections 1024;//每个进程处理1024连接 }
//HTTP配置部分 http { include mime.types;//文件拓展名与文件类型映射表 default_type application/octet-stream;//默认文件类型 sendfile on;//支持文件发送(下载) #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65;//连接保持超时时间,单位秒 server {//web服务监听配置 listen 80;//监听80端口 server_name localhost;//网站名称 #charset koi8-r; location / {//定义安装目录为软件根目录 root html;//网页存放目录 index index.html index.htm;//默认索引页 } location = /50x.html {//错误页面配置 root html; }
欢迎关注博主公众号:旁骛OtherThing,不定期更新各种技术干货。
相关文章
- Linux虚拟机与Windows共享文件
- 通过源码了解ASP.NET MVC 几种Filter的执行过程 在Winform中菜单动态添加“最近使用文件”
- Web文件上传方法总结大全
- 5.配置globals文件(目标端)
- docker-compose.yaml文件配置详解
- 面试题 Java 遍历文件夹及其子文件夹下的所有文件,将文件路径输出到控制台
- 为已有文件添加 d.ts 声明
- Sring源码解析(一)Spring是怎么读取配置Xml文件的
- Django开发环境静态文件访问配置
- maven资源文件的相关配置
- 一小时学会使用springboot操作阿里云OSS实现文件上传,下载,删除(附源码)
- 将本地文件上传到github空仓库(git实现)
- PostgreSQL:Java使用CopyManager实现客户端文件COPY导入
- CentOS配置本地yum源(使用镜像iso文件)
- React脚手架工程化项目里ServiceWorker.js文件作用
- 在64位的ubuntu 14.04 上开展32位Qt 程序开发环境配置(pro文件中增加 QMAKE_CXXFLAGS += -m32 命令)
- Kettle数据抽取实战之三:JSON文件抽取
- nginx 配置跨域、文件限制
- js+php实现文件上传显示文件上传进度条的插件
- git 一个文件还原到某个提交的commit
- ansible 配置了端口在host文件但是还要走22 ip:60001 ansible_ssh_port=60001
- find 多文件查找需要单引号
- ELK之jason配置nginx文件等多个配置文件
- /etc/fstab文件损坏怎么办
- logging 单个py文件输出到两个日志中
- Linux或Windows下安装及配置Erlang和RabbitMQ,所需相关安装包和文件,包含多个版本
- linux下轻松修改pdf文件
- Laravel 5.1的多路由文件的配置