찾다
백엔드 개발PHP 튜토리얼Linux에서 nginx 설치 및 구성에 대한 자세한 설명

1. Linux에서 nginx 설치 및 구성

nginx를 처음 설치하는 과정에서 발생하는 문제는 단계별로 해결됩니다.

서버에 연결하고 로그인하는 데 사용되는 도구는 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 폴더에 들어가서 ./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

이 오류가 발생합니다. 그러면 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 계속 실행하여 ./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.

위 오류가 발생합니다. pcre-devel

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

1.3.3을 설치하고 다시 실행하세요./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.

이 오류가 발생하면

yum install zlib-devel
를 실행하세요.

1.3.4 ./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 모듈 실행을 활성화합니다./configure –with-http_ssl_module

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

1.4.2 활성화 " server+status" 페이지에서 ./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 위의 구성에는 통과

make 명령어 실행, make install 명령어 실행

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

이때 nginx 실행 성공

1.6 환경변수 설정

/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

로 변경하세요. 🎜>

컴파일 후 저장하고 종료한 후

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


를 실행하여 구성을 적용합니다.

1.7 nginx 버전 보기

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

전체 과정이 성공적으로 완료되었습니다!

2. nginx.conf 수정

2.1 nginx 시작

내 nginx 서비스는 http://10.1.135.67/에 있습니다. 이제 nginx를 시작하세요.

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

성공적으로 시작되었습니다. 브라우저에서 http://10.1.135.67/을 엽니다. 기본 포트 번호는 80입니다.

Linux에서 nginx 설치 및 구성에 대한 자세한 설명

위와 같이 nginx는 이미 정상적으로 작동하고 있습니다.

2.2 Tomcat 서비스 구성

이제 내 Tomcat 서비스는 10.1.29.15에 있으며 nginx를 통해 전달되어야 합니다. 그런 다음 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;#最大连接数,默认为512
 accept_mutex on; #设置网路连接序列化,防止惊群现象发生,默认为on
 multi_accept on; #设置一个进程是否同时接受多个网络连接,默认为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 &#39;$remote_addr - $remote_user [$time_local] "$request" &#39;
      &#39;$status $body_bytes_sent "$http_referer" &#39;
      &#39;"$http_user_agent" "$http_x_forwarded_for"&#39;; 
 
 #combined为日志格式的默认值
 access_log logs/access.log main;
 
 #允许sendfile方式传输文件,默认为off,可以在http块,server块,location块
 sendfile  on;
 sendfile_max_chunk 100k; #每个进程每次调用传输数量不能大于设定的值,默认为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; #单连接请求上限次数。
  listen  80; #监听端口
  server_name localhost; #监听地址 
 
  #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

브라우저에서 업로드 프로젝트 호출 성공 여부

Linux에서 nginx 설치 및 구성에 대한 자세한 설명

그림과 같이 프로젝트에 올바르게 접근이 되면서 설정에 성공하게 됩니다!

위 내용은 이 글의 전체 내용입니다. 모든 분들의 학습에 도움이 되기를 바랍니다.

Linux에서 nginx 설치 및 구성에 대한 자세한 내용을 보려면 PHP 중국어 웹사이트를 참고하세요!

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
PHP 세션의 개념을 간단한 용어로 설명하십시오.PHP 세션의 개념을 간단한 용어로 설명하십시오.Apr 26, 2025 am 12:09 AM

phpsessionstrackuserdataacrossmultiplepagerequestsususingauniqueIdStoredInAcookie.here'showtomanagetheMeftically : 1) STARTASESSIONSTART_START () andSTAREDATAIN $ _SESSION.2) RegenerATERATESSESSIDIDAFTERLOGINWITHSESSION_RATERATERATES (True) TopreventSES

PHP 세션에 저장된 모든 값을 어떻게 반복합니까?PHP 세션에 저장된 모든 값을 어떻게 반복합니까?Apr 26, 2025 am 12:06 AM

PHP에서 세션 데이터를 통한 반복은 다음 단계를 통해 달성 할 수 있습니다. 1. Session_start ()를 사용하여 세션을 시작하십시오. 2. $ _session 배열의 모든 키 값 쌍을 통해 Foreach 루프를 통과합니다. 3. 복잡한 데이터 구조를 처리 할 때 is_array () 또는 is_object () 함수를 사용하고 print_r ()를 사용하여 자세한 정보를 출력하십시오. 4. Traversal을 최적화 할 때 페이징을 사용하여 한 번에 많은 양의 데이터를 처리하지 않도록 할 수 있습니다. 이를 통해 실제 프로젝트에서 PHP 세션 데이터를보다 효율적으로 관리하고 사용하는 데 도움이됩니다.

