实训day16


1.静态页面
1安装httpd
[root@web ~]# yum -y install httpd
2.真机访问页面
[root@web html]# echo "静态html文件" > index.html
传入照片再次访问

静态资源,根据开发着保存在项目资源目录中的路径访问静态页面的资源

2.Apache
1.安装http
[root@http ~]# yum  -y install httpd
2.查看安装情况及安装的资源文件
[root@http ~]# rpm -ql httpd
3.查看配置文件
[root@http ~]# vim /etc/httpd/conf/httpd.conf 
4.启动httpd服务
[root@http ~]# systemctl start httpd
5.查看端口
[root@http ~]# netstat -lnput|grep http
tcp6       0      0 :::80                   :::*                    LISTEN      1503/httpd       
不能直接停用防火墙,可以单独打开端口

查看防⽕墙是否启⽤,若启⽤则设置 apache服务可通⾏规则

[root@http ~]# firewall-cmd --zone=public --add-service=http #设置防火墙方向apache
success 
打开服务器不会马上生效,需要重启或重新加载服务

停用防火墙或者打开指定端口

[root@http ~]# firewall-cmd --zone=public -add-port=80/tcp --permanet
6.页面写入
[root@http ~]# touch /var/www/html/index.html
[root@http ~]# mkdir /var/www/html/img/
[root@http ~]# vim /var/www/html/index.html 
<!doctype html>
<html>
        <head>
                <meta charset="utf-8">
                <title>正方形</title>
                <style>
                        div{
                                background-color:red;
                                width:120px;
                                height:120px;
                        }   
                </style>
        </head> 
        <body>
                <div>正方形</div>  
                <img src="img/1.jpg">
        </body> 
</html>

3.
1.下载nginx
[root@nginx ~]# wget https://nginx.org/download/nginx-1.27.0.tar.gz
2.解压
[root@nginx ~]# tar -zxvf nginx-1.27.0.tar.gz 
3.开启编译nginx
[root@nginx nginx-1.27.0]# cd nginx-1.27.0
[root@nginx ~]# yum -y install pcre-devel openssl-devel make gcc gcc-devel
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-stream
[root@nginx nginx-1.27.0]# make && make install
[root@nginx nginx-1.27.0]# useradd -s /bin/nologin -M nginx
[root@nginx nginx]# cp -r conf/ conf.bak
[root@nginx nginx]# ./sbin/nginx 
[root@nginx nginx]# netstat -lnput|grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      14100/nginx: master

4.开放端口
[root@nginx nginx]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success
5.重载防火墙
[root@nginx nginx]# firewall-cmd --reload
success
6.启动和关闭nginx服务
[root@nginx nginx]# ln -s /usr/local/nginx/sbin/nginx /usr/bin/
[root@nginx nginx]# ls -l /usr/bin/nginx
lrwxrwxrwx. 1 root root 27 7月  29 16:15 /usr/bin/nginx -> /usr/local/nginx/sbin/nginx
[root@nginx nginx]# nginx    #80端口被占用
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
^C
[root@nginx nginx]# nginx -s stop
[root@nginx nginx]# netstat -lnput|grep nginx
[root@nginx nginx]# nginx
[root@nginx nginx]# netstat -lnput|grep nginx   #已启用
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      14194/nginx: master 
./nginx #启动
./nginx -s stop  #关闭
./nginx -s reload  #重新启动
指令在命令行使用,是因为在$PATH目录中能找到这个可执行文件

7.脚本启动nginx服务
[root@nginx nginx]# vim ~/nginx.sh
#!/bin/bash
/usr/local/sbin/nginx  &> /dev/null
netstat -lnput|grep nginx
if [ $? -eq 0 ];then
    echo "ningx正在执行,或者是80被占用"

fi
[root@nginx nginx]# nginx
[root@nginx nginx]# source ~/nginx.sh
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      14232/nginx: master 
ningx正在执行,或者是80被占用
[root@nginx nginx]# nginx -s stop
[root@nginx nginx]# source ~/nginx.sh

8.

[root@nginx nginx]# 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

[root@nginx nginx]# systemctl daemon-reload
[root@nginx nginx]# systemctl stop nginx
[root@nginx nginx]# systemctl restart nginx

9.真机测试
监控模块

[root@nginx nginx]# vim /usr/local/nginx/conf/nginx.conf   #添加
 47        location /status{
 48          stub_status on;
 49          access_log off;
 50 }
 51 
[root@nginx nginx]# nginx
虚拟配置

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的C语言万年历的实训报告,供您参考: 一、实训目的 本次实训的主要目的是通过编写一个简单的C语言万年历程序,巩固C语言基本语法和编程思想,提高编程能力和解决问题的能力。 二、实训要求 1、能够使用C语言基本语法和控制语句编写程序。 2、能够使用数组来存储和操作数据。 3、能够使用函数来实现模块化编程。 4、能够使用指针来操作内存中的数据。 5、能够使用文件来读取和写入数据。 三、实训内容 1、程序功能 本程序实现了一个简单的万年历功能,可以通过输入年份和月份来显示该月的日历。 2、程序实现 以下是本程序的主要代码实现: ```c #include <stdio.h> // 判断是否为闰年 int is_leap_year(int year) { if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) { return 1; } else { return 0; } } // 获取某个月份的总天数 int get_days(int year, int month) { int days[] = {31, 28 + is_leap_year(year), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; return days[month - 1]; } // 获取某个日期是星期几 int get_weekday(int year, int month, int day) { if (month == 1 || month == 2) { year--; month += 12; } int c = year / 100; int y = year % 100; int w = y + y / 4 + c / 4 - 2 * c + 26 * (month + 1) / 10 + day - 1; w = (w % 7 + 7) % 7; return w; } // 显示日历 void show_calendar(int year, int month) { int days = get_days(year, month); int weekday = get_weekday(year, month, 1); printf(" 日 一 二 三 四 五 六\n"); int i; for (i = 0; i < weekday; i++) { printf(" "); } for (i = 1; i <= days; i++) { printf("%2d ", i); if ((weekday + i) % 7 == 0) { printf("\n"); } } if ((weekday + days) % 7 != 0) { printf("\n"); } } int main() { int year, month; printf("请输入年份:"); scanf("%d", &year); printf("请输入月份:"); scanf("%d", &month); if (month < 1 || month > 12) { printf("月份输入错误!\n"); return 1; } printf(" %d年%d月\n", year, month); show_calendar(year, month); return 0; } ``` 四、实训总结 通过本次实训,我学会了如何使用C语言来编写一个简单的万年历程序,巩固了C语言基本语法和编程思想,加强了对函数、数组、指针、文件等概念和用法的理解,提高了编程能力和解决问题的能力。同时,我也意识到在编程过程中需要注重代码的规范、可读性和可维护性,这对于日后的开发工作非常重要。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值