当前位置:首页 » 操作系统 » linux502

linux502

发布时间: 2022-10-01 12:08:17

⑴ 一键linux怎么配置502界面

常见的Nginx 502 Bad Gateway解决办法如下:

Nginx 502错误情况1:

网站的访问量大,而php-cgi的进程数偏少。
针对这种情况的502错误,只需增加php-cgi的进程数。具体就是修改/usr/local/php/etc/php-fpm.conf 文件,将其中的max_children值适当增加。这个数据要依据你的VPS或独立服务器的配置进行设置。一般一个php-cgi进程占20M内存,你可以自己计算下,适量增多。
/usr/local/php/sbin/php-fpm restart 然后重启一下.

Nginx 502错误情况2:

CPU占用率、内存占用率非常高,遭到CC攻击.
解决方法请参考:LinuxVPS简单解决CC攻击

Nginx 502错误情况3:

CPU占用率不高,内存溢出。
检查一下网站程序有没有问题?一般小偷站点常常会出现内存溢出。
检查一下/var/log/目录下的日志,看看是不是有人爆破SSH和FTP端口?
SSH、FTP遭到穷举也会占用大量内存。是的话改掉SSH端口和FTP端口即可

将网上找到的一些和502 Bad Gateway错误有关的问题和排查方法列一下,先从FastCGI配置入手:

1.查看FastCGI进程是否已经启动

NGINX 502错误的含义是sock、端口没被监听造成的。我们先检查fastcgi是否在运行

2.检查系统Fastcgi进程运行情况

除了第一种情况,fastcgi进程数不够用、php执行时间长、或者是php-cgi进程死掉也可能造成nginx的502错误
运行以下命令判断是否接近FastCGI进程,如果fastcgi进程数接近配置文件中设置的数值,表明worker进程数设置太少
netstat -anpo | grep "php-cgi" | wc -l

3.FastCGI执行时间过长

根据实际情况调高以下参数值
fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300;

4.头部太大

nginx和apache一样,有前端缓冲限制,可以调整缓冲参数
fastcgi_buffer_size 32k; fastcgi_buffers 8 32k;
如果你使用的是nginx的负载均衡Proxying,调整
proxy_buffer_size 16k; proxy_buffers 4 16k;

5.https转发配置错误

正确的配置方法

