首頁 資料庫 mysql教程 nginx安装与配置

nginx安装与配置

Jun 07, 2016 pm 03:05 PM
nginx 安裝 開始 配置

从今开始,学nginx #安装pcre [root@svr3 ~]# tar -xjf pcre-8.02.tar.bz2 -C /usr/src/ [root@svr3 ~]# cd /usr/src/pcre-8.02/ [root@svr3 pcre-8.02]# ./configure make make install #安装nginx [root@svr3 ~]# useradd -M -s /sbin/nologin nginx [root

从今开始,学nginx 
#安装pcre 
[root@svr3 ~]# tar -xjf pcre-8.02.tar.bz2 -C /usr/src/ 
[root@svr3 ~]# cd /usr/src/pcre-8.02/ 
[root@svr3 pcre-8.02]# ./configure && make && make install  
#安装nginx 
[root@svr3 ~]# useradd -M -s /sbin/nologin nginx 
[root@svr3 ~]# tar -xzf nginx-1.0.5.tar.gz -C /usr/src/ 
[root@svr3 ~]# cd /usr/src/nginx-1.0.5/ 
[root@svr3 nginx-1.0.5]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx  
[root@svr3 nginx-1.0.5]# make && make install  
 
[root@svr3 ~]#vim /usr/local/nginx/conf/nginx.conf 
+++++++++++++++相关说明+++++++++++++++++++++++++++++ 
user  nginx;          #用户使用nginx 
worker_processes  1;  #程序启动后,初始化的进程数;内核多的话,可根据内核数量设置。 
 
#error_log  logs/error.log; 
#error_log  logs/error.log  notice; 
error_log  logs/error.log  info;  #设置错误日志的记录级别 
 
pid        logs/nginx.pid;  #重启关闭nginx时,需要知道pid文件。 
 
worker_rlimit_nofile 51000; 

