上海建设银行官网网站6,网站开发最新书籍,软件开发外包价格,小猫济南网站建设公司一#xff0e;Web
为用户提供互联网上浏览信息的服务#xff0c;web服务是动态的#xff0c;可交互的。
1.安装httpd
yum -y install httpd
2.启动
systemctl start httpd
3.关闭防火墙
systemctl stop firewalld
[rootrs html]# echo 我手机号是 …一Web
为用户提供互联网上浏览信息的服务web服务是动态的可交互的。
1.安装httpd
yum -y install httpd
2.启动
systemctl start httpd
3.关闭防火墙
systemctl stop firewalld
[rootrs html]# echo 我手机号是 index.html
[rootrs html]# ls
index.html
4.在浏览器中输入ip地址进行访问
二http协议
1.http特点 静态文件和动态文件
生成一个大文件
dd if/dev/zero of/var/www/html/a.txt bs30M count1
2.UEI和URL的区别 http状态码 三Apache
最早的web服务基于http提供浏览器浏览
1.查看华为云主机所有打开的端口
firewall-cmd --list-ports
2.在虚拟机上停用防火墙远程主机就无法访问web服务
3.搭建apache服务器
1查看安装情况
[rootrs ~]# rpm -qa|grep httpd
2配置文件
[rootrs ~]# vim /etc/httpd/conf/httpd.conf 启3启动http服务
[rootrs ~]# systemctl start httpd
4在浏览器访问
5在windows客户端scp一张图到/var/www/html下
[rootrs ~]# cd /var/www/html
[rootrs html]# mkdir img [rootrs html]# vim /var/www/html/index.html
!doctype html
html head meta charsetutf-8 title正方形/title style div{ background-color:red; width:120px; height:120px; } /style /head body div正方形/div img srcimg/000.jpg / /body
/html
6在浏览器访问 四Nginx
开源轻量级高性能的http和反向代理服务器
1.特点占用内存少并发能力强
2.作用用来做负载均衡和反向代理
安装nginx
源码编译安装
3.下载源码包
[rootweb ~]# wget https://nginx.org/download/nginx-1.26.1.tar.gz
4.解压
[rootweb ~]# tar -zxvf nginx-1.26.1.tar.gz
[rootweb ~]# yum -y install gcc gcc-c
[rootweb ~]# yum -y install openssl-devel
[rootweb ~]# yum -y install pcre-devel
[rootweb ~]# yum -y install make
5.编译安装nginx
[rootweb nginx-1.26.1]# ./configure --prefix/usr/local/nginx --usernginx --groupnginx --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-stream [rootweb nginx-1.26.1]# make make install
[rootweb nginx-1.26.1]# useradd -s /bin/nologin -M nginx //创建nginx用户和组不然无法启动
6.检查目录
[rootweb nginx-1.26.1]# tree /usr/local/nginx/
7.启动nginx
[rootweb nginx]# ./sbin/nginx
8.查看主要配置文件
vim /usr/local/nginx/conf/nginx.conf
9.优化nginx服务控制
[rootweb nginx]# ln -s /usr/local/nginx/sbin/nginx /usr/bin/ //做一个软连接
[rootweb nginx]# nginx
之所以指令能在命令行使用是因为在$PATH目录中能找到这个可执行文件或者是可执行文件的链接文件
1修改配置文件后重载nginx服务
./nginx -s reload
2脚本启动nginx
[rootweb nginx]# vim ~/nginx.sh
#!/bin/bash
/usr/local/sbin/nginx /dev/null
netstat -lnput|grep nginx
if [ $? -eq 0 ];then echo nginx正在执行或者80端口被占用
fi
[rootweb nginx]# source ~/nginx.sh 3以systemctl控制nginx
[rootweb nginx]# ls /usr/lib/systemd/system
[rootweb nginx]# vim /usr/lib/systemd/system/nginx.service
[Unit] Descriptionnginx Afternetwork.target [Service] Typeforking 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 PrivateTmpFlase [Install] WantedBymulti-user.target [rootweb nginx]# systemctl daemon-reload //重置systemctl进程
如果使用sbin目录下的nginx就无法使用systemctl
优化注意事项 10.开启nginx状态监听模块
1修改配置文件
[rootweb ~]# vim /usr/local/nginx/conf/nginx.conf //在48行添加
location /status { stub_status on; #nginx状态的监听模块 access_log off; } 2重启nginx
[rootweb ~]# systemctl reload nginx
3在浏览器访问查看nginx状态信息
192.168.2.35/status 11.nginx虚拟主机配置
⼀个“location”相当于⼀个虚拟主机也就是⽤户访问⽹站时
点击跳转的另⼀个⻚⾯。
location 内可以添加 nginx 各种功能模块。
配置多个虚拟主机
[rootserver ~]# vim /usr/local/nginx/conf/nginx.conf
......省略部分内容......
server {
listen 80; #监听端⼝
server_name localhost;
charset utf-8; #中文字符集
#access_log logs/host.access.log main;
location /status {
stub_status on;
access_log off;
}
location / {
root html; #⽹站在服务器上的⽬ 录默认为/usr/local/nginx/html
index index.html index.htm; #跳转到的⽹站⾸⻚
}
}
......省略部分内容......
[rootserver ~]# systemctl restart nginx.service
#重启nginx 12.nginx反向代理
再准备一台机器---tomcat 跟上面一样安装nginx编译并安装
[rootserver ~]# wget https://nginx.org/download/nginx-1.26.1.tar.gz
解压
[rootserver ~]# tar -zxvf nginx-1.26.1.tar.gz
[rootserver ~]# yum -y install gcc gcc-c
[rootserver ~]# yum -y install openssl-devel
[rootserver ~]# yum -y install pcre-devel
[rootserver ~]# yum -y install make
编译安装nginx
[rootserver nginx-1.26.1]# ./configure --prefix/usr/local/nginx
[rootserver nginx-1.26.1]# make make install
[rootserver nginx-1.26.1]# useradd -s /bin/nologin -M nginx
[rootserver nginx-1.26.1]# echo 我是后端服务 /usr/local/nginx/html/index.html
[rootserver nginx-1.26.1]# firewall-cmd --zonepublic --add-port80/tcp --permanent //打开端口
success
[rootserver nginx-1.26.1]# firewall-cmd --reload //重新加载防火墙
Success
[rootserver nginx-1.26.1]# vim /usr/local/nginx/conf/nginx.conf
[rootserver nginx-1.26.1]# /usr/local/nginx/sbin/nginx