server_name www.111cn.NET; location /myproj/repos { set $fixed_destination $http_destination; if ( $http_destination ~* ^https(.*)$ ) { set $fixed_destination http$1; } proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Destination $fixed_destination; proxy_pass http://subversion_hosts; }

⑵ linux环境网站提示502 Bad Gateway怎么解决

提升服务器的文件句柄打开打开vi /etc/security/limits.conf 底部加上* soft nofile 51200* hard nofile 51200
vi /etc/sysctl.conf 底部添加fs.file-max=51200

提升nginx的进程文件打开数vi /www/wdlinux/nginx/conf/nginx.confworker_rlimit_nofile 5120; 改成worker_rlimit_nofile 51200;

修改php-fpm.conf文件,主要需要修改2处。vi /www/wdlinux/etc/php-fpm.conf改成下面的值<value name="max_requests">10240</value><value name="rlimit_files">51200</value>

设置php-fpm自动启动vi /etc/rc.local 最后增加/etc/init.d/php-fpm start

完成之后reboot重启下服务器ulimit -n 查看

⑶ linux nginx 网站访问提示502 Bad Gateway怎么操作

试下重新配置网络,也可以看下浏览器的安全设置,还可以直接使用yum/apt安装nginx,以下是官网的安装步骤:
RHEL/CentOS
Install the prerequisites:
sudo yum install yum-utils

To set up the yum repository, create the file named /etc/yum.repos.d/nginx.repo with the following contents:
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
mole_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
mole_hotfixes=true

By default, the repository for stable nginx packages is used. If you would like to use mainline nginx packages, run the following command:
sudo yum-config-manager --enable nginx-mainline

To install nginx, run the following command:
sudo yum install nginx

When prompted to accept the GPG key, verify that the fingerprint matches 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62, and if so, accept it.

Debian

Install the prerequisites:
sudo apt install curl gnupg2 ca-certificates lsb-release

To set up the apt repository for stable nginx packages, run the following command:
echo "deb http://nginx.org/packages/debian `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list

If you would like to use mainline nginx packages, run the following command instead:
echo "deb http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list

Next, import an official nginx signing key so apt could verify the packages authenticity:
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -

Verify that you now have the proper key:
sudo apt-key fingerprint ABF5BD827BD9BF62

The output should contain the full fingerprint 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62 as follows:
pub rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62
uid [ unknown] nginx signing key <[email protected]>

To install nginx, run the following commands:
sudo apt update
sudo apt install nginx

Ubuntu
Install the prerequisites:
sudo apt install curl gnupg2 ca-certificates lsb-release

To set up the apt repository for stable nginx packages, run the following command:
echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list

If you would like to use mainline nginx packages, run the following command instead:
echo "deb http://nginx.org/packages/mainline/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list

Next, import an official nginx signing key so apt could verify the packages authenticity:
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -

Verify that you now have the proper key:
sudo apt-key fingerprint ABF5BD827BD9BF62

The output should contain the full fingerprint 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62 as follows:
pub rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62
uid [ unknown] nginx signing key <[email protected]>

To install nginx, run the following commands:
sudo apt update
sudo apt install nginx

⑷ linux nginx/0.8.46 出现 502 Bad Gateway 问题

1.什么是502 bad gateway 报错 简单来说 502 是报错类型代码 bad gateway 错误的网关 2.产生错误的原因 连接超时 我们向服务器发送请求 由于服务器当前链接太多,导致服务器方面无法给于正常的响应,产生此类报错 3.解救的办法 最好的解决办法当然还是在服务器上做 对大家来说不太可能 那么我们有什么解救的方法呢? 说白了 很简单 就是——刷新(不是一般的刷新哦) 刷新的原理:很多人可能不知道 刷新也是有两种的。 所谓刷新其实就是从服务器下载数据到本地的硬盘浏览器, 再从本地硬盘中读取数据到浏览器显示给我们看。 ①基本刷新:就是点击刷新或者使用F5快捷键 基本刷新只是从本地的硬盘重新拿取数据到浏览器,并不重新向服务器发出请求。 大部分用户很多时候都是这样刷新的,遇到502报错的就没有任何效果。 ②从服务器刷新: 如果你重新直接点击你想要浏览的网页链接,你会发现刚才还是显示502 bad getway的页面现在又可以正常浏览了! 明白道理了吧?当你点击你想要浏览的网页链接的时候,是会从服务器重新下载数据的。 解决方法就是从服务器上刷新:快捷键 ctrl+F5,这样就是重新向服务器发送请求了。 如果服务器能正常给予你响应你就可以看到页面了。

⑸ Linux里面页面502怎么解决

1:php-cgi进程数不够用 (我就是采用此方法解决的)
vim php-fpm.conf
修改其中的2个参数
(1)在安装好使用过程中出现502问题,一般是因为默认php-cgi进程是5个,可能因为phpcgi进程不够用而造成502,需要修改/usr/local/php/etc/php-fpm.conf 将其中的max_children值适当增加
这个数值是不确定的 需要我们自己算的,这个值原则上是越大越好,php-cgi的进程多了就会处理的很快,排队的请求就会很少,减小出现502错误的机率。
一般来说,一台服务器的正常情况下每一个php-cgi要耗费的内存为20M左右。如果我就将此值设为80,那么也就是说大概要耗费服务器1600M内存。
查看一下当前系统中有多少个php-cgi进程在运行
netstat -anpo | grep php-cgi | wc -l
如果这个值接近你的在配置文件里面设置的值,说明需要增加
注:这要根据机器的实际情况而定,每个机器的硬件设施和环境不一样
参数为:<value name=”max_children”>80</value>
(2)另外一个参数就是php-cgi脚本的执行时间
<value name=”request_terminate_timeout”>0s</value>这里写0s的意思是让php-cgi一直执行下去,没有时间限制。
注意:如果你做不到这一点,也就 是说你的PHP-CGI可能出现某个BUG,或者你的宽带不够充足或者其他的原因导致你的PHP-CGI假死那么就建议你给 request_terminate_timeout赋一个值,这个值可以根据服务器的性能进行设定。一般来说性能越好你可以设置越高,20分钟-30分 钟都可以。
修改完这两个参数,重启一下php-cgi,看是否还出现502错误
2: php执行时间长
php执行超时,修改/usr/local/php/etc/php.ini 将max_execution_time 改为300
重启一下php-cgi,看是否还出现502错误
3: php-cgi进程死掉
杀死其进程,重启php-cgi

⑹ linux 502 bad gateway nginx怎么解决

会有好多种情况出现502错误,下面我们分情况来说一下。 一、fastcgi缓冲区设置过小出现错误,首先要查找nginx的日志文件,目录为/var/log/nginx,在日志中发现了如下错误。 2013/01/17 13:33:47 [error] 15421#0: *16 upstream sent too big header while reading response header from upstream 查阅了一下资料,大意是nginx缓冲区有一个bug造成的,我们网站的页面消耗占用缓冲区可能过大。 网上查找了一下解决方法,在国外网站看到了一个增加缓冲区的方法,彻底解决了Nginx 502 Bad Gateway的问题。方法如下: http { ... fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; ... } 请根据服务器已经网站的情况自行增大上述两个配置项。 二、代理缓冲区设置过小如果你使用的是nginx反向代理,如果header过大,超出了默认的1k,就会引发上述的upstream sent too big header (说白了就是nginx把外部请求给后端处理,后端返回的header太大,nginx处理不过来就会导致502。 server { listen 80; server_name *.lxy.me; location / { #########添加这3行 <span class='wp_keywor...

⑺ linux环境网站提示502 Bad Gateway怎么解决

您可以尝试清除浏览器缓存访问一下你的FTP看是否可以登陆产生原因服务器(不一定是Web服务器)是作为网关或代理,以满足客户的要求(如Web浏览器或我们的CheckUpDown机器人)来访问所请求的URL。此服务器收到无效响应从上游服务器访问履行它的要求。固定502错误一般这个问题是由于不良的IP之间的沟通后端计算机,包括您可能尝试访问的在Web服务器上的网站。在分析这个问题,您应该清除浏览器缓存完全。如果您上网时在您尝试访问的所有网站上都看这个问题,有两种可能1)你的ISP了重大设备故障/过载或2)有问题的内部互联网连接如您的防火墙无法正常运作。在第一种情况下,只有您的ISP可以帮助您。在第二种情况下,你需要解决什么,那就是阻止你进入互联网。如果您只有在部分尝试访问的网站中出现此问题,那就很可能是一个问题,即这些网站之一,其设备故障或超载。联系网站的管理员。

