Zero.Statement:
다음 내용은 Linux 환경에 적용되며 소스코드를 사용하여 설치됩니다.
Nginx 공식 홈페이지 설치 가이드: http://wiki.nginx .org/InstallChs
1. nginx 다운로드
1. 공식 홈페이지 다운로드: http://nginx.org/en/download.html
2. Git 다운로드: https://github.com/nginx/nginx
2. 필수 종속 라이브러리
1.pcre
<code>yum -y <span>install</span> pcre* <span>#nginx rewrite模块</span></code>
2.gcc
<code>yum -y <span>install</span> gcc gcc-c++ <span>#编译nginx</span></code>
3. nginx 설치
1. 설치 폴더 생성
<code><span>mkdir</span> -p /web/nginx</code>
2. 실행 사용자 생성
<code>groupadd www useradd <span>-r</span><span>-g</span> www www</code>
3. 컴파일 매개변수
<code><span>.</span>/configure <span>--</span>prefix<span>=</span>/web/nginx <span>--</span><span>with</span><span>-http_stub_status_module</span><span>--</span><span>with</span><span>-pcre</span></code>
가 성공적으로 구성되면 다음 내용이 출력됩니다.
4. 컴파일 및 설치
<code><span>make</span> && <span>make</span> install</code>
후 컴파일이 성공하면 다음 내용을 출력합니다
4. nginx 시작
<code>/web/nginx/sbin/nginx</code>
3 5. 설치 성공 여부 확인
1. 오픈 포트 참조 http://longdd.org/index.php/Home/Index/shows/id/158.html
2. 127.0.0.1을 방문하면 다음 인터페이스가 표시됩니다. nginx가 성공적으로 설치되었습니다
6. 기존 구성
<code><span>#user nobody;</span><span>worker_processes</span><span>1</span>; <span>#error_log logs/error.log;</span><span>#error_log logs/error.log notice;</span><span>error_log</span> logs/error.log <span>info</span>; <span>pid</span> logs/nginx.pid; <span>events</span> { <span>worker_connections</span><span>1024</span>; } <span>http</span> { <span>include</span> mime.types; <span>default_type</span> application/octet-stream; <span>log_format</span> main <span>'<span>$remote_addr</span> - <span>$remote_user</span> [<span>$time_local</span>] "<span>$request</span>" '</span><span>'<span>$status</span><span>$body_bytes_sent</span> "<span>$http_referer</span>" '</span><span>'"<span>$http_user_agent</span>" "<span>$http_x_forwarded_for</span>"'</span>; <span>access_log</span> logs/access.log main; <span>sendfile</span><span>on</span>; <span>#tcp_nopush on;</span><span>#keepalive_timeout 0;</span><span>keepalive_timeout</span><span>65</span>; <span>#gzip on;</span><span>server</span> { <span>listen</span><span>80</span>; <span>server_name</span> localhost; <span>#charset koi8-r;</span><span>#access_log logs/host.access.log main;</span><span>location</span> / { <span>root</span> html; <span>index</span> index.html index.htm; } <span>#error_page 404 /404.html;</span><span># redirect server error pages to the static page /50x.html</span><span>#</span><span>error_page</span><span>500</span><span>502</span><span>503</span><span>504</span> /50x.html; <span>location</span> = /50x.html { <span>root</span> html; } <span># proxy the PHP scripts to Apache listening on 127.0.0.1:80</span><span>#</span><span>#location ~ \.php$ {</span><span># proxy_pass http://127.0.0.1;</span><span>#}</span><span># pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000</span><span>#</span><span>#location ~ \.php$ {</span><span># root html;</span><span># fastcgi_pass 127.0.0.1:9000;</span><span># fastcgi_index index.php;</span><span># fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;</span><span># include fastcgi_params;</span><span>location</span><span>~ \.php$</span> { <span>root</span> /web/www/zhengrui/html/admin; <span>fastcgi_pass</span><span>127.0.0.1:9000</span>; <span>fastcgi_index</span> index.php; <span>include</span> fastcgi_params; <span>fastcgi_param</span> SCRIPT_FILENAME <span>$document_root</span><span>$fastcgi_script_name</span>; <span>fastcgi_param</span> SCRIPT_NAME <span>$fastcgi_script_name</span>; } <span># deny access to .htaccess files, if Apache's document root</span><span># concurs with nginx's one</span><span>#</span><span>#location ~ /\.ht {</span><span># deny all;</span><span>#}</span> } <span># another virtual host using mix of IP-, name-, and port-based configuration</span><span>#</span><span>#server {</span><span># listen 8000;</span><span># listen somename:8080;</span><span># server_name somename alias another.alias;</span><span># location / {</span><span># root html;</span><span># index index.html index.htm;</span><span># }</span><span>#}</span><span># HTTPS server</span><span>#</span><span>#server {</span><span># listen 443 ssl;</span><span># server_name localhost;</span><span># ssl_certificate cert.pem;</span><span># ssl_certificate_key cert.key;</span><span># ssl_session_cache shared:SSL:1m;</span><span># ssl_session_timeout 5m;</span><span># ssl_ciphers HIGH:!aNULL:!MD5;</span><span># ssl_prefer_server_ciphers on;</span><span># location / {</span><span># root html;</span><span># index index.html index.htm;</span><span># }</span><span>#}</span>}</code>
이상에서는 관련 내용을 포함하여 Nginx 시리즈(nginx 설치 후)를 소개했습니다. PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되길 바랍니다.