首页 > 系统相关 >linux安装nginx

linux安装nginx

时间:2023-01-28 14:11:22浏览次数:44  
标签:http -- module nginx linux var path 安装

一、安装准备(参考https://tech.powereasy.net/cpzsk/wzfwqwlaq/content_23804)

1. 离线安装需要依赖GCC,通过以下命令可以检查GCC是否安装

gcc –version
银河麒麟是系统默认集成了GCC,无需要单独安装

2. 软件包下载
nginx 安装包 官方下载地址 https://nginx.org/en/download.html
所有依赖组件包下载:
ssl 功能 需要 openssl 库 下载地址: https://www.openssl.org/
gzip 模块需要 zlib 库 下载地址: http://www.zlib.net/
rewrite 模块需要 pcre 下载地址: http://www.pcre.org/

  1. 选择对应版本单击即下载 tar.gz

     找到对应版本下载

    历史版本没找到在哪里下载= =

    选择对应的版本下载即可

二、安装

上传安装文件到/home(共6个文件)

5.2.1解压缩

tar -zxvf zlib-1.2.8.tar.gz

tar -zxvf openssl-1.1.0g.tar.gz

tar -zxvf pcre-8.38.tar.gz

tar -zxvf nginx-1.12.2.tar.gz

#安装gcc,make用 命令:yum -y install gcc-c++

#yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel

5.2.2新建nginx用户和nginx组,创建需要需要的目录

groupadd -r nginx && useradd -r -g nginx -s /bin/false -M nginx

cd /var/tmp/

mkdir -p /var/tmp/nginx/{client,proxy,fastcgi,uwsgi,scgi}

mkdir /var/log/nginx

5.2.3配置,编译,安装

   切换到nginx安装目录

cd /home

mv nginx-1.12.2 nginx

cd /home/nginx

 

./configure \

--prefix=/home/nginx/ \

--sbin-path=/usr/sbin/nginx \

--conf-path=/home/nginx/conf/nginx.conf \

--error-log-path=/var/log/nginx/error.log \

--http-log-path=/var/log/nginx/access.log \

--pid-path=/home/nginx/nginx.pid  \

--lock-path=/var/lock/nginx.lock \

--user=nginx \

--group=nginx \

--with-http_ssl_module \

--with-http_dav_module \

--with-http_flv_module \

--with-http_realip_module \

--with-http_addition_module \

--with-http_stub_status_module \

--with-http_sub_module \

--with-http_random_index_module \

--with-http_degradation_module \

--with-http_secure_link_module \

--with-http_gzip_static_module \

--with-pcre=/home/pcre-8.38/ \

--with-zlib=/home/zlib-1.2.8 \

--with-openssl=/home/openssl-1.1.0g/ \

--with-debug \

--with-file-aio \

--with-mail \

--with-mail_ssl_module \

--http-client-body-temp-path=/var/tmp/nginx/client_body \

--http-proxy-temp-path=/var/tmp/nginx/proxy \

--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \

--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \

--http-scgi-temp-path=/var/tmp/nginx/scgi \

--with-stream \

--with-ld-opt="-Wl,-E"

 

make(可能报错,如果出现,则

cd /home/pcre-8.38

autoreconf -ivf 

  然后重复5.2.3

  )

make & make install

5.2.4安装成功后做成服务模式,方便启动和关闭,将nginx文件(大概2kb)复制到/etc/init.d/目录下,还有一个nginx文件(相当于exe文件,大概8MB左右) 复制到/usr/sbin/目录下(nginx的exe文件在objs下面)

[root@centos ~]# chmod 755 /etc/init.d/nginx

[root@centos ~]# chkconfig --add nginx

[root@centos ~]# chkconfig nginx on

[root@centos ~]# chkconfig --list nginx

[root@centos ~]# service nginx stop

Stopping nginx (via systemctl):                            [  OK  ]

[root@centos ~]# service nginx start

Starting nginx (via systemctl):                            [  OK  ]

5.2.5测试是否安装成功

# iptables -I INPUT -p tcp --dport 80 -j ACCEPT #开放80端口

firewall-cmd --permanent --add-port=80/tcp

 

service nginx start

  在主机浏览器中输入虚拟机IP,应该出现nginx欢迎界面

service nginx stop

 

★以下是让nginx开机自启:编辑rc.local文件:vi /etc/rc.local 

加入 /etc/init.d/nginx start  保存退出

 

下次重启会生效

如果重启后发现并没有生效,原因是rc.local这个文件没有执行 那我们修改一下rc.local的权限

chmod +x /etc/rc.d/rc.local

 

标签:http,--,module,nginx,linux,var,path,安装
From: https://www.cnblogs.com/utomboy/p/17070216.html

相关文章

  • 喷淋系统安装算量软件中的计算规则
    喷淋系统在安装算量软件中以一键式操作方式进行智能识别与提取,一键完成喷头、各规格管道、管件、阀件等工程量的计算,操作步骤大致分为:启动一键式识别、设计计算规则、检查系......
  • DELL OpenManage Server Administrator (OMSA) for Linux安装
    1.下载和安装软件包从Dell官网(选择对应的机器和操作系统版本)下载DellOpenManageServerAdministrator软件包: 以下步骤是在DellR730和redhat7.5上运行的案例:1.使......
  • 第六节:常见问题总结(npm安装包、)
    一.npm安装包       二.        三.         !作       者:Yaopengfei(姚鹏飞)博客地址:http://ww......
  • arch安装xfce4的时候,出现无法设置开机启动的问题
    sudosystemctlenablelightdm Failedtoenableunit:File/etc/systemd/system/display-manager.servicealreadyy配置开机启动的时候出现的问题是:为启动模块什么......
  • Mongo-Shake安装配置(2)
    下载地址https://github.com/alibaba/MongoShake/releases安装#tar-zxvfmongo-shake-v2.8.2.tgz&&mvmongo-shake-v2.8.2mongoshake&&mvmongoshake//usr/l......
  • ubuntu20.04安装fastdfs遇到的问题
    说明:git clone在线安装与离线安装都不成功后,选择原来可以正常运行的fastdfs服务,进行tar打包下载,再在新项目上进行解压部署。但由于打包压缩动态库的软连接失效,所以启动出......
  • macOS 上安装和配置 Flutter 开发环境
    本文基于此:Flutter中文网一、安装和运行Flutter的系统环境要求想要安装并运行Flutter,你的开发环境需要最低满足以下要求:操作系统:macOS磁盘空间:2.8GB(不包括IDE/......
  • Axure 安装使用 FontAwesome
    Axure安装使用FontAwesome.字体下载:https://www.bootcss.com/p/font-awesome/解压后,到font目录,双击FontAwesome.otf文件退出Axure重新打开后,可以看到FontAwes......
  • linux基本命令
    tail-1000fxx.out  实时查看文件catxx.out 查看文件more查看全部内容pwd 查看当前位置rm删除 rm-rf删除任何文件touch 创建文件grep过滤 参考:......
  • linux基础设置
    1、修改主机hostnamevi/etc/hostname修改hostsvi/etc/hosts192.168.10.201cdh201192.168.10.202cdh202192.168.10.203cdh203192.168.10.204cdh204重启电......