乘风的人

欲穷千里目,更上一层楼


  • 首页

  • 搜索

Nginx - worker_processes、worker_connections设置

发表于 2020-02-04   |   分类于 技术 , Nginx   |   暂无评论
Nginx-worker_processes、worker_connections设置说明工作进程和进程连接数是nginx两个比较重要的参数,设置好合适大小,可以提高nginx处理性能,看到了,记录一下。转载自:https://blog.csdn.net/zhuyu19911016520/article/details/90714429转载自:https:/...

阅读全文...

Nginx - 安装目录及配置文件解析

发表于 2020-01-14   |   分类于 技术 , Nginx   |   暂无评论
Nginx-nginx安装目录及配置文件解析说明记录一下学习到的nginx配置文件的相关介绍及参数内容转载自:https://www.cnblogs.com/paulwhw/articles/11116363.html官方网站:https://docs.nginx.com/nginx.confNGINX的配置文件名为nginx.conf,对于编译安装的ngi...

阅读全文...

Nginx -信号管理nginx

发表于 2020-01-13   |   分类于 技术 , Nginx   |   暂无评论
Nginx-nginx 介绍说明记录一下关于nginx的信号管理,可能可能比较陌生说明nginx 信号控制及相关命令:https://www.nginx.com/resources/wiki/start/topics/tutorials/commandline/#starting-stopping-and-restarting-nginx大家可能要问什么是信...

阅读全文...

Nginx - nginx 安装及相关命令

发表于 2020-01-13   |   分类于 技术 , Nginx   |   暂无评论

Nginx-nginx 介绍

说明

介绍如何编译安装和用apt-get两种方式在ubuntu下安装nginx。


安装前说明

  • 服务器版本:ubuntu16.04
  • nginx下载地址:http://nginx.org/en/download.html
  • nginx 信号控制及相关命令:https://www.nginx.com/resources/wiki/start/topics/tutorials/commandline/#starting-stopping-and-restarting-nginx

编译安装

编译安装

1.下载最新的稳定版nginx,然后解压。

wget http://nginx.org/download/nginx-1.16.1.tar.gz
tar -xzvf nginx-1.16.1.tar.gz

2.更新源,安装相关扩展

  sudo apt-get update
  sudo apt-get install build-essential
  sudo apt-get install libtool
  sudo apt-get install libpcre3 libpcre3-dev
  sudo apt-get install zlib1g-dev
  sudo apt-get install openssl libssl-dev

3.编译

cd nginx-1.16.1/
#编译参数设置
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-file-aio --with-http_realip_module --with-stream --with-mail=dynamic
#编译安装
make
make install

4.启动nginx,查看进程

   
   sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
   ps -aux|grep nginx

编译参数

编译选项说明:
--prefix=path 如果在编译的不指定安装位置,那么默认的位置/usr/local/nginx目录
--sbin-path=path 设置nginx执行脚本的位置,这里如果设置在path变量里面,就可以在bash环境下,任意使用nginx命令,默认位置prefix/sbin/nginx  注意这里的prefix是在配置文件里面配置的路径
--conf-path=path 配置nginx配置文件的路径,如果不指定这个选项,那么配置文件的默认路径就会是 prefix/conf/nginx.conf
--pid-path =path 配置nginx.pid file的路径,一般来说,进程在运行的时候的时候有一个进程id,这个id会保存在pid file里面,默认的pid file的放置位置是prefix/logs/nginx.pid
--error-log-path=path 设置错误日志的存放路径,如果不指定,就默认 prefix/logs/error.log
--http-log-path= path 设置http访问日志的路径,如果不指定,就默认 prefix/logs/access.log
--user=name 设置默认启动进程的用户,如果不指定,就默认 nobody
--group=name 设置这个用户所在的用户组,如果不指定,依然是nobody
--with-http_ssl_module 开启HTTP SSL模块,使NGINX可以支持HTTPS请求。需要安装了OPENSSL
--with-http_flv_module
--with-http_stub_status_module 启用 "server status" 页
--without-http_gzip_module 禁用 ngx_http_gzip_module. 如果启用,需要 zlib
--without-http_ssi_module 禁用 ngx_http_ssi_module
--without-http_referer_module 禁用 ngx_http_referer_module
--without-http_rewrite_module 禁用 ngx_http_rewrite_module. 如果启用需要 PCRE 。
--without-http_proxy_module 禁用 ngx_http_proxy_module
--without-http_fastcgi_module 禁用 ngx_http_fastcgi_module
--without-http_memcached_module 禁用 ngx_http_memcached_module
--without-http_browser_module 禁用 ngx_http_browser_module
--http-proxy-temp-path=PATH 设置路径到the http proxy temporary files
--http-fastcgi-temp-path=PATH 设置路径到Set path to the http fastcgi temporary files
--without-http 禁用 HTTP server
--with-mail 启用 IMAP4/POP3/SMTP 代理模块
--with-mail_ssl_module 启用ngx_mail_ssl_module
--with-openssl=DIR 设置路径到OpenSSL library sources
--with-stream 用来实现四层协议的转发、代理或者负载均衡等

