nginx使用筆記

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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章