centos 7编译安装nginx-1.10.1

由于各种原因现需要迁移一些机器到新机器上,现在需要在新机器上搭建nginx-1.10.1

这个版本也是有点历史了,不过,兵来将挡,水来土淹

nginx有很多的依赖包,首先安装一波,我可是一步一步踩出来的坑,每一个缺少依赖包都是编译错误导致出现的原因

# yum安装一些依赖包
yum -y install gcc gcc-c++ autoconf automake make perl-ExtUtils-Embed     
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel gperftools gd-devel


#从git添加ng健康检查模块
git clone https://github.com/yaoweibin/nginx_upstream_check_module.git
cd nginx_upstream_check_module

# 安装pcre依赖包 也可以选择像上边一样用yum安装
wget 'https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz'
tar -zxvf pcre-8.42.tar.gz
cd pcre-8.42
./configure
make && make install 

一切准备就绪后,就可以开始编译nginx了

./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-stream --with-stream_ssl_module --with-google_perftools_module --add-module=../nginx_upstream_check_module-master

当你看到下面这些字符时,就代表成功了,接下来就是配置启动文件,点击这里了查看 nginx启动文件配置

cp conf/nginx.conf '/etc/nginx/nginx.conf.default'
test -d '/var/run' \
	|| mkdir -p '/var/run'
test -d '/usr/local/nginx/logs' \
	|| mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' \
	|| cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' \
	|| mkdir -p '/usr/local/nginx/logs'
make[1]: 离开目录“/home/ops/nginx-1.10.1”

需要手动创建nginx属主和nginx属组。

groupadd nginx

useradd nginx -g nginx -s /sbin/nologin -M

发布了111 篇原创文章 · 获赞 31 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_24601199/article/details/103732575