We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1. ping www.baidu.com. //检查网络 2. yum list|grep gcc //列出gcc的部分 3. intables关闭 iptables -L 查看是否开启 iptables -S 关闭 4. getenforce 关闭
安装依赖
1. yum -y install gcc gcc-c++ autoconf pcre-devel make automake 2.yum -y install wget httpd-tools vim (httpd-tools加密的)
创建工作目录
1. cd /opt/ 2. mkdir app backup download logs work // 1. backup 放备用文件 2. app 当代码 3. download存放下载的内容 4. logs 存放日志 5. work存放脚本代码
nginx安装
Mainline version(开发版本)。Stable version(稳定版本) Legacy version(过去版本)
https://nginx.org/en/download.html 下载地址
Linux centos
Pre-Built Packages 寻找稳定版本
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=1
配置信息
// 1. cd /etc/yum.repos.d // 2. vim nginx.repo // 3. 复制上面的代码,保存并退出
查看源信息
yum list|grep nginx
安装
yum install nginx
查看文件的存放目录和安装路径
rpm -ql nginx
工具
// 查看后台进程 1. ps -aux|grep nginx // 查看本机因为Nginx进程所启用的端口 2. netstat -luntp|grep nginx
配置文件
目录和配置文件
/etc/nginx /etc/nginx/nginx.conf /etc/nginx/conf.d /etc/nginx/conf.d/default.conf (核心配置)
作用: Nginx主配置文件 先走Nginx的配置文件,如果我们没有配置,就走default.conf默认配置文件
保存和检查配置
1. nginx -t -c /etc/nginx/nginx.conf // -t 表示配置文件的语法检测 -c 配置文件测试是否成功 2. nginx -s reload -c /etc/nginx/nginx.conf // 重启 并制定配置 3. ps -aux|grep nginx
http协议的关系
执行命令
/usr/sbin/nginx(主要这个) /usr/sbin/nginx-debug
作用:Nginx服务的启动管理的终端命令(用于调试和分析)
nginx -tc /etc/nginx/nginx.conf (检查配置项)
nginx -c /etc/nginx/nginx.conf / systemctl start nginx.service (开启nginx)
nginx -s reload -c /etc/nginx/nginx.conf / systemctl reload nginx.service (重启Nginx服务)
nginx -s stop -c /etc/nginx/nginx.conf / systemctl stop nginx.service (关闭服务)
缓存
日志
1. cd /etc/nginx 2. vi nginx.conf
http { // 设置了Nginx中所有的Content-Type类型 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; // 读取默认的配置 include /etc/nginx/conf.d/*.conf; sendfile on; #tcp_nopush on; // 客户端和服务端的连接时间 keepalive_timeout 65; #gzip on; server { listen: 80; location { proxy_pass http://localhost:1234 proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; } }
如果没有配置server,就会走defalut.conf的文件(/etc/nginx/conf.d/default.conf)
server { // 对于不同的server,可以根据listen(端口),也可以根据server_name区别 listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; // 如果开启了nginx,路径:/ 目录:/usr/share/nginx/html 文件: index.html index.htm location / { root /usr/share/nginx/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # // 如果是500等服务器错误,就走/50.html error_page 500 502 503 504 /50x.html; // 路径: /50.html 文件的存放目录: /usr/share/nginx/html location = /50x.html { root /usr/share/nginx/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; #} }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
nginx学习
环境配置
安装依赖
创建工作目录
nginx安装
Mainline version(开发版本)。Stable version(稳定版本) Legacy version(过去版本)
https://nginx.org/en/download.html 下载地址
Linux centos
Pre-Built Packages 寻找稳定版本
配置信息
查看源信息
安装
查看文件的存放目录和安装路径
工具
nginx的中间件架构
1. 安装目录讲解(rpm -ql nginx)
配置文件
目录和配置文件
/etc/nginx /etc/nginx/nginx.conf
/etc/nginx/conf.d /etc/nginx/conf.d/default.conf (核心配置)
作用: Nginx主配置文件 先走Nginx的配置文件,如果我们没有配置,就走default.conf默认配置文件
保存和检查配置
http协议的关系
执行命令
/usr/sbin/nginx(主要这个) /usr/sbin/nginx-debug
作用:Nginx服务的启动管理的终端命令(用于调试和分析)
nginx -tc /etc/nginx/nginx.conf (检查配置项)
nginx -c /etc/nginx/nginx.conf / systemctl start nginx.service (开启nginx)
nginx -s reload -c /etc/nginx/nginx.conf / systemctl reload nginx.service (重启Nginx服务)
nginx -s stop -c /etc/nginx/nginx.conf / systemctl stop nginx.service (关闭服务)
缓存
日志
2. 安装编译参数(nginx -V)
--sbin-path=/usr/sbin/nginx
--modules-path=/usr/lib64/nginx/modules
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock
--http-proxy-temp-path=/var/cache/nginx/proxy_temp
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
--http-scgi-temp-path=/var/cache/nginx/scgi_temp
--group=nginx
3. Nginx的主要配置
3.1: nginx.conf中的http部分
如果没有配置server,就会走defalut.conf的文件(/etc/nginx/conf.d/default.conf)
The text was updated successfully, but these errors were encountered: