############源碼安裝nginx########################html
[root@server1 mnt]# lsnginx
drbd-8.4.2 drbd-8.4.2.tar.gz heartbeat keepalive nginx-1.10.3.tar.gzvim
[root@server1 mnt]# tar zxf nginx-1.10.3.tar.gz 瀏覽器
[root@server1 mnt]# cd nginx-1.10.3ide
[root@server1 nginx-1.10.3]# yum install pcre-devel gcc zlib-devel openssl-devel -y測試
[root@server1 nginx-1.10.3]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module#檢測依賴性spa
出現以下提示即表示成功:debug
Configuration summaryserver
+ using system PCRE libraryhtm
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL 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"
修改debug
Vim /mnt/nginx-1.10.3/auto/cc/gcc
178 # debug
179 #CFLAGS="$CFLAGS -g"
[root@server1 core]# vim /mnt/nginx-1.10.3/src/core/nginx.h
12 #define nginx_version 1010003
13 #define NGINX_VERSION "1.10.3"
14 #define NGINX_VER "nginx/"##隱藏ngnix版本信息
cd /mnt/nginx-1.10.3/
[root@server1 nginx-1.10.3]# make && make install
[root@server1 core]# cd /usr/local/nginx/
[root@server1 nginx]# ls
conf html logs sbin
[root@server1 nginx]# du -sh#f若是不修改以前的debug信息,文件大小會是5.5M
908K.
[root@server1 nginx]# cd conf/
[root@server1 conf]# useradd -u 900 -s /sbin/nologin nginx##建立一個用戶適用於該用戶
[root@server1 conf]# vim nginx.conf
2 user nginx nginx;
3 worker_processes 1;
說明:進程個數通常跟cpu個數相同,若是是兩個則爲:worker_processes 01 10; 三個:001 010 100;(cpu個數信息用lscpu查看)
[root@server1 conf]# ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/
[root@server1 conf]# nginx -t##檢測錯誤
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@server1 conf]# nginx##啓動nginx(關閉:nginx -s)
測試:在真機上的瀏覽器上輸入安裝nginx主機的ip地址:
nginx 安裝成功!!