设为首页 加入收藏

TOP

nginx-1.22.0版本安装(一)
2023-07-23 13:31:28 】 浏览:54
Tags:nginx-1.22.0 安装

nginx运行状态查看

查看80端口占用情况:
netstat -tunlp | grep 80

# 查看进程是否运行
ps -A | grep nginx

# 强制关闭nginx
pkill nginx

 

【开始安装】(引自网络教程)

https://www.runoob.com/linux/nginx-install-setup.html

将教程内下载地址替换为:https://nginx.org/download/nginx-1.22.0.tar.gz

 

【快速安装指令-无脑复制粘贴即可,安装后nginx在这里:/usr/local/nginx】

1、环境安装:

yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel wget vim

 

2、pcre安装 (目录位置/usr/local/pcre-8.35)

cd /usr/local && wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz && tar zxvf pcre-8.35.tar.gz && cd pcre-8.35 && ./configure && make && make install && cd .. && rm -rf pcre-8.35.tar.gz && pcre-config --version

 

3、nginx安装 (目录位置/usr/local/nginx)

cd /usr/local && wget https://nginx.org/download/nginx-1.22.0.tar.gz && tar zxvf nginx-1.22.0.tar.gz && cd nginx-1.22.0 && ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/pcre-8.35 && make && make install && cd .. && rm -rf nginx-1.22.0.tar.gz && rm -rf nginx-1.22.0 && /usr/local/nginx/sbin/nginx -v

 

4、配置使用用户,创建站点目录在/var/html里

/usr/sbin/groupadd www ; /usr/sbin/useradd -g www www ; mkdir /var/html ; chown -R www.www /var/html

 

5、配置nginx.conf(存放位置: /usr/local/nginx/conf)

配置文件备份后新建配置文件:

cd /usr/local/nginx/conf/ && mv nginx.conf nginx.conf-bak && vim nginx.conf

 

下方可粘贴用基础配置文件(注意在VIM里先按i进入编辑状态再粘贴):

user www www; #运行用户
#worker_processes 1; #设置值和CPU核心数一致

worker_processes auto; #1.9.10版本后可以如此配置
worker_cpu_affinity auto; #1.9.10版本后可以如此配置

error_log /usr/local/nginx/logs/nginx_error.log crit; #错误日志位置和日志级别
pid /usr/local/nginx/nginx.pid; #目录和安装位置一致才行,按教程安装的不用改目录
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
events
{
 use epoll;
 worker_connections 65535;
}
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';

 charset  utf-8;
  
 server_names_hash_bucket_size 128;
 client_header_buffer_size 32k;
 large_client_header_buffers 4 32k;
 client_max_body_size 8m;
  
 sendfile on;
 tcp_nopush on;
 keepalive_timeout 60;
 tcp_nodelay on;
 fastcgi_connect_timeout 300;
 fastcgi_send_timeout 300;
 fastcgi_read_timeout 300;
 fastcgi_buffer_size 64k;
 fastcgi_buffers 4 64k;
 fastcgi_busy_buffers_size 128k;
 fastcgi_temp_file_write_size 128k;
 gzip on;
 gzip_min_length 1k;
 gzip_buffers 4 16k;
 gzip_http_version 1.0;
 gzip_comp_level 2;
 gzip_types text/plain application/x-java script text/css application/xml;
 gzip_vary on;


 #limit_zone crawler $binary_remote_addr 10m;

#下面是server虚拟主机的配置
server
 {
  listen 80;#监听端口
  server_name localhost;#域名
  index index.html index.htm index.php; #配置增加支持php文件解析
  root /var/html;#站点目录,目录要存在
&nbs

首页 上一页 1 2 3 4 下一页 尾页 1/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇(偶尔更新)【Linux】Linux常见不.. 下一篇Linux应急响应学习

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目