centos7 nginx 安装

xiaoxiao2021-02-28  95

1、nginx是C语言开发,建议在linux上运行,本教程使用Centos7作为安装环境。

安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gcc:

yum install gcc-c++

2、PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。nginx的http模块使用pcre来解析正则表达式,所以需要在linux上安装pcre库。

yum install -y pcre pcre-devel 3、OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。 nginx不仅支持http协议,还支持https(即在ssl协议上传输http),所以需要在linux安装openssl库。

yum install -y openssl openssl-devel 4、下载安装nginx

#下载nginx wget http://nginx.org/download/nginx-1.0.4.tar.gz #若没有安装wget 可使用: yum -y install wget 命令安装 tar -zxvf nginx-1.0.4.tar.gz cd nginx-1.0.4 ./configure make;make install [root@localhost ~]# whereis nginx nginx: /usr/local/nginx [root@localhost ~]# cd /usr/local/nginx/ [root@localhost nginx]# ls client_body_temp conf fastcgi_temp html logs proxy_temp sbin scgi_temp uwsgi_temp [root@localhost nginx]# cd sbin/ [root@localhost sbin]# ./nginx [root@localhost sbin]# ps -ef | grep nginx #查看nginx是否启动成功 root 2222 2190 0 08:54 pts/0 00:00:00 vi nginx.conf root 2230 1 0 08:57 ? 00:00:00 nginx: master process ./nginx nobody 2231 2230 0 08:57 ? 00:00:00 nginx: worker process root 2233 2190 0 08:57 pts/0 00:00:00 grep --color=auto nginxnginx默认监听本机的80 端口

关闭本机防火墙或设置80端口可访问

用浏览器访问本机ip出现welcome to nginx 则说明安装成功

转载请注明原文地址: https://www.6miu.com/read-36589.html

最新回复(0)