events { 
    worker_connections  50000;     #允许的连接数,我这里设置50000个。 

 
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  30; 
 
    gzip  on;  #允许gzip压缩。 
    gzip_buffers 32 4k;
    gzip_comp_level 1;
    gzip_min_length 1024;
    gzip_types text/html text/css application/xml;
    server { 
        listen       80; 
        server_name  localhost; 
        #charset koi8-r; 
        access_log  logs/host.access.log  main; 
        location / { 
            root   html;         #目录 
            index  index.html index.htm;   #index类型 
        } 
         #error_page  404              /404.html; 
         # redirect server error pages to the static page /50x.html 
        # 
        error_page   500 502 503 504  /50x.html; 
        location = /50x.html { 
            root   html; 
        } 
 
        #这里是关于转发的部分 
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80 
        # 
        #location ~ \.php$ { 
        #    proxy_pass   http://127.0.0.1; 
        #} 
 
        #fastcgi的部分 
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
        # 
        #location ~ \.php$ { 
        #    root           html; 
        #    fastcgi_pass   127.0.0.1:9000; 
        #    fastcgi_index  index.php; 
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name; 
        #    include        fastcgi_params; 
        #} 
 
        # deny access to .htaccess files, if Apache's document root 
        # concurs with nginx's one 
        # 
        #location ~ /\.ht { 
        #    deny  all; 
        #} 
    } 
 # another virtual host using mix of IP-, name-, and port-based configuration 
  虚拟主机的部分 

+++++++++++++++++++++++++++++++++++++++++++++ 
 
现在就配置一台主机,改了以下内容: 
    server { 
        listen       80; 
        server_name  svr3.labexam.com 10.1.1.30; 
        #charset koi8-r; 
        access_log  logs/w1.access.log  combined; 
        location / { 
            root   /var/www/w1; 
            index  index.html index.htm; 
        } 
#看了下日志 
[root@svr3 nginx]# tail /usr/local/nginx/logs/w1.access.log 
10.1.1.8 - - [15/Aug/2011:02:21:50 +0800] "GET / HTTP/1.1" 200 8 "-" "Opera/9.80 (Windows NT 5.1; U; zh-cn) Presto/2.9.168 Version/11.50" 
10.1.1.8 - - [15/Aug/2011:02:21:50 +0800] "GET /favicon.ico HTTP/1.1" 404 142 "http://svr3.labexam.com/" "Opera/9.80 (Windows NT 5.1; U; zh-cn) Presto/2.9.168 Version/11.50" 
 
===>如何启动nginx?   
方法1、执行/usr/local/nginx/sbin/nginx  -t 检查配置文件是否有误!或是直接执行/usr/local/nginx/sbin/nginx  
如果有多个配置文件可以使用指定的配置文件启动: 
#/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf   
 
===> nginx的信号控制: 
TERM,INT  快速关闭 
QUIT 从容关闭 
HUP  重启,重新加载配置文件 
USR1  重启打开日志,在切割日志时用途大 
USR2  平滑升级可执行程序 
WINCH  从容关闭进程
 
本文出自 “潜入技术的海洋” 博客

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

docker容器名稱怎麼查 docker容器名稱怎麼查 Apr 15, 2025 pm 12:21 PM

可以通過以下步驟查詢 Docker 容器名稱:列出所有容器(docker ps)。篩選容器列表(使用 grep 命令)。獲取容器名稱(位於 "NAMES" 列中)。

nginx在windows中怎麼配置 nginx在windows中怎麼配置 Apr 14, 2025 pm 12:57 PM

如何在 Windows 中配置 Nginx?安裝 Nginx 並創建虛擬主機配置。修改主配置文件並包含虛擬主機配置。啟動或重新加載 Nginx。測試配置並查看網站。選擇性啟用 SSL 並配置 SSL 證書。選擇性設置防火牆允許 80 和 443 端口流量。

怎麼查看nginx是否啟動 怎麼查看nginx是否啟動 Apr 14, 2025 pm 01:03 PM

確認 Nginx 是否啟動的方法:1. 使用命令行:systemctl status nginx(Linux/Unix)、netstat -ano | findstr 80(Windows);2. 檢查端口 80 是否開放;3. 查看系統日誌中 Nginx 啟動消息;4. 使用第三方工具,如 Nagios、Zabbix、Icinga。

nginx怎麼配置雲服務器域名 nginx怎麼配置雲服務器域名 Apr 14, 2025 pm 12:18 PM

在雲服務器上配置 Nginx 域名的方法:創建 A 記錄,指向雲服務器的公共 IP 地址。在 Nginx 配置文件中添加虛擬主機塊,指定偵聽端口、域名和網站根目錄。重啟 Nginx 以應用更改。訪問域名測試配置。其他注意事項:安裝 SSL 證書啟用 HTTPS、確保防火牆允許 80 端口流量、等待 DNS 解析生效。

docker怎麼啟動容器 docker怎麼啟動容器 Apr 15, 2025 pm 12:27 PM

Docker 容器啟動步驟:拉取容器鏡像:運行 "docker pull [鏡像名稱]"。創建容器:使用 "docker create [選項] [鏡像名稱] [命令和參數]"。啟動容器:執行 "docker start [容器名稱或 ID]"。檢查容器狀態:通過 "docker ps" 驗證容器是否正在運行。

docker怎麼創建容器 docker怎麼創建容器 Apr 15, 2025 pm 12:18 PM

在 Docker 中創建容器: 1. 拉取鏡像: docker pull [鏡像名] 2. 創建容器: docker run [選項] [鏡像名] [命令] 3. 啟動容器: docker start [容器名]

nginx怎麼查版本 nginx怎麼查版本 Apr 14, 2025 am 11:57 AM

可以查詢 Nginx 版本的方法有:使用 nginx -v 命令;查看 nginx.conf 文件中的 version 指令;打開 Nginx 錯誤頁,查看頁面的標題。

怎麼啟動nginx服務器 怎麼啟動nginx服務器 Apr 14, 2025 pm 12:27 PM

啟動 Nginx 服務器需要按照不同操作系統採取不同的步驟:Linux/Unix 系統:安裝 Nginx 軟件包(例如使用 apt-get 或 yum)。使用 systemctl 啟動 Nginx 服務(例如 sudo systemctl start nginx)。 Windows 系統:下載並安裝 Windows 二進製文件。使用 nginx.exe 可執行文件啟動 Nginx(例如 nginx.exe -c conf\nginx.conf)。無論使用哪種操作系統,您都可以通過訪問服務器 IP

See all articles