下载 nginx.rar 按照 readme.txt 操作即可
首次安装自动下载
开启:service Nginx start
安装位置:/etc/Nginx
贴出shell文件:
#!/bin/sh #关闭进程 killpids(){ pids=($(ps -ef | grep $1 | awk '{print $2}')) for pid in ${pids[@]}; do echo "关闭进程: pid ${pid}" kill -9 ${pid} done } killpids Nginx #uninstall old rpms rmrpms(){ oldRpms=($(rpm -qa|grep $1)) for oldRpm in ${oldRpms[@]}; do echo "旧版$1: ${oldRpm}" echo "删除..." yum -y remove $1 ${oldRpm} done } rmrpms Nginx #删除 rm -rf /etc/rc.d/init.d/Nginx rm -rf /etc/logrotate.d/Nginx rm -rf /etc/sysconfig/Nginx rm -rf /etc/Nginx rm -rf /usr/lib64/Nginx rm -rf /usr/sbin/Nginx rm -rf /usr/libexec/initscripts/legacy-actions/Nginx rm -rf /usr/share/Nginx rm -rf /var/log/Nginx rm -rf /var/cache/Nginx #install Nginx echo "安装依赖" yum install -y pcre pcre-devel yum install -y zlib zlib-devel yum install -y openssl openssl-devel yum install -y python-daemon #查看CentOS版本号 centosVersion=$(rpm -q centos-release) echo "CentOS版本:$centosVersion" if [[ $centosVersion =~ "-7-" ]] then echo "安装包:Nginx-nr-agent-2.0.0-11.el7.ngx.noarch.rpm" # http://Nginx.org/packages/centos/7/noarch/RPMS/Nginx-nr-agent-2.0.0-11.el7.ngx.noarch.rpm rpm -ivh Nginx-nr-agent-2.0.0-11.el7.ngx.noarch.rpm else echo "安装包:Nginx-nr-agent-2.0.0-11.el6.ngx.noarch.rpm" # http://Nginx.org/packages/centos/6/noarch/RPMS/Nginx-nr-agent-2.0.0-11.el6.ngx.noarch.rpm rpm -ivh Nginx-nr-agent-2.0.0-11.el6.ngx.noarch.rpm fi #设置YUM源 repo='/etc/yum.repos.d/Nginx.repo' rm -rf $repo touch $repo echo '[Nginx] name=Nginx repo baseurl=http://Nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1' >> $repo #安装 yum -y install Nginx #启动并查看状态 service Nginx start service Nginx status #开机启动 echo "" echo "开机启动" chkconfig Nginx on #修改端口号 echo "端口号: 80" #显示版本 echo "version:" rpm -qa|grep Nginx echo "" #代理端口 echo '若要代理8080端口,执行如下命令: \cp -f /usr/Nginx/default.conf /etc/Nginx/conf.d/' echo ""原文链接:https://www.f2er.com/centos/377846.html