知识补充

configure 完成后会看到用到的扩展,及nginx的详细信息。

Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

相关命令

#查看nginx命令
/usr/local/nginx/sbin/nginx -h
#直接启动
/usr/local/nginx/sbin/nginx
#停止
/usr/local/nginx/sbin/nginx -s stop
重启
/usr/local/nginx/sbin/nginx -s reload

其他补充:
如果想要使用service nginx restart、service nginx stop 相关的命令,需要将nginx加到service下
参考链接:https://www.cnblogs.com/shihaiming/p/6290219.html

错误记录

编译安装后,在其他地方直接使用nginx命令时,提示需要安装相关nginx的包,但安装后会在/ect/下重新安装nginx,而且会覆盖之前在/usr/local下安装的nginx,网上说是我扩展安装的不对,但是重装后这个问题依然存在。想要在/usr/local/下管理nginx,只能在命令前加上nginx的路径了../sbin/nginx -h -s -c

root@iZ2ze1kijdfc2i0715ucdzZ:~/nginx-1.16.1# nginx -h
The program 'nginx' can be found in the following packages:
 * nginx-core
 * nginx-extras
 * nginx-full
 * nginx-light
Try: apt install <selected package>

这个问题我会再找一找的,看有什么解决的方法。找到了会补充上来。

apt-get 安装

apt-get和apt是ubuntu下自带的包管理工具,apt 算是apt-get的升级版,ununtu16.04之后就可以使用apt,所以这里也可以使用apt instll

直接安装

#更新源
sudo apt-get update
#安装扩展
sudo apt-get install build-essential
sudo apt-get install libtool
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install zlib1g-dev
sudo apt-get install openssl libssl-dev
#安装nginx
apt-get install nginx

补充

#查看目前源内的包的版本及相关扩展
apt-cache showpkg nginx
#安装指定版本的包
apt-cache madison <<package name>>

目录结构

  • 所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经安排在了/etc/nginx/sites-available下
  • 程序文件在/usr/sbin/nginx
  • 日志放在了/var/log/nginx中
  • 并已经在/etc/init.d/下创建了启动脚本nginx
  • 默认的虚拟主机的目录设置在了/var/www/nginx-default (有的版本 默认的虚拟主机的目录设置在了/var/www, 请参考/etc/nginx/sites-available里的配置)


阅读全文 »

PHP---- CGI和FastCGI的相关介绍

发表于 2020-01-02   |   分类于 PHP , 技术   |   暂无评论
PHP---- CGI和FastCGI的相关介绍说明专门花时间去看了PHP-FPM、FastCGI和CGI 相关的知识,记录一下。本文转载自:https://www.cnblogs.com/tssc/p/10255590.html在搭建 LAMP/LNMP 服务器时,会经常遇到 PHP-FPM、FastCGI和CGI 这几个概念。如果对它们一知半解,很难搭建...

阅读全文...

1...2728293031323334353637...41

知易行难,知行合一

204 文章
14 分类
27 标签
GitHub
友情链接
© 2026 乘风的人
Typecho
主题 - NexT.Pisces