【Linux】nginx 离线安装
674 字
3 分钟
【Linux】nginx 离线安装
资源下载
nginx-1.20.1.tar.gz(下载链接中包含gcc、g++、pcre、libtool、nginx)
链接:https://pan.baidu.com/s/1Niv33uZa4gj0viYFrnBTBQ
提取码:0b91
安装步骤
安装gcc
rpm -Uvh *.rpm --nodeps --force结果
[root@doris54 gcc]# rpm -Uvh *.rpm --nodeps --forcewarning: cpp-4.8.5-16.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:zlib-1.2.7-17.el7 ################################# [ 6%] 2:mpfr-3.1.1-4.el7 ################################# [ 13%] 3:libmpc-1.0.1-3.el7 ################################# [ 19%] 4:openssl-libs-1:1.0.2k-8.el7 ################################# [ 25%] 5:cpp-4.8.5-16.el7 ################################# [ 31%] 6:zlib-devel-1.2.7-17.el7 ################################# [ 38%] 7:kernel-headers-3.10.0-693.el7 ################################# [ 44%] 8:glibc-headers-2.17-196.el7 ################################# [ 50%] 9:glibc-devel-2.17-196.el7 ################################# [ 56%] 10:gcc-4.8.5-16.el7 ################################# [ 63%] 11:openssl-devel-1:1.0.2k-8.el7 ################################# [ 69%] 12:openssl-1:1.0.2k-8.el7 ################################# [ 75%] 13:openssl098e-0.9.8e-29.el7.centos.################################# [ 81%]Cleaning up / removing... 14:openssl-1:1.0.2k-19.el7 ################################# [ 88%] 15:openssl-libs-1:1.0.2k-19.el7 ################################# [ 94%] 16:zlib-1.2.7-18.el7 ################################# [100%][root@doris54 gcc]#安装g++
rpm -Uvh *.rpm --nodeps --force结果
[root@doris54 gcc-c++]# rpm -Uvh *.rpm --nodeps --forcewarning: autogen-libopts-5.18-5.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:pkgconfig-1:0.27.1-4.el7 ################################# [ 5%] 2:zlib-1.2.7-17.el7 ################################# [ 10%] 3:libcom_err-1.42.9-10.el7 ################################# [ 15%] 4:openssl-libs-1:1.0.2k-8.el7 ################################# [ 20%] 5:ntpdate-4.2.6p5-25.el7.centos.2 ################################# [ 25%] 6:zlib-devel-1.2.7-17.el7 ################################# [ 30%] 7:libsepol-devel-2.5-6.el7 ################################# [ 35%] 8:libselinux-devel-2.5-11.el7 ################################# [ 40%] 9:libverto-devel-0.2.5-4.el7 ################################# [ 45%] 10:libstdc++-devel-4.8.5-16.el7 ################################# [ 50%] 11:keyutils-libs-devel-1.5.8-3.el7 ################################# [ 55%] 12:krb5-devel-1.15.1-8.el7 ################################# [ 60%] 13:autogen-libopts-5.18-5.el7 ################################# [ 65%] 14:ntp-4.2.6p5-25.el7.centos.2 ################################# [ 70%] 15:openssl-devel-1:1.0.2k-8.el7 ################################# [ 75%] 16:gcc-c++-4.8.5-16.el7 ################################# [ 80%] 17:openssl-1:1.0.2k-8.el7 ################################# [ 85%] 18:openssl098e-0.9.8e-29.el7.centos.################################# [ 90%] 19:tcl-1:8.5.13-8.el7 ################################# [ 95%]Cleaning up / removing... 20:libcom_err-1.42.9-17.el7 ################################# [100%][root@doris54 gcc-c++]#验证gcc、g++是否安装成功,执行命令:
gcc -v结果
[root@doris54 gcc-c++]# gcc -vUsing built-in specs.COLLECT_GCC=gccCOLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapperTarget: x86_64-redhat-linuxConfigured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linuxThread model: posixgcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)[root@doris54 gcc-c++]#**安装PCRE,先把pcre解压出来,tar -zxvf pcre-8.35.tar.gz,解压出来之后就要开始安装了
cd pcre-8.35
./configure
make
make install安装libtool,先解压libtool:tar -zxvf libtool-2.4.2.tar.gz,解压出来之后就要开始安装了
cd libtool-2.4.2
./configure
make
make install安装nginx,先把nginx解压出来 tar -zxvf nginx-1.20.1.tar.gz,解压出来之后就要开始安装了**
cd nginx-1.20.1
./configure
make
make install启动nginx: nginx安装目录地址 -c nginx配置文件地址 ,安装后的路径好像会被变到/usr/local里面
| 常用命令 | 操作 |
|---|---|
| /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf | 启动nginx |
| /usr/local/nginx/sbin/nginx -s stop | 停止nginx |
| /usr/local/nginx/sbin/nginx -s reload | 重启nginx |
| netstat -tunlp | 查看端口占用 |
| netstat -tunlp | grep |
nginx的配置文件为安装目录下的nginx目录中的nginx.conf,默认端口为80,启动后出现如下页面即为启动成功
开机自启
编写自启服务
vim /usr/lib/systemd/system/nginx.service[Unit]Description=nginxAfter=network.target
[Service]Type=forkingPIDFile=/usr/local/nginx/logs/nginx.pidExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confExecReload=/usr/local/nginx/sbin/nginx -s reloadExecStop=/usr/local/nginx/sbin/nginx -s stopPrivateTmp=true
[Install]WantedBy=multi-user.target设置nginx命令
[root@node1 sbin]# vi ~/.bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then . ~/.bashrcfi
# User specific environment and startup programs# 在原有的PATH 后加 :/usr/local/nginx/sbinPATH={mathJaxContainer[0]}HOME/bin:/usr/local/nginx/sbin
export PATH[root@node1 sbin]# source ~/.bash_profile[root@node1 sbin]# nginx -vnginx version: nginx/1.18.0设置开机自启
root@node1 ~]# systemctl enable --now nginx.service[root@node1 ~]# ps -ef |grep nginxroot 879 1 0 16:17 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginxnobody 881 879 0 16:17 ? 00:00:00 nginx: worker processroot 1738 1645 0 16:20 pts/0 00:00:00 grep --color=auto nginx[root@node1 ~]#启动命令
# nginx startsudo systemctl start nginx# nginx stopsudo systemctl stop nginx# nginx reloadsudo systemctl reload nginx# nginx statussudo systemctl status nginx支持与分享
如果这篇文章对你有帮助,欢迎分享给更多人或打赏支持!
相关文章智能推荐
1
【Linux】Libgdiplus安装
Linux在CentOS 7上安装libgdiplus的过程,以解决ASP.NET Core MVC项目在处理图片时遇到的The type initializer for ‘Gdip‘ threw an exception错误。首先,通过安装yum-utils和epel-release来获取必要的工具和仓库支持。
2
【Linux】Redis 离线安装
Linux在Linux环境下离线安装Redis的全过程。文章首先提供了Redis的下载链接及解压步骤,接着详细描述了编译和安装Redis的方法,包括解决编译过程中可能遇到的问题。随后,文章介绍了如何启动Redis服务,如何设置Redis的开机自启动,这些内容对离线环境下的Redis安装和管理非常有帮助。
3
【Linux】Nacos 问题
Linux本文《【Linux】Nacos 问题》详细记录了在Linux环境下遇到的Nacos服务连接问题及其解决方法。文章还介绍了如何配置Nacos服务的开机自启动,确保服务在系统重启后能够自动运行。这些内容对解决Nacos连接问题和提高系统稳定性非常有帮助。
4
【Linux】常用命令
Linux本文档《【Linux】常用命令》详细列出了Linux系统中常用的命令及其用法,涵盖了从基本命令、关机操作、文件和目录管理、文件搜索、文件系统的挂载与卸载、磁盘空间管理、文件权限设置、文件的特殊属性、打包和压缩文件、RPM包管理、YUM软件包升级器、DEB包管理、查看文件内容、文本处理、字符设置和文件格式转换等操作。
5
【Linux】RocketMQ 部署
Linux在Linux环境下部署RocketMQ的完整过程。文章详细说明了如何通过Docker部署RocketMQ,包括创建NameServer、Broker和RocketMQ Console的服务,并提供了相应的Docker命令和配置文件示例。
随机文章随机推荐
小王的博客














