当前位置: 首页 > news >正文

做网站 怎么谈网站开发 海淀

做网站 怎么谈,网站开发 海淀,互联网网站如何做流量统计,做网站运作国珍一、系统准备 我们的服务器采用了 openEuler 22.03 (LTS-SP4) 的初始化服务器模式安装 二、安装步骤 #xff08;一#xff09;安装依赖库 在终端中运行以下命令确保系统安装了必要的依赖#xff1a; sudo dnf install -y python3上述 Python 脚本中的依赖库会在运行 Py…一、系统准备 我们的服务器采用了 openEuler 22.03 (LTS-SP4) 的初始化服务器模式安装 二、安装步骤 一安装依赖库 在终端中运行以下命令确保系统安装了必要的依赖 sudo dnf install -y python3上述 Python 脚本中的依赖库会在运行 Python 脚本时自动安装如果尚未安装的话。其中 flask 库可以使用以下命令安装 pip3 install flask二初始安装代码 以下代码用于执行系统的初始设置包括更新系统、配置网络、安装 Nginx 和配置防火墙等操作。 vi   /var/www/html/initial_setup.py   将以下代码复制粘贴到文件中 import os import subprocess import redef run_command(command):执行命令并返回输出result subprocess.run(command, shellTrue, stdoutsubprocess.PIPE, stderrsubprocess.PIPE, textTrue)if result.returncode! 0:print(fError: {result.stderr})exit(1)return result.stdoutdef update_system():更新系统到最新版本answer input(Do you want to update the system? (yes/no): )if answer.lower() yes:print(Updating system...)run_command(dnf update -y)else:print(To update the system manually, run: dnf update -y)def configure_network():配置网络设置answer input(Do you want to configure network settings? (yes/no): )if answer.lower() yes:# 获取所有网卡信息network_info run_command(ip -o link show | awk -F: {print $2})interfaces [line.strip() for line in network_info.splitlines() if lo not in line]if len(interfaces) 1:interface interfaces[0]else:print(Multiple network interfaces detected. Please select one to set the IP address:)for i, iface in enumerate(interfaces, start1):print(f{i}. {iface})choice int(input(Enter the number of your choice: )) - 1interface interfaces[choice]# 设置 IP 地址print(fSetting IP address for {interface} to 10.10.10.10/24...)run_command(fnmcli con mod \{interface}\ ipv4.addresses 10.10.10.10/24)run_command(fnmcli con mod \{interface}\ ipv4.gateway 10.10.10.2)run_command(fnmcli con mod \{interface}\ ipv4.dns 8.8.8.8)run_command(fnmcli con up \{interface}\)else:print(To configure network settings manually:)print(1. Identify network interfaces using: ip -o link show | awk -F: {print $2})print(2. Select an interface and set IP address, gateway and DNS using nmcli commands.)def install_nginx():安装 Nginx Web 服务器answer input(Do you want to install Nginx? (yes/no): )if answer.lower() yes:print(Installing Nginx...)run_command(dnf install -y nginx)run_command(systemctl enable nginx)run_command(systemctl start nginx)else:print(To install Nginx manually:)print(1. Run: dnf install -y nginx)print(2. Enable and start Nginx using systemctl.)def configure_firewall():配置防火墙answer input(Do you want to configure firewall? (yes/no): )if answer.lower() yes:print(Configuring firewall...)run_command(firewall-cmd --permanent --add-port80/tcp)run_command(firewall-cmd --permanent --add-port443/tcp)run_command(firewall-cmd --reload)else:print(To configure firewall manually:)print(1. Run: firewall-cmd --permanent --add-port80/tcp)print(2. Run: firewall-cmd --permanent --add-port443/tcp)print(3. Reload firewall using: firewall-cmd --reload)def setup_dns_and_hosts():设置 DNS 解析和修改 hosts 文件answer input(Do you want to set up DNS and hosts file? (yes/no): )if answer.lower() yes:print(Setting up DNS and hosts file...)with open(/etc/hosts, a) as f:f.write(\n10.10.10.10 www.cgqyw.com cgqyw.com\n)else:print(To set up DNS and hosts file manually:)print(Append the following line to /etc/hosts: 10.10.10.10 www.cgqyw.com cgqyw.com)def initial_setup():update_system()configure_network()install_nginx()configure_firewall()setup_dns_and_hosts()if __name__ __main__:initial_setup() 三安装文件上传服务 以下代码用于设置 Flask 文件上传服务并创建默认的 Nginx 页面。 import os from flask import Flask, render_template, request, send_from_directoryapp Flask(__name__) UPLOAD_FOLDER /var/www/html/uploads/ app.config[UPLOAD_FOLDER] UPLOAD_FOLDER# 确保上传文件夹存在 if not os.path.exists(UPLOAD_FOLDER):os.makedirs(UPLOAD_FOLDER)app.route(/) def index():# 显示所有已上传的文件列表files os.listdir(app.config[UPLOAD_FOLDER])return render_template(index.html, filesfiles)app.route(/upload, methods[POST]) def upload_file():if file not in request.files:return No file partfile request.files[file]if file.filename :return No selected fileif file:filename file.filenamefile.save(os.path.join(app.config[UPLOAD_FOLDER], filename))return File uploaded successfullyapp.route(/download/filename) def download_file(filename):return send_from_directory(app.config[UPLOAD_FOLDER], filename, as_attachmentTrue)def setup_file_upload_service():default_html !DOCTYPE htmlhtmlheadtitleWelcome to CGQYW/title/headbodyh1Welcome to CGQYW Server!/h1pThis is a simple web server./p/body/htmlwith open(/var/www/html/index.html, w) as f:f.write(default_html)app.run(debugTrue)if __name__ __main__:setup_file_upload_service()四运行程序 先运行初始安装代码注安装运行需要一些时间与网速、系统配置相关耐心等待 python3 /var/www/html/initial_setup.py再运行文件上传服务代码 python3 /var/www/html/file_upload_service.py未完待续
http://www.dnsts.com.cn/news/80766.html

