首页 > 编程知识 正文

linux如何安装nginx,linux详细教程

时间:2023-05-03 17:15:47 阅读:13966 作者:1477

Linux安装、卸载Nginx高级教程Linux版本的Nginx推荐使用源代码安装。

1 .环境需要标准的GCC编译器来编译Nginx源代码。 GCC全部称为GNUCompiler Collection,由GNU开发,由GPL和LGPL许可证颁发,是自由UNIX和苹果计算机Mac OS X操作系统的标准编译器。 由于GCC原本只能使用c语言,原名GNU C语言编译器,后来扩展迅速,可以使用c、Fortran、Pascal、Objective-C、Java和Ada等其他语言。

此外,还需要Automake工具来完成makefile的自动创建。

Nginx中的一些模块需要依赖于其他第三方库,因此通常是pcre库(支持rewrite模块)、zlib库(支持gzip模块)和openssl库) 因此,在编译Nginx源代码之前,必须安装这些库。

#gcc安装yum-y安装gcc-c # pcre安装yum-yInstallpcre-devel#zlib安装yum-yInstallzlib-devel#OpenSSL安装OpenSSL安装yum-yInstaaaation OpenSSL之所以需要安装,是因为后期nginx需要配置https,所以最好提前准备好。

在进行上述安装之前,建议使用以下命令检查是否安装了这些软件包:

yum list安装| grep * * *安装到此为止。

下载地址: Nginx官方网站地址

下载后,将nginx包上传到服务器并解压缩,然后进入解压缩后的nginx目录。

2 .源代码编译Nginx的编译安装很简单。 在Linux上,建议下载和安装tar软件包。

解压缩tar软件包进入其他配置,如tar -zxvf nginx-1.20.1.tar.gz #解压缩后的目录#配置安装路径。 如果/usr/local/nginx./configure#成功运行,缺省安装目录将增加一个Makefile文件,实际上,在运行上面的configure命令时可以配置许多参数上面的安装都使用了Nginx的默认配置。

3 .启动3.nginx#并在cd /usr/local/nginx/sbin目录中运行。 启动/nginx #启动nginx访问服务器ip,nginx欢迎页面显示正常启动的说明

验证常用命令. Nginx -t #配置文件是否正常启动。 /nginx #启动nginx./nginx -s quit #正常停止./nginx -s stop #高速停止./nginx -s reload #重装./nginx

[ root @ Zhao ym/] # PS-ef|grepnginxroot 75141010336000? 0:00336000 nginx : master process./nginx root 76027514010:12? 0336000336000 nginx :00 workerprocessroot 81442354018336007 pts/00033600336000 grep-- color=auto nginx http://www.Sina

[ root @ Zhao ym/] #/usr/local/nginx/sbin/nginx-s stop [ root @ Zhao ym/] # netstat-lntpactiveinternetconnection proto recv-QS end-qlocaladdressforeignaddressstatepid/program name TCP0.0.0. 0336666 listen 1023 shd TCP0.0.0. 033605355.0.0.0: * listen 979/systemd-resolve TCP0.0.0. 0336080.0.033: * nginx : mastertcp 60336033603360336053553360336033603360 * listen 979/systemd-resolve TCP 6033603360336021http://ww

查看Nginx相关文件: where is nginx [ root @ Zhao ym/] # whereisnginxnginx :/usr/lib 64/nginx/usr/local/nginx/usr/nginx/usr/lib 64/nginx/usr/share/nginx/usr/local/nginx usr/local/nginx/sbin/nginx RM-RF/usr

[root@localhost /]# 解决yum remove nginx依赖关系====================================================================: nginx-all-modules noarch 13:1 601.12.2-3.el7 @ epel 24k nginx-mod-http-perl x86 _ 641:1.12.2-3.el7 @ epel 54k nginx-mod-3 24k nginx 86 _ 641:1.12.2-3.el7 @ epel7====================

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。