centos7.6离线安装nginx1.18.0
1、安装依赖关系
#有yum源时安装依赖
yum install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel -y

无yum源时自行上传依赖软件包,进入该文件夹

cd /yilai
yum localinstall *

2、解压nginx

tar zxvf nginx-linux-1.18.0.tar.gz

3、设置

cd nginx-1.18.0
./configure --prefix=/www/server/nginx --with-http_ssl_module --with-stream --with-stream_ssl_module

4、编译安装:

make
make install

5、控制nginx

启动
/www/server/nginx/sbin/nginx
停止
/www/server/nginx/sbin/nginx -s stop
载入配置
/www/server/nginx/sbin/nginx -s reload

6、修改配置

vim /www/server/nginx/conf/nginx.conf

修改user ngbody为:

user nginx;

修改线程worker_processes 1为:
worker_processes auto;
修改最大连接数worker_connections 1024为:
worker_connections 65530;
在最后一行的}上面插入一行:
include /www/server/nginx/conf/conf.d/*.conf;
注:轮询负载均衡需在http {下新加如下内容,进行跳转时转到cibheat上。
upstream heat{
server 192.168.0.100:8080;
server 192.168.0.101:8080;
server example.com:8080;
}

server段:

server {
        listen 80;
        server_name www.abc.com;

        location / {
            proxy_pass "http://heat";
            proxy_set_header X-Forwarded-For $remote_addr;
         }
}

7、新建配置文件目录

mkdir /www/server/nginx/conf/conf.d

8、新建配置文件

vim /www/server/nginx/conf/conf.d/heat.conf

php项目写入如下内容:

server {
        listen    8080;
        server_name www.qqq.com  192.168.1.205;
        root   /www/server/www/heat/public;

        location /admin {
            index  index.html index.htm index.php;

            if (!-e $request_filename){
                rewrite  ^(.*)$  /index.php?s=$1  last;   break;
            }
        }

        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
        access_log  /www/server/nginx/logs/heat.log;
        error_log  /www/server/nginx/logs/heat.error.log;
}
9、反向代理
server {
        listen       80;
        server_name www.qqq.com;

        location /
        {
            proxy_pass "http://127.0.0.1:8080";
            proxy_set_header X-Forwarded-For $remote_addr;
           #下面这行的作用是把原http请求的Header中的Host字段也放到转发的请求里。如果不加这一行的话,nginx转发的请求header里就不会有Host字段,而服务器是靠这个Host值来区分你请求的是哪个域名的资源的。
            proxy_set_header Host $host:$server_port;
            #获取真实IP
            proxy_set_header X-Real-IP $remote_addr;
        }
}

10、设置

关闭版本显示
server_tokens  off;
上传文件大小限制
client_max_body_size 1024M;
设置为on表示启动高效传输文件的模式
sendfile on;
保持连接的时间,默认65s
keepalive_timeout 1800s;
11、载入配置
/www/server/nginx/sbin/nginx -s reload

12、加入启动项

sed -i '$a/bin/su - nginx -c "/www/server/nginx/sbin/nginx"' /etc/rc.d/rc.local && chmod +x /etc/rc.d/rc.local

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