关于: "运维":

ssh_linux

cd myprojectdir
source myprojectenv/bin/activate
sudo systemctl restart gunicorn
sudo systemctl restart nginx 
goaccess /var/log/nginx/access.log -o report2.html --log-format=COMBINED


14天

zcat /var/log/nginx/access.log.*.gz | goaccess \
  --log-format=COMBINED \
  --geoip-database /usr/local/share/GeoIP/GeoLite2-City.mmdb \
  -o reportip.html


1天

goaccess /var/log/nginx/access.log \
  --log-format=COMBINED \
  --geoip-database /usr/local/share/GeoIP/GeoLite2-City.mmdb \
  -o report_615.html


check css



n5321 | 2025年3月27日 17:37

devops Bug

把online的内容做了一个大的更新。然后网页蹦了

一直NGINX的502,做了大量的尝试。在运维上面的理解确实也不够!脑子里大概知道一个框架。但是gunicorn and nginx的配置没改,结果却是登不上网站。确实是烦躁。

尝试了各种办法。

中间的关键是丢了run/gunicorn.sock这个文件。怎么丢的搞不清楚。各种办法都试过了,有点烦。试着重启了一下linux的系统,居然好了。×

当然这次的linux重启确实是已经跑了两个月了。不过,确实要算是很有意思的体验。这样也行!

另外一个特殊一点的东西就是居然online的performance比本地的好了一倍!index页面pc上面打开要接近1s,可是online打开只要0.5s,linux的power吗?!


n5321 | 2025年2月16日 00:36

腾讯云操作手册

https://orcaterm.cloud.tencent.com/terminal?type=lighthouse&instanceId=lhins-rmuhs9ke®ion=ap-shanghai&from=lh_console_login_btn

进了ubuntu的操作界面。

云端构建网站、Web应用、小程序/小游戏、APP、电商应用、云盘/图床和各类开发测试环境,相比普通云服务器更加简单易用且更贴近应用,以套餐形式整体售卖基础云资源并提供高带宽流量包,将热门开源软件融合打包实现一键构建应用,提供极简上云体验。

https://console.cloud.tencent.com/lighthouse/instance/detail?rid=4&id=lhins-rmuhs9ke

云服务器的本质是什么?

每个云服务器实例在用户看来都是一个独立的服务器环境,具备自主操作系统、独立的存储、网络连接和计算能力,支持用户部署应用、存储数据、运行程序等。云服务器广泛用于各种计算需求,比如网站托管、应用部署、数据处理、机器学习等。

找了若干本云计算的书籍,云服务器背后是云计算吗?

我并不想要搞那么复杂的东西。我的目的是一个稳定的cloud server。可以部署一个网站,可以有一个很好用的渠道,可以跟潜在用户交流。

在看nginx的日志。

简单查了一下。

对于一个网站来说,如何监控他的流量呢?

有很多办法,网上推荐的是用google analytics,不过怎么好像这个网站的功能停更了。这个属于利用外部工具,就是在site中间插入google API,然后数据都可以被google收集。

用Nginx查看的数据就更完整准确了。

goaccess /var/log/nginx/access.log.1-o report1.html --log-format=COMBINED

在linux下面可以用这个命令直接导出来,这个太牛逼了。

20250324,在考虑改用django-request,开发环境可用、生产环境不可用,奇怪!



n5321 | 2024年11月7日 16:52

Introduction to Web Servers

web server’s primary role is to serve web pages for a website.

If you want to host your web application on the internet, in many cases you will need a web server.

When you visit http://www.digitalocean.com, you begin with entering a URL that starts a request over the internet. This request passes through multiple layers, one or more of which will be a web server. This web server generates a response to your request, which in this case is the DigitalOcean website, specifically the homepage. Ideally, this happens quickly and with 24/7 availability.

网站的本质。

in reality most modern web pages today are a combination of many resources. Web servers act as an intermediary between the backend and the frontend, serving up resources like HTML and CSS files to JSON data, all generated dynamically on the fly or served statically.

If you intend to work with websites or online apps in any capacity, it is extremely useful to familiarize yourself with the basics of what a web server is, and how it works.

A web server handles requests on the internet through HTTP and HTTPS protocol, and is also called an HTTP server.A web server is distinct from other types of servers in that it specializes in handling these HTTP and HTTPS requests, differentiating itself from application servers (e.g. Gunicorn) and servers for other protocols (i.e. WSGI). 

好多新名词。

Here are some common tasks handled by web servers:

  • Serves HTML, CSS, and JavaScript files.
  • Serves images and videos.
  • Handles HTTP error messaging.
  • Handles user requests, often concurrently.
  • Directs URL matching and rewriting.
  • Processes and serves dynamic content.
  • Compresses content for optimized data usage and speed.
  • Enables browser caching for your static content.

In practical terms, here are some personal projects that would involve a web server:

  • You want to make a website.
  • You want to make an app that connects to the internet.

Goals of a Web Server

看一个Web server的goals对比一个电机的goals,or  ansys的goals,好像没有standard。

Web servers cater to an audience with expectations of speed, availability, reliability, and more. They have a shared purpose of serving content on the internet, and in order to be considered a viable web server solution, the following aspects must be considered:

  • Uptime: This refers to the time a web server is online and operational. Websites need to be online at all times to serve users, so a high uptime is the goal. This also translates to stability and predictability. When a user enters a URL or clicks a link to your website, the expected page should load every time, and at any given time. The only exceptions should be planned downtimes for updates or maintenance. A web server that is buggy or crashes at random times adversely affects your users’ experience.
  • Speed: Your web pages should load as fast as possible. Users want their request fulfilled immediately, otherwise you risk losing them. On a slow loading web page, even if the user sits through the first load, every subsequent long load will exponentially decrease their willingness to stay or visit again.
  • Concurrency: This refers to the handling of multiple requests coming in at the same time. Having too many people trying to visit your website at once seems like a good thing, but this becomes a real problem when load times slow down to a crawl and your whole server crashes. Your physical or virtual server only has so many resources such as RAM and CPU compute power, and web servers must use these resources efficiently.
  • Scalability: Scalability refers to either making your existing servers more powerful through vertical scaling, or adding more servers to your setup through horizontal scaling. As you grow your audience, you may reach a point where you need more than one or two small web servers.
  • Ease of set up: Getting a project up and running quickly is key to the iteration of your project. A straightforward and repeatable install process is important for the first web server you set up, and the multiple web servers afterwards when you scale up.
  • Documentation: Web servers are complex. The most common setups will get you on your feet quickly, but your needs will grow over time. Oftentimes you will need features that are not as commonly used. When that time comes, good documentation is essential to creating custom solutions for your needs.
  • Developer support: If the core developers are not committed to their own project, you shouldn’t commit your project to theirs. This includes both plans for long term support for their software, along with immediate short term support they provide in the form of bug fixes and patches.
  • Community support: A core development team will handle most of the heavy lifting, but a thriving community contributes to filling in the gaps. With open source projects, this can mean contributions to the actual code base, but a strong community will also answer your questions and help with your specific issues.


Structure of Configuration Files

对web服务器的关键就是对他们的配置?!

Web servers store their settings in configuration files. You can customize your web servers by editing these files. 








n5321 | 2024年8月30日 17:49

A Linux Command Line Primer

to know how to work in a terminal environment, both locally and remotely.

Although GUIs can be an intuitive way to use a computer for many users, they often do not provide us with the greatest power over our machines, and they may prevent us from having full administrative access on our computers, including installing, modifying, or deleting software or files. Additionally, as GUIs are largely visual, they are often not as accessible as they could be for all users.

In your interactive browser terminal, there should be a dollar sign, $ and a blinking cursor. This is where you will begin to type commands to tell the terminal what to do.

In many of these Unix (or *nix-based) operating systems, the symbols at the end of the prompt may be a $ symbol or a # symbol, which mean the following:

关于登录账号的权限问题。

  • $ or dollar sign — you are logged in as a regular user
  • # or hashtag/pound symbol — you are logged in as a user with elevated privileges

For our purposes within the browser terminal below, you are logged in as a regular user, but you also have administrator privileges via the sudo command.

好像是建议用普通账号登录,用sudu获取管理员权限。

 Similarly, with a cloud server, it is possible to destroy a server and start fresh if something goes awry.

command is an instruction that is given by a user, communicating what it is that the user wants the computer to do.

command 对计算机的操作本质上是类似一个军官对士兵的指挥。

The pwd command stands for “present working directory,” and it lets you know where you are within the current filesystem. linux命令都是这种单词首字母的缩写!

This value (the name of the folder) is known as an argument, which is an input being given to the command. If you are familiar with natural language grammar, you can think of the argument as an object that is being acted upon by the verb of the command.

We’ll begin by using the touch command, which can create a new file or modify an existing file. 

We can use echo directly on the command line to have the interface repeat after us. The traditional first program, "Hello, World!", can be written with echo like so:

这个echo像是print


  1. echo Hello, World!
Output
Hello, World!

we can use a command-line text editor. Several popular choices exist, including Vim and Emacs. For our purposes, we’ll use nano, which is a less complex CLI text editor program that we can use to begin our exploration.

三个编辑器

Vim Emacs and nano

With your file now containing the text you would like, we can now save and close the file. You may notice that there is some guidance at the bottom of your terminal window:

^G Get Help   ^O WriteOut   ^R Read File  ^Y Prev Page  ^K Cut Text   ^C Cur Pos
^X Exit       ^J Justify    ^W Where Is   ^V Next Page  ^U UnCut Text ^T To Spell

第一次最烦的就是这个编辑器的存储、查看方式。

他本质上好像是不能用鼠标的。

Here, the ^ symbol refers to the Control or CTRL key on your keyboard, and the output above tells us that we need to combine that key with X (use this lower case, without pressing the SHIFT key) in order to leave the file. Let’s press those two keys together:

CTRL x


Autocompletion and History

Many versions of the command line, including the interactive terminal embedded in this tutorial, allow you to autocomplete and to reuse commands as you go. This supports you moving more quickly as it saves you typing time.













n5321 | 2024年8月30日 17:24

ubuntu的问题

暂时不想管,先弄一个凑合用的blog

Introduction to Cloud Servers
Because a cloud server is effectively a whole virtual computer, other cloud product offerings can be understood in relation to them. 

云服务器本质上是提供了一台公网地址下的远程电脑。cloud servers will always be running as virtual machines

To understand cloud servers, it's helpful to understand the type of software that runs in the cloud.Today, nearly all cloud customers use a Linux-based operating system

Server-side software: This is a class of software that’s designed to run in a cloud environment, which does not have a desktop environment or a display connected to it. Usually, this means that the software is installed and configured via a command line interface, and then accessed by regular users through a web browser or another application.

Web servers: This software enables your cloud server to communicate with users or applications on the internet using the HTTP protocol. 

API servers: APIs (Application Programming Interfaces) are a type of software mediary that enable applications to communicate with one another.

Database servers: Database servers, also called databases, are another type of API server. Unlike web servers, which can be accessed via a web browser and usually render an HTML interface, database servers are usually accessed via a database query API.


which will typically still involve virtualized server clusters, but the principle is consistent. The primary distinction is that a cloud server (sometimes called a VPS, or virtual private server, to clarify that it is a virtual machine) can be made to run any software in any way, whereas any other cloud offering is effectively an optimized and constrained subset of server features.


Should I Use a Cloud Server?

It is often sufficient to deploy a firewall like ufw that can expose network ports on an individual basis to keep a server secure, or to at least offload the responsibility for that security to the maintainers of software like Nginx, which is used on millions of servers worldwide.

Access

To connect and work with cloud servers, you will need to know how to work in a terminal environment, both locally and remotely. Remote terminal connections mostly make use of a protocol called SSH, or Secure Shell.Along with HTTP, this is one of the most commonly used protocols, although SSH is naturally used more often by administrators rather than end users. HTTP runs on port 80 (and port 443 for HTTPS). SSH typically runs on port 22. Cloud administration can be broadly understood in terms of these protocols, servers, and services.




n5321 | 2024年8月30日 17:20

About Us

普通电机工程师!
从前只想做最好的电机设计,现在修理电机设计工具。
希望可以帮你解释电磁概念,项目救火,定制ANSYS Maxwell。

了解更多