- Java锁的逻辑(结合对象头和ObjectMonitor)
- 还在用饼状图?来瞧瞧这些炫酷的百分比可视化新图形(附代码实现)⛵
- 自动注册实体类到EntityFrameworkCore上下文,并适配ABP及ABPVNext
- 基于Sklearn机器学习代码实战
源码包的获取:官网下载 。
实验环境:和企业环境类似,关闭防火墙,禁用selinux,使用静态IP地址 。
[root@node01 ~]# yum install pcre-devel -y
[root@node01 ~]# yum -y install gc gcc gcc-c++ zlib-devel openssl-devel
[root@node01 ~]# groupadd nginx
[root@node01 ~]# useradd -s /sbin/nologin -g nginx -M nginx
[root@node01 ~]# wget http://tengine.taobao.org/download/tengine-2.2.0.tar.gz
[root@node01 ~]# tar xf tengine-2.2.0.tar.gz -C /usr/local/src/
[root@node01 ~]# cd /usr/local/src/tengine-2.2.0/
[root@node01 tengine-2.2.0]#
[root@node01 tengine-2.2.0]# ls
AUTHORS.te CHANGES.cn conf docs man README tests
auto CHANGES.ru configure html modules README.markdown THANKS.te
CHANGES CHANGES.te contrib LICENSE packages src
./configure --user=nginx --group=nginx \
--prefix=/usr/local/src/nginx \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module
[root@node01 tengine-2.2.0]# make && make install
[root@node01 tengine-2.2.0]# chown -R nginx.nginx /src/tengine-2.2.0/
[root@node01 ~]# cat /usr/lib/systemd/system/nginx.service
t]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/src/nginx/logs/nginx.pid
ExecStartPre=/usr/local/src/nginx/sbin/nginx -t -c /usr/local/src/nginx/conf/nginx.conf
ExecStart=/usr/local/src/nginx/sbin/nginx -c /usr/local/src/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
修改了PID文件 。
# 重新创建了一个PID文件
touch /usr/local/src/nginx/logs/nginx.pid
测试:
[root@node01 ~]# systemctl daemon-reload
[root@node01 ~]# systemctl restart nginx.service
[root@node01 ~]#
[root@node01 ~]#
[root@node01 ~]# ss -lntup | grep 80
tcp LISTEN 0 128 *:80 *:* users:(("nginx",pid=13454,fd=6),("nginx",pid=13452,fd=6))
tcp LISTEN 0 80 [::]:3306 [::]:* users:(("mysqld",pid=1202,fd=28))
[root@node01 ~]#
[root@node01 ~]#
[root@node01 ~]# systemctl stop nginx.service
[root@node01 ~]#
[root@node01 ~]#
[root@node01 ~]# ss -lntup | grep 80
tcp LISTEN 0 80 [::]:3306 [::]:* users:(("mysqld",pid=1202,fd=28))
[root@node01 ~]# cd /usr/local/src/nginx/html/
[root@node01 html]# ll
total 8
-rw-r--r-- 1 root root 539 Apr 16 18:07 50x.html
-rw-r--r-- 1 root root 555 Apr 16 18:07 index.html
[root@node01 html]# cp index.html{,.bak}
[root@node01 html]# vim index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
@keyframes myAnimation {
from {
width: 100px;
height: 75px;
background-color: yellow;
border: 1px solid red;
}
to {
width: 200px;
height: 150px;
background-color: green;
border: 1px solid red;
}
}
div {
animation-name: myAnimation;
transition-duration: 1s;
transition-timing-function: ease;
animation-iteration-count: infinite;
animation-play-state: running;
animation-direction: reverse;
animation: myAnimation 10s infinite linear;
}
div:hover {
display: none;
}
</style>
</head>
<body>
<div>
</div>
</body>
</html>
[root@node01 conf]# pwd
/usr/local/src/nginx/conf
[root@node01 conf]# vim nginx.conf
server {
listen 80;
server_name bbs.openlab.edu;
location / {
root html/bbs;
index index.html index.htm;
}
}
server {
listen 80;
server_name blog.openlab.edu;
location / {
root html/blog;
index index.html index.htm;
}
}
[root@node01 conf]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.11.110 bbs.openlab.edu blog.openlab.ed
[root@node01 html]# for name in blog bbs;do mkdir $name;done
[root@node01 html]# for name in blog bbs ;do echo " $name test" > $name/index.html ;done
[root@node01 conf]# curl http://bbs.openlab.edu
bbs test
[root@node01 conf]# curl http://blog.openlab.edu
blog test
基于地址访问控制 。
server {
listen 192.168.11.110:80;
server_name bbs.openlab.edu;
location / {
autoindex on;
root html/bbs;
index index.html index.htm;
deny 192.168.11.111;
allow 192.168.11.0/24;
deny all;
}
location /nginx_status {
stub_status on;
access_log off;
}
}
[root@template ~]# ifconfig
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.11.10 netmask 255.255.255.0 broadcast 192.168.11.255
inet6 fe80::23ff:1697:647:7139 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:bc:8b:08 txqueuelen 1000 (Ethernet)
RX packets 589 bytes 49970 (48.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 968 bytes 115511 (112.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@template ~]# curl http://bbs.openlab.edu
bbs test
[root@node02 ~]# ifconfig
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.11.111 netmask 255.255.255.0 broadcast 192.168.11.255
inet6 fe80::de65:5eb0:ef21:bfad prefixlen 64 scopeid 0x20<link>
inet6 fe80::e8bb:875c:36dc:9aac prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:b0:1e:37 txqueuelen 1000 (Ethernet)
RX packets 705 bytes 60926 (59.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1180 bytes 141313 (138.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@node02 ~]# curl -I http://blog.openlab.edu
HTTP/1.1 403 Forbidden
Server: Tengine/2.2.0
Date: Sun, 16 Apr 2023 11:45:53 GMT
Content-Type: text/html
Content-Length: 589
Connection: keep-alive
基于用户控制 对于实现访问网站或目录密码认证保护,nginx的HTTP基本认证模块(HTTP Auth Basic)可以实现。这个模块提供基于用户名与密码的验证来保护你的站点或站点的一部分 。
# 在location中添加这俩行
auth_basic "Restricted";
auth_basic_user_file /usr/local/nginx/webpass;
server {
listen 80;
server_name bbs.openlab.edu;
location / {
root html/bbs;
index index.html index.htm;
auth_basic "Restricted";
auth_basic_user_file /usr/local/src/nginx/webpass;
}
}
[root@node01 conf]# yum install httpd-tools -y
[root@node01 conf]# htpasswd -cm /usr/local/src/nginx/webpass tom
New password:
Re-type new password:
Adding password for user tom
[root@node01 conf]# more /usr/local/src/nginx/webpass
tom:$apr1$mlWgXfOz$6j4C758K/wsTDDdQtFH990
[root@node01 conf]# yum install elinks.x86_64 -y
[root@node1 ~]# elinks http://bbs.openlab.edu/nginx_status
最后此篇关于CentOS7---Nginx安装并配置虚拟主机的文章就讲到这里了,如果你想了解更多关于CentOS7---Nginx安装并配置虚拟主机的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我在这里想做的是将所有连接转发到机器一上端口 3306 上的本地主机到本地主机上端口 3306 上的机器二。因此,如果您连接到机器一上的 mysql,它的行为就像您正在连接一样在二号机器上。 我认为
通过Kibana界面,如何获得 flex IP /主机? 我的意思是,与kibana连接的Elastic主机。 那有可能吗?我在这个上挣扎了好几个小时,却一无所获:( 附:不确定此问题是否是题外话,应
我知道这听起来很奇怪,但我有一个情况,Deno 需要关闭自己的主机(并因此杀死自己的进程)。这可能吗? 我特别需要这个用于 linux (lubuntu),如果相关的话。我想这需要 sudo 权限,这
我知道这听起来很奇怪,但我有一个情况,Deno 需要关闭自己的主机(并因此杀死自己的进程)。这可能吗? 我特别需要这个用于 linux (lubuntu),如果相关的话。我想这需要 sudo 权限,这
我有一个基本问题,但谷歌并没有为我产生很多结果(反正不是英文的)。基本上我想做的就是: 我有一个图形需要用作整个应用程序的持久 header ,例如:我不能让它在新的 Intent 调用时从屏幕上滑出
您好,我正在使用 xampp,我正在尝试使用 php 进行连接。 $sql_connections = mysql_connect("$server, $username, $password")
我目前正在尝试一些多人游戏的想法,并正在尝试创建一个 Java 应用程序来为基于网络浏览器的多人游戏提供服务。 我的开发环境是主机上的Eclipse, native 上的notepad + Googl
今天为大家分享一篇关于SSH 的介绍和使用方法的文章。本文从SSH是什么出发,讲述了SSH的基本用法,之后在远程登录、端口转发等多种场景下进行独立的讲述,希望能对大家有所帮助。 什么是SSH?
我已经完成了在裸机 Centos 7 上运行的测试 Kubernets 主机的设置。这将用作测试系统,因为我们将在 IBM Bluemix Kubernetes 服务中部署所有内容。 从 Bluemi
我正在尝试通过带有 4.2(果冻 bean )的 android 设备“nexus 7”通过 USB 与我的 freeduino 板进行通信,该板类似于 arduino uno。 几个月后,我使用开发
我正在使用 nginx,但在设置反向代理时遇到问题。 我的 nginx.conf 是默认的(没有对其进行任何更改),我的站点可用配置是: upstream backend_hosts { se
我在 projectlocker(免费 svn 主机)上有一个帐户,但我不知道如何将我的项目文件上传到它。 我在我的仪表板中找不到任何选项。 我在我的电脑上使用tortoiseSvn,那么如何上传文件
设置batchSize = 1有意义吗?如果我想一次处理一个文件? 尝试过batchSize = 1000和batchSize = 1 - 似乎具有相同的效果 { "version": "2.0"
我只想知道.. docker中现在有任何可用的工具吗?我已经阅读了Docker中有关多主机功能的一些文档,例如, Docker群 Docker服务(带有副本) 我也知道群模式下的volume问题,容器
我想将文件从 Docker 的容器挂载到我的 docker 主机。 数据卷不是我的解决方案,因为它们是从 docker 主机到 docker 容器的装载,我需要相反的方法。 谢谢 最佳答案 当 doc
我是新手。我无法正确理解RMI。互联网上有大量教程,但据我所知,它们都是针对本地主机的。服务器和客户端都运行在同一台机器上。 我想在任何计算机上运行客户端,并且主机将位于一台计算机上,让我们考虑IP
我无法从客户端“A”SSH 到服务器“B”(但我可以从同一子网上的许多其他 ssh 客户端而不是“A”——所有都是 *nux 机器) serverA>ssh -v -p 端口用户@serverB Op
设置batchSize = 1有意义吗?如果我想一次处理一个文件? 尝试过batchSize = 1000和batchSize = 1 - 似乎具有相同的效果 { "version": "2.0"
由于我不是天生的编码员,请多多包涵。 这是我尝试使用HAproxy来实现的目标,但是经过数小时的检查后,我无法以某种方式使其工作。 从 domain.com/alpha domain.com/beta
我正在使用 tomcat 运行 Java Web 应用程序,通过电子邮件将生成的报告发送给用户。我可以发送电子邮件,但几个小时后服务器停止发送电子邮件,并出现以下错误。 javax.mail.Mess
我是一名优秀的程序员,十分优秀!