相关文章:

  • 怎么用自己电脑做网站服务器人工智能培训心得体会
  • seo网站建设优化图片制作器手机版
  • 宝应网站建设网站qq弹窗
  • 网站空间 php程序怎么做付款下载网站
  • 镇海住房和建设交通局网站做婚庆策划的网站
  • h5用什么网站来做北京市建设厅门户网站6
  • aws网站建设海南网站建设
  • 资讯类网站模板下载seo资讯网
  • 计算机网站开发是什么专业WordPress 如何去域名授权
  • 怎样使用网站模板太原cms建站
  • 做淘宝客网站制作教程国内创意网站界面设计
  • 重庆企业建站系统模板上海公司招聘信息
  • app开发及后期维护费用整站seo策略实施
  • 商城网站前端更新商品天天做吗wordpress 找源码
  • 站长之家查询慈溪怎么做网站
  • 网站建设文化服务平面广告设计培训哪里学
  • 上海网站建设团队杨浦wordpress标签插件下载
  • win2008 iis配置网站吉林省建设监理协会网站
  • 深圳网站设计网站制作福州网站建设报价
  • html怎么做移动端网站三国类网页游戏前十名
  • 线上网站设计大淘客怎么做网站
  • 自己做单词卡的网站是什么机关网站建设和运行情况汇报
  • 品牌网站设计标准如何在网站上做免费代理
  • 钓鱼网站制作步骤wordpress与joomla
  • 深圳狮子会网站哪种企业适合做网站
  • 网站建设管理后台导航栏h5开发环境
  • 有没有个人做网站赚钱编写html的软件有哪些
  • 外贸网站推广 上海seo排名咨询
  • 网站建设企业熊掌号网站源码下载视频
  • 哪里网站做的好wordpress花园破解