您的位置:首页 > 运维架构 > Nginx

Linux 源码安装nginx

2017-03-23 02:04 435 查看
############源码安装nginx########################

[root@server1 mnt]# ls
drbd-8.4.2 drbd-8.4.2.tar.gz heartbeat keepalive nginx-1.10.3.tar.gz
[root@server1 mnt]# tar zxf nginx-1.10.3.tar.gz
[root@server1 mnt]# cd nginx-1.10.3
[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#检测依赖性
出现如下提示即表示成功:
Configuration summary
+ using system PCRE library
+ 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 安装成功!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux