checking for OS + Linux 3.10.0-957.el7.x86_64 x86_64 checking for C compiler ... not found ./config

本文详细介绍了在CentOS7系统上从源码编译安装nginx的过程,包括必要的依赖包安装、源码下载、编译配置及常见错误解决方法。通过遵循本文步骤,读者可以顺利完成nginx的安装并进行基本测试。

                                 解压目录执行编译参数配置./configure --prefix=/usr/local/nginx

linux版本:CentOS7 64位

在安装nginx前首先要确认系统中安装了gcc、pcre-devel、zlib-devel、openssl-devel

nginx下载地址:https://nginx.org/download/

下载“nginx-1.9.9.tar.gz”,移动到/usr/local/下。

## 解压
tar -zxvf nginx-1.9.9.tar.gz

##移动
mv nginx-1.9.9 nginx

##进入nginx目录
cd nginx

## 配置,这一步可能会出现各种的错误,在下面会一一列出。
./configure --prefix=/usr/local/nginx

 

错误信息

checking for OS
+ Linux 3.10.0-327.el7.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found

解决方法:安装gcc

yum -y install gcc

错误信息

./configure: error: the HTTP rewrite module requires the PCRE library.

解决方法:安装pcre-devel

yum install pcre-devel

错误信息

./configure: error: the HTTP gzip module requires the zlib library.

解决方法:安装zlib-devel

yum install zlib-devel

 

再次执行“./configure --prefix=/usr/local/nginx”

正确的结果如下:

    技术分享

OK,现在可以执行make 了。 如果你想使用openssl 功能,sha1 功能就需要安装openssl ,sha1。

yum -y install openssl openssl-devel

开启ssl 模块

./configure --with-http_ssl_module

   技术分享

执行make、make install命令

测试是否安装成功

./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

启动nginx 

cd /usr/local/nginx/sbin
./nginx //启动nginx

在浏览器中输入服务器的ip地址,如:192.168.1.12

很不幸,打不开链接。下面进行原因排查:

    技术分享

    技术分享

说明服务器的80端口是打不开的。

因为我使用的linux系统版本是CentOS7,所以可以在服务器中执行如下命令来验证》》

firewall-cmd --query-port=80/tcp

    技术分享

显然80端口没有开启。

下面我们开启80端口:

    技术分享

刷新浏览器

    技术分享

====================== 分割线 ====================

配置完毕!

[root@VM-8-4-centos nginx-1.24.0]# ./configure --prefix=/usr/nginx checking for OS + Linux 3.10.0-1160.119.1.el7.x86_64 x86_64 checking for C compiler ... found + using GNU C compiler + gcc version: 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) checking for gcc -pipe switch ... found checking for -Wl,-E switch ... found checking for gcc builtin atomic operations ... found checking for C99 variadic macros ... found checking for gcc variadic macros ... found checking for gcc builtin 64 bit byteswap ... found checking for unistd.h ... found checking for inttypes.h ... found checking for limits.h ... found checking for sys/filio.h ... not found checking for sys/param.h ... found checking for sys/mount.h ... found checking for sys/statvfs.h ... found checking for crypt.h ... found checking for Linux specific features checking for epoll ... found checking for EPOLLRDHUP ... found checking for EPOLLEXCLUSIVE ... not found checking for eventfd() ... found checking for O_PATH ... found checking for sendfile() ... found checking for sendfile64() ... found checking for sys/prctl.h ... found checking for prctl(PR_SET_DUMPABLE) ... found checking for prctl(PR_SET_KEEPCAPS) ... found checking for capabilities ... found checking for crypt_r() ... found checking for sys/vfs.h ... found checking for UDP_SEGMENT ... not found checking for nobody group ... found checking for poll() ... found checking for /dev/poll ... not found checking for kqueue ... not found checking for crypt() ... not found checking for crypt() in libcrypt ... found checking for F_READAHEAD ... not found checking for posix_fadvise() ... found checking for O_DIRECT ... found checking for F_NOCACHE ... not found checking for directio() ... not found checking for statfs() ... found checking for statvfs() ... found checking for dlopen() ... not found checking for dlopen() in libdl ... found checking for sched_yield() ... found checking for sched_setaffinity() ... found checking for SO_SETFIB ... not found checking for
04-24
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值