动态页面与静态页面的差别:
静态资源:根据开发者保存在项目资源目录中的路径访问静态的资源,包括html 图片 js css 音乐 视频
http协议
http原理:
http状态码:
[root@git ]# yum -y install httpd
 [root@git html]# echo "我是静态的html文件" > index.html
[root@git html]# dd if=/dev/zero of=/var/www/html/a.txt bs=30M count=1
apache
搭建apache服务器:

查看华为云主机的所有的打开的端口
firewall-cmd --list-ports
停用防火墙或打开指定端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload 启动端口
firewall-cmd --zone=public --add-service=http --permanent 防⽕墙开放 http服务

下载http,并执行以下操作:
touch /var/www/html/index.html
mkdir /var/www/html/img/
cp 300.3.png /var/www/html/img
vim /var/www/html/index.html

浏览器测试:

nginx
源码编译安装nginx
注意:html目录中的文件发生修改之后,不需要重启nginx服务
1.下载源码包
在nginx.org中复制nginx-1.26.1.tar.gz包的地址,在虚拟机中下载:
wget https://nginx.org/download/nginx-1.26.1.tar.gz
2.解压
tar -zxvf nginx-1.26.1.tar.gz
3.下载nginx所需要的依赖包 gcc gcc-c++ openssl-devel pcre-devel
yum -y install gcc gcc-c++ openssl-devel pcre-devel
4.编译安装nginx
./configure --prefix=/usr/local/nginx/ --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-stream
make && make install
5.nginx的启动
1)nginx的启动与关闭:

2)创建脚本来启动nginx服务:
[root@slave nginx]# vim ~/nginx.sh
3)守护进程:以systemctl控制nginx
如果直接使用sbin目录下的nginx,就无法使用systemctl
170 vim /usr/lib/systemd/system/nginx.service
[Unit]
 Description=nginx
 After=network.target
[Service]
 Type=forking
 PIDFile=/usr/local/nginx/logs/nginx.pid
 ExecStart=/usr/local/nginx/sbin/nginx
 ExecReload=/usr/local/nginx/sbin/nginx -s reload
 ExecStop=/usr/local/nginx/sbin/nginx -s stop
 PrivateTmp=Flase
[Install]
 WantedBy=multi-user.target
  
  171  systemctl daemon-reload
   172  systemctl stop nginx
   173  systemctl restart nginx
   174  reboot
   175  systemctl start nginx.service 
  
4)创建软连接:直接使用nginx命令
之所以指令能在命令行使用,是因为在$PATH目录中能找到这个可执行文件或者是可执行文件的链接文件
[root@slave nginx]# nginx
 -bash: nginx: 未找到命令
 [root@slave nginx]# $PATH 
 -bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin: 没有那个文件或目录
[root@slave nginx]# ln -s  /usr/local/nginx/sbin/nginx   /usr/bin/
 [root@slave nginx]# ls -l /usr/bin/nginx
 lrwxrwxrwx. 1 root root 27 7月  29 16:15 /usr/bin/nginx -> /usr/local/nginx/sbin/nginx
 [root@slave nginx]# nginx -s stop 
 [root@slave nginx]# netstat -lnput | grep nginx
 [root@slave nginx]# nginx
 [root@slave nginx]# netstat -lnput | grep nginx
 tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      8232/nginx: master  
  
添加监控块:
修改配置文件,找到“server { }”,添加⼀个“location { }”,也就是虚拟主机
[root@slave ~]# vim /usr/local/nginx/conf/nginx.conf

 [root@slave ~]# systemctl reload nginx.service 

配置多个虚拟主机:
location 内可以添加 nginx 各种功能模块
        location / {
             root   html;
             index  index.html index.htm;
         }
nginx反向代理配置
建立后端服务器:
  206  scp root@192.168.118.54:~/nginx-1.26.1.tar.gz ./
   207  tar -zxvf nginx-1.26.1.tar.gz 
   209  cd nginx-1.26.1/
210 yum -y install gcc gcc-c++ openssl-devel pcre-devel
  219   ./configure --prefix=/usr/local/nginx/ --user=nginx --group=nginx --with-http_ssl_module --               with-http_stub_status_module --with-http_realip_module --with-stream
   220  make 
   221  make install
   222  useradd -s /bin/nologin -M nginx
   223  echo "我是后端服务器" > /usr/local/nginx/html/index.html
  227  firewall-cmd --zone=public --add-port=80/tcp --permanent
   228  /usr/local/nginx/sbin/nginx
   234  firewall-cmd --reload
