1.nginx安装
来源:互联网 发布:mac怎么玩腾讯游戏 编辑:程序博客网 时间:2024/05/21 22:50
1.安装nginx环境
uname -aLinux localhost.localdomain 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
2.安装nginx需提前安装的软件
#查询软件安装目录rpm -qarpm -ql xxxxxxxxxxx#安装gcc编译器yum -y install gcc#nginx使用到正则表达式的话必须安装的软件,用于解析正则表达式。默认安装在 /usr/lib64/yum -y install pcre pcre-devel#安装zlib。用于响应体重压缩gzib。默认安装 /usr/lib64/yum -y install zlib zlib-devel#安装openssl。安装目录 /usr/lib64/opensslyum -y install openssl oepnssl-devel /usr/lib64/
3.安装nginx
cd ~mkdir softcd softwget http://nginx.org/download/nginx-1.11.4.tar.gztar -zxvf nginx-1.11.4.tar.gz cd nginx-1.11.4./configure --prefix=/usr/local/nginxmakemake install
4.修改nginx配置
cd /usr/local/nginx/cd conf/vi ./nginx.conf
nginx 配置
#user nobody;worker_processes 1;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { worker_connections 1024;}http { include 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 logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root 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; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #}}
5.启动,访问和停止nginx
cd ../sbin./nginxcurl http://127.0.0.1:80
6.常用命令
#启动指定配置文件/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf#指定nginx 安装目录/usr/local/nginx/sbin/nginx -p /usr/local/nginx#临时全局指定一些全局配置项。不能和已有的写在配置文件中的配置项相冲突,执行其他命令也要带上-g/usr/local/nginx/sbin/nginx -g "pid /usr/local/nginx/log/test.pid" #测试配置文件是否正确/usr/local/nginx/sbin/nginx -t#显示版本信息/usr/local/nginx/sbin/nginx -v#快速停止服务/usr/local/nginx/sbin/nginx -s stop#==等效于直接向master进程发送TERM和INT信号量ps -ef | grep nginx#显示如下进程:root 7309 1 0 19:05 ? 00:00:00 nginx: master process ./nginxnobody 7310 7309 0 19:05 ? 00:00:00 nginx: worker processroot 7405 2269 0 21:54 pts/0 00:00:00 grep --color=auto nginx#执行:kill -s SIGTERM 7309 orkill -s SIGINT 7309 #优雅的退出服务。关闭监听端口,停止接收请求。处理完目前的任务后停止服务/usr/local/nginx/sbin/nginx -s quit#==等效于直接向master进程发送QUIT信号量。#或者优雅的停止worker进程发送WINCH信号量#nginx重读配置项并生效。实际上会检查配置项,优雅的关闭,再启动服务/usr/local/nginx/sbin/nginx -s reload#==等效于直接向master进程发送HUP信号量。#日志文件回滚。重新生成日志文件,我们可以拷贝日志文件,以至于日志文件不会过大/usr/local/nginx/sbin/nginx -s reopen#==等效于直接向master进程发送USR1信号量。#平滑升级#向master进程发送USR2信号量。此时同时存在两个进程,可以手工平滑停止老进程
7.总结
无。
0 0
- Nginx的安装1.
- 1.nginx安装
- 1.nginx的安装
- 1.安装nginx
- 1.nginx学习笔记:nginx的安装
- nginx笔记:nginx安装
- Nginx-----源码安装nginx
- 【nginx】nginx的安装
- 安装Nginx
- nginx安装
- 安装 nginx
- 安装nginx
- 安装 Nginx
- nginx安装
- Nginx安装
- 安装Nginx
- 安装nginx
- nginx安装
- CSS里面的长度单位px/pt/em/in/pc/mm/cm解释
- isShown和inVisible的区别
- android libyuv库的使用
- 什么方法可以将pdf压缩到最小
- ETC1压缩纹理格式详解
- 1.nginx安装
- UIScrollView如何判断是向右滚动还是向左滚动
- 滚动条滚动到底部加载其他数据(Jquery+ajax)
- Spring与Quartz的整合实现定时任务调度
- Java中字符串中子串的查找方法
- java中的定时器
- 在Visual Studio Code配置GoLang开发环境
- vs2010+opencv2.4.9配置========重点说明
- 两张图 揭示 CSS动画卡顿问题