⑻ linux nginx 网站访问提示502 Bad Gateway怎么操作

1、FastCGI进程是否已经启动
ps aux | grep php
查看是否启动了php-fpm服务;
2、FastCGI worker进程数是否不够
运行linux命令:
netstat -anpo | grep “php-cgi” | wc -l
判断是否接近FastCGI进程,接近配置文件中设置的数值,表明worker进程数设置太少;
3、FastCGI执行时间过长
根据实际情况调高以下参数值
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
4、FastCGI Buffer不够
nginx和apache一样,有前端缓冲限制,可以调整缓冲参数
fastcgi_buffer_size 32k;
fastcgi_buffers 8 32k;
5、其它原因
出现502的情况太多了,(例如:你服务器目前的配置支撑不了你现有的业务。我有一个朋友服务器是4核8G的,经常一会出现502 Bad Gatewa,又一会正常。CPU和内存经常爆满接近100%,负载也接近4。最后,配置升级成8核16G后变就变正常了。)远远不只是博主所说的这几种!这几种只能说是最常用的吧!具体的原因一定要去查看服务器的日志;

⑼ linux环境网站提示502 Bad Gateway怎么解决

看下Apache是否开启了伪静态
.htacces是否有

热点内容
密码子的原料是什么 发布:2024-09-19 09:11:42 浏览:347
半夜编程 发布:2024-09-19 09:11:36 浏览:103
海康威视存储卡质量如何 发布:2024-09-19 08:55:35 浏览:940
python3默认安装路径 发布:2024-09-19 08:50:22 浏览:516
环卫视频拍摄脚本 发布:2024-09-19 08:35:44 浏览:418
sqlserveronlinux 发布:2024-09-19 08:16:54 浏览:256
编程常数 发布:2024-09-19 08:06:36 浏览:952
甘肃高性能边缘计算服务器云空间 发布:2024-09-19 08:06:26 浏览:162
win7家庭版ftp 发布:2024-09-19 07:59:06 浏览:717
数据库的优化都有哪些方法 发布:2024-09-19 07:44:43 浏览:269