1)将软件安装在根目录下
[root@localhost ~]# pwd
/root
2)wget下载nginx
[root@localhost ~]# wget http://nginx.org/download/nginx-1.10.1.tar.gz
--2019-07-07 15:42:13-- http://nginx.org/download/nginx-1.10.1.tar.gz
Resolving nginx.org (nginx.org)... 95.211.80.227, 62.210.92.35, 2001:1af8:4060:a004:21::e3
Connecting to nginx.org (nginx.org)|95.211.80.227|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 909077 (888K) [application/octet-stream]
Saving to: ‘nginx-1.10.1.tar.gz’
100%[===================================================================================================================================================>] 909,077 31.1KB/s in 36s
2019-07-07 15:42:49 (24.9 KB/s) - ‘nginx-1.10.1.tar.gz’ saved [909077/909077]
3)查看虚拟机的时间,发现不一致。
[root@localhost ~]# date
Sun Jul 7 15:43:20 EDT 2019
4)调整时间
[root@localhost ~]# yum -y install ntpdate
[root@localhost ~]# ntpdate cn.pool.ntp.org
7 Jul 06:45:56 ntpdate[2751]: step time server 202.108.6.95 offset -32395.079164 sec
[root@localhost ~]# date
Sun Jul 7 06:46:01 EDT 2019
5)解压
[root@localhost ~]# tar -zxvf nginx-1.10.1.tar.gz
6)安装依赖
[root@localhost nginx-1.10.1]# yum -y install pcre-devel openssl-devel
7)安装
./configure \
--prefix=/usr/local/nginx \
--with-http_ssl_module
make && make install
8)启动编译后的nginx
[root@localhost ~]# cd /usr/local/nginx/sbin
[root@localhost sbin]# ./nginx
9)查看启动nginx后,进程
[root@localhost sbin]# ps aux | grep nginx
root 16440 0.0 0.1 45900 1116 ? Ss 06:59 0:00 nginx: master process ./nginx
nobody 16441 0.0 0.1 46340 1888 ? S 06:59 0:00 nginx: worker process
root 16445 0.0 0.0 112712 972 pts/0 S+ 06:59 0:00 grep --color=auto nginx
10)停止nginx
直接杀死nginx
[root@localhost sbin]# ./nginx -s stop
柔和的关闭nginx
[root@localhost sbin]# ./nginx -s quit
11)修改环境变量,方便从其他目录启动nginx
[root@localhost ~]# vi /etc/profile
最下面添加:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
esc
wq
source /etc/profile
12)添加软连接到搜索路径下。
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/nginx
13)查看外链
[root@localhost ~]# cd /usr/local/sbin/
[root@localhost sbin]# ll
total 0
lrwxrwxrwx. 1 root root 27 Jul 7 16:18 nginx -> /usr/local/nginx/sbin/nginx
14)修改配置后
重启nginx:
nginx -s reload
启动nginx:
nginx
停止nginx:
nginx -s quit
15)
curl http://192.168.40.128
16)
http://archive.kernel.org/centos-vault/6.8/isos/x86_64/CentOS-6.8-x86_64-bin-DVD1.iso
vim /etc/sysconfig/i18n
17)虚拟机窗口全屏变大
查看-->自动调整大小-->自动适应客户机/自动调整大小
18)centos 6.8
[root@localhost ~]# cd ..
[root@localhost /]# ls
bin dev home lib64 media mnt opt root selinux sys usr
boot etc lib lost+found misc net proc sbin srv tmp var
19)./configure: error: C compiler cc is not found
解决:
yum -y install gcc gcc-c++ autoconf automake make
20)
curl http://192.168.40.129
21)检查语法错误
nginx -t