Centos7 源码安装Nginx
· 技术积累 · Linux Nginx

在centos7下面 源码安装nginx 1.14,此版本 -> 1.2X最新版本也同样适用

创建用户、安装依赖包

#关闭selinux
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

#创建运行用户
useradd -M -s /sbin/nologin nginx

#添加epelyum源
wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo

#安装依赖包
yum -y install wget unzip bzip2 zlib zlib-devel pcre pcre-devel \
openssl openssl-devel geoip geoip-devel gd gd-devel  gcc gcc-c++ make libtool  

#包存放目录
mkdir /source && cd /source

蓝奏网盘打包打包下载 pcre|zlib|openssl 密码:8omn

# 下载依赖源码包解压
cd /data/source/
wget https://deac-riga.dl.sourceforge.net/project/pcre/pcre/8.44/pcre-8.44.tar.gz
wget https://www.zlib.net/fossils/zlib-1.2.13.tar.gz
wget https://www.openssl.org/source/old/1.1.1/openssl-1.1.1f.tar.gz

#解压
tar xf pcre-8.44.tar.gz
tar xf openssl-1.1.1f.tar.gz
tar xf zlib-1.2.13.tar.gz

下载nginx源码包、解压

wget http://nginx.org/download/nginx-1.14.1.tar.gz
tar xf nginx-1.14.1.tar.gz

配置、编译、安装

cd nginx-1.14.1
#配置:【注意:pcre,openssl,zlib路径填写解压后源码包路径 不是编译安装后路径】
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/usr/local/nginx/client_temp \
--http-proxy-temp-path=/usr/local/nginx/proxy_temp \
--http-fastcgi-temp-path=/usr/local/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/usr/local/nginx/uwsgi_temp \
--http-scgi-temp-path=/usr/local/nginx/scgi_temp \
--user=nginx \
--group=nginx \
--with-mail \
--with-stream \
--with-threads \
--with-file-aio \
--with-poll_module \
--with-select_module \
--with-http_v2_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_ssl_module \
--with-http_geoip_module \
--with-http_slice_module \
--with-http_gunzip_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_image_filter_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_stub_status_module \
--with-mail_ssl_module \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-stream_ssl_preread_module \
--with-pcre=/source/pcre-8.44 \
--with-openssl=/source/openssl-1.1.1f \
--with-zlib=/source/zlib-1.2.13

make && make install

设置系统变量

vim /etc/profile
#文件最后添加一行
export PATH=$PATH:/usr/local/nginx/sbin
#重新读取文件
source /etc/profile

或者
echo 'export PATH=$PATH:/usr/local/nginx/sbin' >>/etc/profile && source /etc/profile

启动、访问

[root@localhost ~]# nginx
[root@localhost ~]# netstat -lntp |grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      7945/nginx: master  

Centos7 源码安装Nginx

Ubuntu18.04源码安装Nginx


本文最后更新时间 2024-04-10
文章链接地址:
https://me.jinchuang.org/archives/298.html
本站文章除注明[转载|引用],均为本站原创内容,转载前请注明出处
Nginx 配置 Referer 防盗链
统计文本中每个字符出现的次数
Nali 离线ip数据库文件
苹果CMS v10内容管理系统搭建

Centos7 源码安装php7.4

configure: error: C++ compiler g++ does not work or no compiler found

我要留言