nginx安装 没有网络且缺少基础包的环境下
一、安装
[root@oracle ~]# cd /etc/yum.repos.d/
[root@oracle yum.repos.d]# rm -rf *
[root@oracle yum.repos.d]# vim nginx.repo
配置文件内容(redhat6.4版本)
[Server]
name=Server
baseurl=file:///media/RHEL_6.4\ x86_64\ Disc\ 1/Server
enabled=1
gpgcheck=0
[HighAvailability]
name=HighAvailability
baseurl=file:///media/RHEL_6.4\ x86_64\ Disc\ 1/HighAvailability
enabled=1
gpgcheck=0
[LoadBalancer]
name=LoadBalancer
baseurl=file:///media/iso/LoadBalancer
enabled=1
gpgcheck=0
[root@oracle yum.repos.d]# yum clean all
[root@oracle yum.repos.d]# yum update
安装依赖的包
yum -y install gcc gcc-c++ autoconf automake
yum -y install zlib zlib-devel openssl openssl-devel pcre-devel
不能使用yum的情况下安装rpm包(适合内网情况下使用)
查看已经安装的包
rpm -qa | grep gcc
rpm -qa | grep gcc-c++
rpm -qa | grep autoconf
rpm -qa | grep automake
rpm -qa | grep zlib
rpm -qa | grep zlib-devel
rpm -qa | grep openssl
rpm -qa | grep openssl-devel
rpm -qa | grep pcre-devel
一起安装
rpm -ivh gcc-4.4.7-18.el6.x86_64.rpm gcc-c++-4.4.7-18.el6.x86_64.rpm libgcc-4.4.7-18.el6.x86_64.rpm autoconf-2.63-5.1.el6.noarch.rpm automake-1.11.1-4.el6.noarch.rpm zlib-1.2.3-29.el6.x86_64.rpm zlib-devel-1.2.3-29.el6.x86_64.rpm openssl-1.0.1e-57.el6.x86_64.rpm openssl-devel-1.0.1e-57.el6.x86_64.rpm
如下是网上找的样例:
rpm -ivh mpfr-3.1.1-4.el7.x86_64.rpm
rpm -ivh libmpc-1.0.1-3.el7.x86_64.rpm
rpm -ivh kernel-headers-3.10.0-957.el7.x86_64.rpm
rpm -ivh glibc-headers-2.17-260.el7.x86_64.rpm
rpm -ivh glibc-devel-2.17-260.el7.x86_64.rpm
rpm -ivh cpp-4.8.5-36.el7.x86_64.rpm
rpm -ivh gcc-4.8.5-36.el7.x86_64.rpm
rpm -ivh pcre-8.32-17.el7.x86_64.rpm --force(由于机器上已经有低版本的pcre,所以强制安装)
rpm -ivh pcre-devel-8.32-17.el7.x86_64.rpm
rpm -ivh libstdc++-devel-4.8.5-36.el7.x86_64.rpm
rpm -ivh gcc-c++-4.8.5-36.el7.x86_64.rpm
rpm -ivh zlib-devel-1.2.7-18.el7.x86_64.rpm
创建用户
groupadd -r nginx
useradd -s /sbin/nologin -g nginx -r nginx
进入配置文件目录执行
./configure --prefix=/usr --sbin-path=/usr/sbin/ngnix --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx/pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fcgi --with-http_stub_status_module
安装
make && make install
创建目录
mkdir /var/temp/nginx/client -pv
二、常用操作
本地虚拟机环境下的操作
1、启动
/usr/sbin/ngnix -c /etc/nginx/nginx.conf
端口占用如下处理:
查看端口属于哪个程序?端口被哪个进程占用 lsof -i :8083
杀掉占用端口的进程 kill -9 进程id
2、关闭
从容停止 kill -QUIT `cat /var/run/nginx/nginx/pid`
快速停止 kill -TERM `cat /var/run/nginx/nginx/pid`
强制停止 kill -9 nginx
3 、检查nginx配置文件语法是否有错误
/usr/sbin/ngnix -t -c /etc/nginx/nginx.conf
4、重启
kill -HUP $( cat /var/run/nginx/nginx/pid)
查看服务
[root@localhost sbin]# ps aux | grep nginx
root 5531 0.0 0.0 44604 996 ? Ss 16:25 0:00 nginx: master process ngnix -c /etc/nginx/nginx.conf
nginx 5532 0.0 0.0 45032 1604 ? S 16:25 0:00 nginx: worker process
root 5540 0.0 0.0 103248 840 pts/0 S+ 16:28 0:00 grep nginx
看配置
[root@localhost nginx]# pwd
/etc/nginx
[root@localhost nginx]# vi nginx.conf