欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Linux下安裝配置nginx詳解

 更新時間:2017年01月20日 15:44:53   作者:RunningFan  
本篇文章主要介紹了Linux下安裝配置nginx,介紹了在Linux系統(tǒng)下安裝配置Nginx的詳細過程,具有一定的參考價值,有興趣的可以了解一下。

一、Linux下安裝配置nginx

第一次安裝nginx,中間出現(xiàn)的問題一步步解決。

用到的工具secureCRT,連接并登錄服務器。

1.1 rz命令,會彈出會話框,選擇要上傳的nginx壓縮包。

#rz 

1.2 解壓

[root@vw010001135067 ~]# cd /usr/local/
[root@vw010001135067 local]# tar -zvxf nginx-1.10.2.tar.gz

1.3 進入nginx文件夾,執(zhí)行./configure命令

[root@vw010001135067 local]# cd nginx-1.10.2
[root@vw010001135067 nginx-1.10.2]# ./configure

報錯如下:

checking for OS
 + Linux 2.6.32-431.el6.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found

出現(xiàn)這個錯誤。那么就是gcc 包沒有安裝。

1.3.1 安裝gcc

查看gcc

[root@vw010001135067 nginx-1.10.2]# whereis gcc
gcc:

安裝gcc

[root@vw010001135067 nginx-1.10.2]# yum -y install gcc

安裝成功后再次查看

[root@vw010001135067 nginx-1.10.2]# whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz

gcc安裝好了。

1.3.2 繼續(xù)執(zhí)行./configure

[root@vw010001135067 nginx-1.10.2]# ./configure
checking for OS
 + Linux 2.6.32-431.el6.x86_64 x86_64
checking for C compiler ... found
......
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

出現(xiàn)如上錯誤。安裝pcre-devel

[root@vw010001135067 nginx-1.10.2]# yum install pcre-devel

1.3.3 再次執(zhí)行./configure

error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

如果有這個錯誤 那么執(zhí)行

yum install zlib-devel

1.3.4 執(zhí)行./configure后沒有報錯

[root@vw010001135067 nginx-1.10.2]# ./configure
checking for OS
 + Linux 2.6.32-431.el6.x86_64 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) 
.......
Configuration summary
 + using system PCRE library
 + OpenSSL library is not used
 + md5: using system crypto library
 + sha1: using system crypto 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"

1.4 如果你想使用openssl 功能,sha1 功能。 那么安裝openssl ,sha1 吧

[root@vw010001135067 nginx-1.10.2]# yum install openssl openssl-devel 
[root@vw010001135067 nginx-1.10.2]# install perl-Digest-SHA1.x86_64

1.4.1 開啟ssl 模塊 執(zhí)行./configure –with-http_ssl_module

[root@vw010001135067 nginx-1.10.2]# ./configure --with-http_ssl_module

1.4.2 啟用“server+status”頁,執(zhí)行./configure –with-http_stub_status_module

[root@vw010001135067 nginx-1.10.2]# ./configure --with-http_stub_status_module

上面兩個命令同時啟動可以

復制代碼 代碼如下:

[root@vw010001135067 nginx-1.10.2]# ./configure --with-http_stub_status_module --with-http_ssl_module

1.5 上面configure就通過了

執(zhí)行make 命令,執(zhí)行make install 命令

[root@vw010001135067 nginx-1.10.2]# make
[root@vw010001135067 nginx-1.10.2]# make install

至此,nginx 執(zhí)行成功了

1.6 配置環(huán)境變量

在/etc/profile 中加入配置

打開配置文件

[root@vw010001135067 nginx-1.10.2]# vi /etc/profile

在配置文件中加入

#nginx configure
export NGINX_HOME=/usr/local/nginx-1.10.2
export PATH=$PATH:$NGINX_HOME/sbin

我開始像上面填寫,結果nginx -v的時候查找不到。注意到上面我的nginx_home配置的地址不對。先找到nginx的安裝地址

[root@vw010001135067 nginx-1.10.2]# whereis nginx
nginx: /usr/local/nginx

還真是地址寫錯了,把上面的改成

#nginx configure
export NGINX_HOME=/usr/local/nginx
export PATH=$PATH:$NGINX_HOME/sbin

編譯完保存退出并執(zhí)行

[root@vw010001135067 nginx-1.10.2]# source /etc/profile

使配置生效。

1.7 查看nginx版本

[root@vw010001135067 nginx]# nginx -v
nginx version: nginx/1.10.2

整個過程成功了!

二、修改nginx.conf

2.1 啟動nginx

我的nginx服務在http://10.1.135.67/,配置成功后,現(xiàn)在啟動nginx

[root@vw010001135067 nginx]# cd /usr/local/nginx
[root@vw010001135067 nginx]# nginx -c conf/nginx.conf

啟動成功,在瀏覽器打開http://10.1.135.67/,默認端口號80.

這里寫圖片描述

如上圖,nginx已經(jīng)正常工作了。

2.2 配置tomcat服務

現(xiàn)在我的tomcat服務在10.1.29.15,需要通過nginx轉發(fā)。那么打開nginx.conf,修改配置文件。如下,添加:

