1.nginx小试牛刀
yum install nginx -y
系统默认是没有这个nginx安装包的。
2.简单了解,给你的机器,配置一个软件仓库(360软件大师,点点点,下载各种工具,它的软件,还携带了一堆广告)
配置阿里云的软件仓库
https://developer.aliyun.com/mirror/
这里配置下载2个软件仓库 (centos和redhat系统的关系)
# wget -O 指定文件存放到哪里 资源的下载链接
# 直接下载Centos-7.repo这个文件,到当前目录
wget https://mirrors.aliyun.com/repo/Centos-7.repo
# 不但下载资源,且指定到某一个路径下
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
3.既然机器有了软件仓库,即可下载各种应用了
[root@localhost opt]# yum install nginx -y
4. 就可以启动该应用
[root@localhost opt]# systemctl start nginx
5.程序运行了,如何判断他运行?
windows
任务管理器
查看进程,就是一个个运行中的软件,在消耗系统的资源
linux
任务管理器
查看进程
查看nginx这个程序的进程
执行ps命令
命令是 ,仅仅查看这个机器上的 nginx进程信息,是否存在
ps -ef |grep nginx
6. 一个网站的运行,默认端口是 http的80端口
用你的客户端,浏览器去访问,
10.96.0.134:80即可
7.注意关闭服务器的防火墙
执行命令
[root@localhost opt]# iptables -F
8.停止这个网站服务,思路是?
停用80端口,也就是,停止这个软件的运行
[root@localhost opt]# systemctl stop nginx
再次重新运行,命令是
systemctl restart nginx
8.可以修改该软件的配置了,比如网站首页的内容
完成1分钟,做一个dnf官网
下载该网址的首页html文件
wget https://dnf.qq.com/main.shtml
移动,拷贝该文件,到你的nginx网站目录下, 它会自动识别
移动 /opt/main.shtml 到/usr/share/nginx/html/ 目录下,且重命名为index.html
[root@localhost opt]# mv /opt/main.shtml /usr/share/nginx/html/index.html
mv: overwrite ‘/usr/share/nginx/html/index.html’? y
9.当你修改了网站的前端页面,无须重启,网站自动更新
http://10.96.0.134/
完成练习效果,访问你的linux机器地址,看到一个有内容的网址即可。
课程里是dnf官网,自行更换其他html文件。