第十一周day2.png
1.nginx安装步骤:
1.1配置nginx官方yum源:
[root@web ~]# vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
1.2安装nginx:
[root@web ~]# yum install -y nginx
1.3检查配置的yum源:
[root@web01 ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
nginx | 2.9 kB 00:00:00
nginx/x86_64/primary_db | 46 kB 00:00:01
repo id repo name status
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,019
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,221
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 409
nginx/x86_64 nginx repo 152
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 1,982
repolist: 25,783
1.4检查nginx安装版本信息:
[root@web01 ~]# rpm -qa nginx
nginx-1.16.0-1.el7.ngx.x86_64
1.5检查nginx自定义文件:
[root@web01 ~]# rpm -ql nginx
/etc/logrotate.d/nginx nginx日志切割的配置文件
/etc/nginx
/etc/nginx/nginx.conf nginx主配置文件
/etc/nginx/conf.d
/etc/nginx/conf.d/default.conf nginx.conf一样
/etc/nginx/mime.types 媒体类型 (http协议中的文件类型)
/etc/nginx/fastcgi_params
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/modules
/etc/nginx/scgi_params
/etc/nginx/uwsgi_params
/etc/nginx/win-utf
/etc/sysconfig/nginx systemctl 管理 nginx的使用的文件
/usr/lib/systemd/system/nginx.service systemctl 管理nginx(开 关 重启 reload) 配置文件
/usr/sbin/nginx nginx命令
/usr/sbin/nginx-debug
/usr/share/nginx/html 站点目录 网站的根目录 www.oldboyedu.com/oldboy.jpg
/usr/share/nginx/html/50x.html
/usr/share/nginx/html/index.html
/var/cache/nginx
/var/log/nginx nginx日志 access.log 访问日志
1.6开启nginx服务和检查nginx服务进程:
[root@web01 ~]# systemctl start nginx
[root@web01 ~]# ps -ef |grep nginx
root 8398 1 0 10:51 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 8399 8398 0 10:51 ? 00:00:00 nginx: worker process
root 8425 7482 0 10:51 pts/0 00:00:00 grep --color=auto nginx
1.7检查nginx配置语法:
[root@web01 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
1.8配置hosts解析:
配置www.oldboy.com 的hosts解析
[root@web01 /etc/nginx]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.1.7 www.oldboy.com 配置www.oldboy.com 的hosts解析
检查解析是否成功
[root@web01 /etc/nginx]# ping www.oldboy.com
PING web01 (172.16.1.7) 56(84) bytes of data.
64 bytes from web01 (172.16.1.7): icmp_seq=1 ttl=64 time=0.036 ms
64 bytes from web01 (172.16.1.7): icmp_seq=2 ttl=64 time=0.055 ms
网友评论