#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;#最大連接數(shù),默認為512
 accept_mutex on; #設置網(wǎng)路連接序列化,防止驚群現(xiàn)象發(fā)生,默認為on
 multi_accept on; #設置一個進程是否同時接受多個網(wǎng)絡連接,默認為off
 #use epoll;  #事件驅動模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport 
}


http {
 #文件擴展名與文件類型映射表
 include  mime.types;

 #默認文件類型,默認為text/plain 
 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"'; 

 #combined為日志格式的默認值
 access_log logs/access.log main;

 #允許sendfile方式傳輸文件,默認為off,可以在http塊,server塊,location塊
 sendfile  on;
 sendfile_max_chunk 100k; #每個進程每次調(diào)用傳輸數(shù)量不能大于設定的值,默認為0,即不設上限。

 #tcp_nopush  on;

 #連接超時時間,默認為75s,可以在http,server,location塊。
 keepalive_timeout 65;

 #gzip on;

 upstream upload {
  server 10.1.29.15:8080;
 }

 error_page 404 https://www.baidu.com; #錯誤頁

 server {
  keepalive_requests 120; #單連接請求上限次數(shù)。
  listen  80; #監(jiān)聽端口
  server_name localhost; #監(jiān)聽地址 

  #charset koi8-r;

  #access_log logs/host.access.log main;

  location ~ ^.*?/upload/[^/]*?$ {
   proxy_connect_timeout 15;
   proxy_send_timeout 15;
   proxy_read_timeout 15;
   proxy_set_header Host $host;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header Connection "";
   proxy_pass http://upload; #請求轉向upload 定義的服務器列表
   client_max_body_size 1024m;
} 
 }
}

配置好后,保存配置文件,并且重啟nginx

[root@vw010001135067 nginx]# nginx -s reload

在瀏覽器調(diào)用upload項目是否成功

這里寫圖片描述

如圖能正確訪問項目,配置成功!

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • Nginx隱藏服務器端各類信息的方法

    Nginx隱藏服務器端各類信息的方法

    這篇文章主要介紹了Nginx隱藏服務器端各類信息的方法,包括隱藏HTTP頭信息和PHP版本號等等,需要的朋友可以參考下
    2015-07-07
  • 詳解nginx靜態(tài)資源服務器簡單配置

    詳解nginx靜態(tài)資源服務器簡單配置

    這篇文章主要介紹了詳解nginx靜態(tài)資源服務器簡單配置,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-05-05
  • 利用Nginx反向代理與負載均衡搭建多人測試環(huán)境詳解

    利用Nginx反向代理與負載均衡搭建多人測試環(huán)境詳解

    這篇文章主要介紹了利用Nginx反向代理與負載均衡搭建多人測試環(huán)境的相關資料,文中介紹的非常詳細,相信對大家具有一定的參考價值,需要的朋友們下面來一起看看吧。
    2017-04-04
  • nginx常用配置conf的示例代碼詳解

    nginx常用配置conf的示例代碼詳解

    這篇文章主要介紹了nginx常用配置conf,包括配置vue項目,配置接口代理的代碼詳解,代碼簡單易懂,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-03-03
  • nginx代理部署Vue刷新頁面404的問題解決

    nginx代理部署Vue刷新頁面404的問題解決

    在上線vue開發(fā)的前端網(wǎng)頁部署在服務器上后,刷新頁面顯示404,本文就來介紹一下nginx代理部署Vue刷新頁面404的問題解決,感興趣的可以了解一下
    2023-12-12
  • CentOS利用Nginx搭建下載功能服務器

    CentOS利用Nginx搭建下載功能服務器

    這篇文章主要介紹了CentOS利用Nginx搭建下載功能服務器,需要的朋友可以參考下
    2017-06-06
  • Nginx安裝及具體應用小結

    Nginx安裝及具體應用小結

    Nginx 動靜分離簡單來說就是把動態(tài)請求跟靜態(tài)請求分開,Nginx 處理靜態(tài)請求,Tomcat處理動態(tài)請求,這篇文章主要介紹了Nginx安裝及具體應用小結,需要的朋友可以參考下
    2024-02-02
  • filebeat同時收集錯誤日志與普通日志并存詳解

    filebeat同時收集錯誤日志與普通日志并存詳解

    這篇文章主要為大家介紹了filebeat同時收集錯誤日志與普通日志并存詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-08-08
  • Nginx配置網(wǎng)站適配PC和手機的幾種方法

    Nginx配置網(wǎng)站適配PC和手機的幾種方法

    在開發(fā)中,我們常常會遇到需要根據(jù)用戶設備的不同,返回對應樣式的頁面,本文主要介紹了Nginx配置網(wǎng)站適配PC和手機的幾種方法,具有一定的參考價值,感興趣的可以了解一下
    2024-08-08
  • nginx如何設置服務器響應時間長短

    nginx如何設置服務器響應時間長短

    本文主要介紹了nginx如何設置服務器響應時間長短,主要介紹了兩種方法,具有一定的參考價值,感興趣的可以了解一下
    2023-09-09

最新評論