사용자 인증에 세션을 사용하는 방법을 설명하십시오.사용자 인증에 세션을 사용하는 방법을 설명하십시오.Apr 26, 2025 am 12:04 AM

이 세션은 서버 측 상태 관리 메커니즘을 통해 사용자 인증을 인식합니다. 1) 세션 생성 및 고유 ID의 세션 생성, 2) ID는 쿠키를 통해 전달됩니다. 3) ID를 통해 서버 저장 및 세션 데이터에 액세스합니다. 4) 사용자 인증 및 상태 관리가 실현되어 응용 프로그램 보안 및 사용자 경험이 향상됩니다.

PHP 세션에 사용자 이름을 저장하는 방법의 예를 제시하십시오.PHP 세션에 사용자 이름을 저장하는 방법의 예를 제시하십시오.Apr 26, 2025 am 12:03 AM

tostoreauser'snameinaphpsession, startSessionstart_start (), wathsignthenameto $ _session [ 'username']. 1) useSentess_start () toinitializethesession.2) assimeuser'snameto $ _session [ 'username']

PHP 세션이 실패 할 수있는 몇 가지 일반적인 문제는 무엇입니까?PHP 세션이 실패 할 수있는 몇 가지 일반적인 문제는 무엇입니까?Apr 25, 2025 am 12:16 AM

phpsession 실패 이유에는 구성 오류, 쿠키 문제 및 세션 만료가 포함됩니다. 1. 구성 오류 : 올바른 세션을 확인하고 설정합니다. 2. 쿠키 문제 : 쿠키가 올바르게 설정되어 있는지 확인하십시오. 3. 세션 만료 : 세션 시간을 연장하기 위해 세션을 조정합니다 .GC_MAXLIFETIME 값을 조정하십시오.

PHP의 세션 관련 문제를 어떻게 디버그합니까?PHP의 세션 관련 문제를 어떻게 디버그합니까?Apr 25, 2025 am 12:12 AM

PHP에서 세션 문제를 디버그하는 방법 : 1. 세션이 올바르게 시작되었는지 확인하십시오. 2. 세션 ID의 전달을 확인하십시오. 3. 세션 데이터의 저장 및 읽기를 확인하십시오. 4. 서버 구성을 확인하십시오. 세션 ID 및 데이터를 출력, 세션 파일 컨텐츠보기 등을 통해 세션 관련 문제를 효과적으로 진단하고 해결할 수 있습니다.

session_start ()가 여러 번 호출되면 어떻게됩니까?session_start ()가 여러 번 호출되면 어떻게됩니까?Apr 25, 2025 am 12:06 AM

Session_Start ()로 여러 통화를하면 경고 메시지와 가능한 데이터 덮어 쓰기가 발생합니다. 1) PHP는 세션이 시작되었다는 경고를 발행합니다. 2) 세션 데이터의 예상치 못한 덮어 쓰기를 유발할 수 있습니다. 3) Session_status ()를 사용하여 반복 통화를 피하기 위해 세션 상태를 확인하십시오.

PHP에서 세션 수명을 어떻게 구성합니까?PHP에서 세션 수명을 어떻게 구성합니까?Apr 25, 2025 am 12:05 AM

SESSION.GC_MAXLIFETIME 및 SESSION.COOKIE_LIFETIME을 설정하여 PHP에서 세션 수명을 구성 할 수 있습니다. 1) SESSION.GC_MAXLIFETIME 서버 측 세션 데이터의 생존 시간을 제어합니다. 2) 세션 .Cookie_Lifetime 클라이언트 쿠키의 수명주기를 제어합니다. 0으로 설정하면 브라우저가 닫히면 쿠키가 만료됩니다.

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

Eclipse용 SAP NetWeaver 서버 어댑터

Eclipse용 SAP NetWeaver 서버 어댑터

Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기

에디트플러스 중국어 크랙 버전

에디트플러스 중국어 크랙 버전

작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

SublimeText3 영어 버전

SublimeText3 영어 버전

권장 사항: Win 버전, 코드 프롬프트 지원!

맨티스BT

맨티스BT

Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.