centos7安装nginx

(1)安装gcc c++(gcc/c++是linux下常用的c/c++编译器,目的是把.c文件转换成可运行的文件)c++与g++相同
[root@localhost ~]# yum install gcc gcc-c++

例如,用vim写一个test.c文件
[root@localhost 文档]# mkdir practice //创建文件夹
[root@localhost 文档]# cd practice //到指定目录
[root@localhost practice]# touch test0924.c //创建文件
[root@localhost practice]# vim test0924.c //修改文件内容
#include<stdio.h>
int main(){
printf(“hello zmx!”);
return 0;
}
[root@localhost practice]# gcc test0924.c -o test0924 //编译文件
[root@localhost practice]# ./test0924 //运行
hello zmx! //显示结果
(2)到安装目录
[root@localhost ~]# cd /usr/local/nginx
(3)安装pcre和pcre-devel
PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,pcre-devel 是使用 pcre 开发的一个二次开发库。
[root@localhost nginx]# yum install -y pcre pcre-devel
(4)安装zlib zlib提供了很多压缩和解方式,nginx需要zlib对http进行gzip
[root@localhost nginx]# yum install -y zlib zlib-devel
(5)安装openssl openssl是一个安全套接字层密码库,nginx要支持https,需要使用openssl
[root@localhost nginx]# yum install -y openssl openssl-devel
(6)下载nginx
[root@localhost nginx]# wget http://nginx.org/download/nginx-1.14.0.tar.gz
(7)解压
[root@localhost nginx]# tar -zxvf nginx-1.14.0.tar.gz
(8)到nginx目录下
[root@localhost nginx]# ls
nginx-1.14.0 nginx-1.14.0.tar.gz
[root@localhost nginx]# cd nginx-1.14.0/
(9)编译
[root@localhost nginx-1.14.0]# ./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tem/nginx/client --http-proxy-temp-path=/var/tem/nginx/proxy --http-fastcgi-temp-path=/var/tem/nginx/fcgi --with-http_stub_status_module
(10)安装
[root@localhost nginx-1.14.0]# make && make install
(11)启动
[root@localhost nginx-1.14.0]# nginx -c /etc/nginx/nginx.conf
(12)启动过程中遇到问题
1)nginx: [emerg] getpwnam(“nginx”) failed
[root@localhost nginx-1.14.0]# useradd -s /sbin/nologin -M nginx
[root@localhost nginx-1.14.0]# id nginx
2)nginx: [emerg] mkdir() “/var/tem/nginx/client” failed (2: No such file or directory)
[root@localhost nginx-1.14.0]# sudo mkdir -p /var/tem/nginx/client
(13)nginx 配置文件检测
[root@localhost nginx-1.14.0]# nginx -c /usr/local/nginx/nginx-1.14.0/conf/nginx.conf(自己nginx配置文件路径)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值