[英]Magento 2 Varnish on Nginx server
Have installed Varnish cache successfuly but now when I try to use: systemctl status varnish - it's giving me an error Could not get socket :80: Address already in use.已成功安装 Varnish 缓存,但现在当我尝试使用时:systemctl status varnish - 它给我一个错误无法获取套接字:80:地址已在使用中。
I have checked the sockets by using netstat -plntu and it seems like that this is the problem:我已经使用 netstat -plntu 检查了套接字,这似乎是问题所在:
206.189.99.109:80 0.0.0.0:* LISTEN 31889/nginx: master 206.189.99.109:80 0.0.0.0:* LISTEN 31889/nginx: master
10.18.0.8:8080 0.0.0.0:* LISTEN 31889/nginx: master 10.18.0.8:8080 0.0.0.0:* 听 31889/nginx: master
206.189.99.109:8080 0.0.0.0:* LISTEN 31889/nginx: master 206.189.99.109:8080 0.0.0.0:* LISTEN 31889/nginx: master
one of the Nginx: master is running under port 80 I have tried to change the port in nginx config files but nothing. Nginx 之一:master 正在端口 80 下运行我曾尝试更改 nginx 配置文件中的端口,但什么也没有。
How or where can I change this port to 80?如何或在哪里可以将此端口更改为 80?
In nginx
, you have to change to port in the config file that holds your vhost config.在
nginx
,您必须在保存 vhost 配置的配置文件中更改为 port。
Usualy listen 80
is somewhere in that file.通常,
listen 80
位于该文件中的某个位置。 Replace it with listen 8080
.将其替换为
listen 8080
。
For varnish
, the listen port is part of the systemd
config file.对于
varnish
,监听端口是systemd
配置文件的一部分。 By default it is hosted in /lib/systemd/system/varnish.service
, but it should be copied to /etc/systemd/system/varnish.service
.默认情况下,它托管在
/lib/systemd/system/varnish.service
,但应将其复制到/etc/systemd/system/varnish.service
。
In the varnish.service
file you'll find something like -a :6081
, which should be replaced by -a :80
.在
varnish.service
文件中,您会发现类似-a :6081
,应将其替换为-a :80
。
After you've made the changes to the varnish.service
file, you need to reload the systemd
daemon by running sudo systemctl daemon-reload
.对
varnish.service
文件进行更改后,您需要通过运行sudo systemctl daemon-reload
systemd
守护sudo systemctl daemon-reload
。
And finally, it's a matter of restarting nginx
& varnish
using the restart commands that systemd
offers.最后,这是使用
systemd
提供的重启命令重启nginx
和varnish
的问题。
Here's the all-in-one command that does all this for you:这是为您完成所有这些的多合一命令:
sudo sed -i 's/80/8080/' /etc/nginx/sites-enabled/default
sudo cp -f /lib/systemd/system/varnish.service /etc/systemd/system/varnish.service
sudo sed -i 's/-a :6081/-a :80/' /etc/systemd/system/varnish.service
sudo systemctl daemon-reload
sudo systemctl restart nginx
sudo systemctl restart varnish
These are my assumptions about these commands:这些是我对这些命令的假设:
nginx
vhost conf file is /etc/nginx/sites-enabled/default
nginx
vhost conf 文件是/etc/nginx/sites-enabled/default
varnish
is in its out-of-the-box config, and still listens on port 6081
varnish
在其开箱即用的配置中,并且仍侦听端口6081
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.