订阅
纠错
加入自媒体

nginx负载均衡一些配置的实战演示!

2021-03-01 10:19
TXP嵌入式
关注

(1)解压nginx:

(2)解压openssl:

(3)解压pcre:

(4)解压zlib:

(5)进行配置,先进入到nginx里面去,然后执行下面语句:

./configure --prefix=/usr/local/nginx
--with-http_realip_module
--with-http_addition_module
--with-http_gzip_static_module
--with-http_secure_link_module
--with-http_stub_status_module
--with-stream
--with-pcre=/home/txp/share/nginx/pcre-8.41
--with-zlib=/home/txp/share/nginx/zlib-1.2.11
--with-openssl=/home/txp/share/nginx/openssl-1.1.0g

然后直接make:

然后接着再sudo make install:

最终我们可以看到在/usr/local/nginx/目录下看到安装的nginx:

现在我们可以试着来运行nginx,并进行访问(下面的访问成功):

这里小结一下:

很多开源软件的安装步骤大概都差不多是下面这样的套路(比如等下我们下面要安装的模块,也是这样安装的思路,所以这里就不造轮子了)

-- ./cofigure

-- make

--sudo make install

2、自己写conf文件

在平时的开发过程中,主要我们要去配置它的conf文件夹下的nginx.conf文件

root@ubuntu:/usr/local/nginx# ls
client_body_temp  conf  fastcgi_temp
html  logs  proxy_temp  sbin  scgi_temp
uwsgi_temp

这个文件原本内容是:

#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

<上一页  1  2  3  下一页>  
声明: 本文由入驻维科号的作者撰写,观点仅代表作者本人,不代表OFweek立场。如有侵权或其他问题,请联系举报。

发表评论

0条评论,0人参与

请输入评论内容...

请输入评论/评论长度6~500个字

您提交的评论过于频繁,请输入验证码继续

暂无评论

暂无评论

人工智能 猎头职位 更多
扫码关注公众号
OFweek人工智能网
获取更多精彩内容
文章纠错
x
*文字标题:
*纠错内容:
联系邮箱:
*验 证 码:

粤公网安备 44030502002758号