1.编译安装Nginx
环境
[root@nginx ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core)
1.安装依赖包
[root@nginx ~]# yum -y install epel-release [root@nginx ~]# yum install -y pcre pcre-devel openssl openssl-devel
2.安装Nginx
[root@nginx ~]# mkdir -p /home/dilusense/tools [root@nginx ~]# cd /home/dilusense/tools [root@nginx tools]# wget http://nginx.org/download/nginx-1.10.2.tar.gz
3.解压编译并创建用户
[root@nginx tools]# tar xvf nginx-1.10.2.tar.gz [root@nginx tools]# cd nginx-1.10.2/ [root@nginx nginx-1.10.2]# useradd -s /sbin/nologin -M www [root@nginx nginx-1.10.2]# ./configure --prefix=/usr/local/nginx-1.10.2 --user=www --group=www \ --with-http_stub_status_module --with-http_ssl_module [root@nginx nginx-1.10.2]# make && make install
4.编译安装完后做成软链接
[root@nginx nginx-1.10.2]# ln -s /usr/local/nginx-1.10.2 /usr/local/nginx
5.启动
[root@nginx nginx-1.10.2]# echo 'export PATH=$PATH:/usr/local/nginx/sbin/' >>/etc/profile [root@nginx nginx-1.10.2]# source /etc/profile [root@nginx nginx-1.10.2]# nginx [root@nginx nginx-1.10.2]# lsof -i:80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME nginx 12525 root 6u IPv4 72952 0t0 TCP *:http (LISTEN) nginx 12526 www 6u IPv4 72952 0t0 TCP *:http (LISTEN)
2.脚本
#!/bin/bash
yum -y install epel-release
yum install -y pcre pcre-devel openssl openssl-devel
mkdir -p /home/dilusense/tools
cd /home/dilusense/tools
yum install -y wget
wget http://nginx.org/download/nginx-1.10.2.tar.gz
tar xf nginx-1.10.2.tar.gz
cd nginx-1.10.2/
useradd -s /sbin/nologin -M www
./configure --prefix=/usr/local/nginx-1.10.2 --user=www --group=www \
--with-http_stub_status_module --with-http_ssl_module
make && make install
ln -s /usr/local/nginx-1.10.2 /usr/local/nginx
echo 'export PATH=$PATH:/usr/local/nginx/sbin/' >>/etc/profile
source /etc/profile
/usr/local/nginx/sbin/nginx
如无特殊说明,文章均为本站原创,转载请注明出处
- 转载请注明来源:3分钟内快速编译Nginx实践
- 本文永久链接地址:https://www.xionghaier.cn/archives/58.html