<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>我本善良 &#187; linux</title>
	<atom:link href="https://wbsl.org/category/linux/feed" rel="self" type="application/rss+xml" />
	<link>https://wbsl.org</link>
	<description>一个不太正常的正常人</description>
	<lastBuildDate>Fri, 05 Jul 2024 01:35:05 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.2</generator>
	<item>
		<title>监控Nginx运行状态脚本</title>
		<link>https://wbsl.org/linux/391.html</link>
		<comments>https://wbsl.org/linux/391.html#comments</comments>
		<pubDate>Fri, 05 Jul 2024 01:30:16 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[Nginx监控脚本]]></category>

		<guid isPermaLink="false">https://wbsl.org/?p=391</guid>
		<description><![CDATA[[crayon-69e546ce780f6305622384/]]]></description>
				<content:encoded><![CDATA[<p>
</p><pre class="crayon-plain-tag">#!/bin/bash

# 检查Nginx是否运行
if pgrep nginx &gt; /dev/null 2&gt;&amp;1; then
    echo "Nginx is running."
    exit 0
else
    echo "Nginx is not running. Starting Nginx..."
    systemctl start nginx

    # 检查Nginx是否启动成功
    if pgrep nginx &gt; /dev/null 2&gt;&amp;1; then
        echo "Nginx started successfully."
        exit 0
    else
        echo "Failed to start Nginx."
        exit 1
    fi
fi</pre><p> </p>
]]></content:encoded>
			<wfw:commentRss>https://wbsl.org/linux/391.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux下用dd命令测试硬盘的读写速度</title>
		<link>https://wbsl.org/linux/388.html</link>
		<comments>https://wbsl.org/linux/388.html#comments</comments>
		<pubDate>Wed, 26 Jun 2024 02:43:49 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[dd命令]]></category>
		<category><![CDATA[测试硬盘速度]]></category>

		<guid isPermaLink="false">https://wbsl.org/?p=388</guid>
		<description><![CDATA[一、测试写速度： time dd if=/dev/zero of=/tmp/test bs=8k count=<a href="https://wbsl.org/linux/388.html" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>一、测试写速度：</p>
<p><code>time dd if=/dev/zero of=/tmp/test bs=8k count=1000000</code></p>
<p>二、测试读速度：</p>
<p><code>time dd if=/tmp/test of=/dev/null bs=8k</code></p>
<p>三、测试读写速度：</p>
<p><code>time dd if=/tmp/test of=/var/test bs=64k</code></p>
<p>四、参数说明</p>
<p>1、time 有计时作用，dd 用于复制，从 if 读出，写到 of；</p>
<p>2、if=/dev/zero 不产生 IO，因此可以用来测试纯写速度；</p>
<p>3、同理 of=/dev/null 不产生 IO，可以用来测试纯读速度；</p>
<p>4、将/tmp/test 拷贝到/var 则同时测试了读写速度；</p>
<p>5、bs 是每次读或写的大小，即一个块的大小，count 是读写块的数量。</p>
]]></content:encoded>
			<wfw:commentRss>https://wbsl.org/linux/388.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux强制同步时间命令</title>
		<link>https://wbsl.org/linux/375.html</link>
		<comments>https://wbsl.org/linux/375.html#comments</comments>
		<pubDate>Fri, 19 Apr 2024 13:04:02 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[同步时间]]></category>

		<guid isPermaLink="false">https://wbsl.org/?p=375</guid>
		<description><![CDATA[有些系统时间不准同步时间后重启后又不准，可以使用这个加入到自动任务里即可 [crayon-69e546ce79<a href="https://wbsl.org/linux/375.html" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>有些系统时间不准同步时间后重启后又不准，可以使用这个加入到自动任务里即可</p>
<p></p><pre class="crayon-plain-tag">date -s "$(curl -H 'Cache-Control: no-cache' -sI google.com | grep '^Date:' | cut -d' ' -f3-6)Z" &amp;&gt;/dev/null 2&gt;&amp;1</pre><p> </p>
]]></content:encoded>
			<wfw:commentRss>https://wbsl.org/linux/375.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LNMP一键安装包的Nginx 502 Bad Gateway错误可能原因及解决方法</title>
		<link>https://wbsl.org/linux/362.html</link>
		<comments>https://wbsl.org/linux/362.html#comments</comments>
		<pubDate>Sat, 20 Aug 2022 01:11:12 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[lnmp]]></category>
		<category><![CDATA[Nginx 502]]></category>

		<guid isPermaLink="false">https://wbsl.org/?p=362</guid>
		<description><![CDATA[第一种原因： 安装lnmp一键安装包时php没安装成功而出现502 Bad Gateway，从0.9开始只要安<a href="https://wbsl.org/linux/362.html" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>第一种原因：<br />
安装lnmp一键安装包时php没安装成功而出现502 Bad Gateway，从0.9开始只要安装成功或失败都就会有提示。没安装成功一般原因是在安装php前，脚本中某些lib包可能没有安装上，造成php没有编译安装成功。可以看一下是否存在/usr/local/php/sbin/php-fpm ，如果没有肯定没安装成功。</p>
<p>解决方法：<br />
可以尝试根据lnmp一键安装包中的脚本手动安装一下，看看是什么错误导致的，在网上搜索一下，或者把错误信息发上来。如果实在不会提供按http://lnmp.org/install.html这个安装时的lnmp.log日志文件（可以用winscp登陆下载lnmp.log，压缩并上传到本论坛），没有错误信息我们没法说什么原因。本方法只限于lnmp没安装成功，只要lnmp安装成功了这一项就没可能。</p>
<p>第二种原因：<br />
在php.ini里，eaccelerator配置项一定要放在Zend Optimizer配置之前，否则也可能引起502 Bad Gateway。php一些模块之间也可能会造成502，如Zend GuardLoader与Opcache，ioncube与Zend GuardLoader等，一般可以通过注释掉一个然后重启php-fpm，然后看是否还502进行排除。</p>
<p>第三种原因：<br />
在安装好使用过程中出现502问题，一般是因为默认php-cgi进程是5个，可能因为phpcgi进程不够用而造成502，需要修改/usr/local/php/etc/php-fpm.conf 将其中的max_children值适当增加，如果php已升级到5.3.*以上且使用的是dynamic模式，需要调整pm.max_spare_servers参数的值。<br />
也有可能是max_requests值不够用。</p>
<p>第四种原因：<br />
php执行超时，修改/usr/local/php/etc/php.ini 将max_execution_time 改为300</p>
<p>第五种原因：<br />
磁盘空间不足，如mysql日志占用大量空间清理一下磁盘上的文件，有部分剩余空间，重启即可恢复。</p>
<p>第六种原因：<br />
查看php-cgi或php-fpm进程是否在运行</p>
<p>第七种原因：<br />
将nginx.conf里的<br />
fastcgi_connect_timeout<br />
fastcgi_send_timeout<br />
fastcgi_read_timeout都调大一点。</p>
<p>第八种原因：<br />
可能原因：http://bbs.vpser.net/thread-1654-1-1.html</p>
<p>第九种原因：<br />
有时候也可能是自己修改过下面2处的配置，导致nginx配置文件里的设置和php-fpm上的设置不一样也会502。如果使用unix套接字，修改/usr/local/php/etc/php-fpm.cnf 里设置，php 5.2为</p>
<p>/tmp/php-cgi.sock<br />
php 5.3及以上版本为listen = /tmp/php-cgi.sock ，同时/usr/local/nginx/conf/nginx.conf 及其/usr/local/nginx/conf/vhost/ 下面的虚拟主机配置里的fastcgi_pass unix:/tmp/php-cgi.sock; 不一致就必定502。<br />
有时候unix套接字模式下可能会502，可以尝试改成tcp/ip的方式 php 5.2下</p>
<p>/tmp/php-cgi.sock<br />
替换为</p>
<p>127.0.0.1:9000<br />
php 5.3及以上版本listen = /tmp/php-cgi.sock替换为listen = 127.0.0.1:9000，nginx配置文件及虚拟主机配置文件里fastcgi_pass unix:/tmp/php-cgi.sock;替换为fastcgi_pass 127.0.0.1:9000; 之后重启试试。</p>
<p>还需要补充的就是不要按网上找到的教程随便修改配置，网上找到的可能会路径不一样，也可能会导致502或有相关的错误产生。</p>
<p>第十种原因：<br />
如果虚拟主机的日志文件过大也可能会造成502问题。<br />
建议定期清空一下虚拟主机的日志文件。</p>
<p>第十一种原因：<br />
有些程序或者程序的主题有死循环或其他非常占用资源的代码也可能会引起502，可以尝试暂时注释掉可能的主机的配置文件，重启看看是否还会502。</p>
<p>第十二种原因：<br />
如果以上方法都试过，但还有时会出现502错，可以尝试添加502自动重启脚本：http://bbs.vpser.net/thread-1913-1-1.html</p>
<p>第十三种原因：<br />
实在找不到原因可以开启slowlog看看慢日志是否有相关有用的信息：http://bbs.vpser.net/viewthread.php?tid=10251&#038;page=1&#038;fromuid=3#pid30582</p>
<p>第十四种原因：<br />
升级PHP后出现502，可能php没升级成功。<br />
如果是1.0之前的版本升级PHP到5.4或5.5后，可能是因为这个原因：http://bbs.vpser.net/thread-10763-1-1.html</p>
<p>第十五种原因：<br />
CentOS 6 下，wordpress访问后台、安装wp、安装插件报502错误的解决方法：http://bbs.vpser.net/thread-10767-1-1.html</p>
]]></content:encoded>
			<wfw:commentRss>https://wbsl.org/linux/362.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux上iptables防火墙的基本应用</title>
		<link>https://wbsl.org/linux/357.html</link>
		<comments>https://wbsl.org/linux/357.html#comments</comments>
		<pubDate>Wed, 06 Jul 2022 13:23:10 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[iptables]]></category>

		<guid isPermaLink="false">https://wbsl.org/?p=357</guid>
		<description><![CDATA[1、安装iptables防火墙 如果没有安装iptables需要先安装，CentOS执行： yum insta<a href="https://wbsl.org/linux/357.html" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>1、安装iptables防火墙<br />
如果没有安装iptables需要先安装，CentOS执行：</p>
<p>yum install iptables -y<br />
yum install iptables-services -y #CentOS7需安装此iptables的service软件包#<br />
CentOS 7上默认安装了firewalld建议关闭并禁用：</p>
<p>systemctl stop firewalld<br />
systemctl mask firewalld<br />
Debian/Ubuntu执行：</p>
<p>apt-get install iptables -y<br />
apt-get install iptables-persistent -y #持久化iptables规则服务#<br />
2、清除已有iptables规则<br />
iptables -F<br />
iptables -X<br />
iptables -Z<br />
3、开放指定的端口<br />
-A和-I参数分别为添加到规则末尾和规则最前面。</p>
<p>#允许本地回环接口(即运行本机访问本机)<br />
iptables -A INPUT -i lo -j ACCEPT<br />
# 允许已建立的或相关连的通行<br />
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT<br />
#允许所有本机向外的访问<br />
iptables -A OUTPUT -j ACCEPT<br />
# 允许访问22端口<br />
iptables -A INPUT -p tcp --dport 22 -j ACCEPT<br />
#允许访问80端口<br />
iptables -A INPUT -p tcp --dport 80 -j ACCEPT<br />
#允许访问443端口<br />
iptables -A INPUT -p tcp --dport 443 -j ACCEPT<br />
#允许FTP服务的21和20端口<br />
iptables -A INPUT -p tcp --dport 21 -j ACCEPT<br />
iptables -A INPUT -p tcp --dport 20 -j ACCEPT<br />
#如果有其他端口的话，规则也类似，稍微修改上述语句就行<br />
#允许ping<br />
iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT<br />
#禁止其他未允许的规则访问<br />
iptables -A INPUT -j REJECT  #（注意：如果22端口未加入允许规则，SSH链接会直接断开。）<br />
iptables -A FORWARD -j REJECT<br />
4、屏蔽IP<br />
#如果只是想屏蔽IP的话“3、开放指定的端口”部分设置可以直接跳过。<br />
#屏蔽单个IP的命令是<br />
iptables -I INPUT -s 123.45.6.7 -j DROP<br />
#封整个段即从123.0.0.1到123.255.255.254的命令<br />
iptables -I INPUT -s 123.0.0.0/8 -j DROP<br />
#封IP段即从123.45.0.1到123.45.255.254的命令<br />
iptables -I INPUT -s 124.45.0.0/16 -j DROP<br />
#封IP段即从123.45.6.1到123.45.6.254的命令是<br />
iptables -I INPUT -s 123.45.6.0/24 -j DROP<br />
5、屏蔽或允许某IP访问指定端口<br />
#屏蔽某IP访问指定端口，以22端口为例命令是<br />
iptables -I INPUT -s 123.45.6.7 -p tcp --dport 22 -j DROP<br />
#允许某IP访问指定端口，以22端口为例命令是<br />
iptables -I INPUT -p tcp --dport 22 -j DROP<br />
iptables -I INPUT -s 123.45.6.7 -p tcp --dport 22 -j ACCEPT<br />
6、查看已添加的iptables规则<br />
iptables -L -n<br />
v：显示详细信息，包括每条规则的匹配包数量和匹配字节数<br />
x：在 v 的基础上，禁止自动单位换算（K、M） vps侦探<br />
n：只显示IP地址和端口号，不将ip解析为域名</p>
<p>7、删除已添加的iptables规则<br />
将所有iptables以序号标记显示，执行：</p>
<p>iptables -L -n --line-numbers<br />
比如要删除INPUT里序号为8的规则(要删除OUTPUT的话就改成OUTPUT，以此类推)，执行：</p>
<p>iptables -D INPUT 8<br />
8、iptables的开机启动及规则保存<br />
有可能系统并未安装iptables的service文件，可以先执行：</p>
<p>yum -y install iptables-services<br />
进行安装。<br />
CentOS上可能会存在安装好iptables后，iptables并不开机自启动，可以执行一下：</p>
<p>chkconfig --level 345 iptables on<br />
CentOS7可执行：<br />
有可能系统并未安装iptables的service文件，可以执行：</p>
<p>yum -y install iptables-services<br />
systemctl enable iptables<br />
将其加入开机启动。</p>
<p>CentOS上可以执行：service iptables save保存规则。</p>
<p>另外更需要注意的是Debian/Ubuntu上iptables是不会保存规则的，也是前面说的持久化iptables规则。<br />
需要先执行一下，安装持久化脚本：</p>
<p>apt-get --no-install-recommends install -y iptables-persistent<br />
Debian或Ubuntu 16.04或更高版本执行：/etc/init.d/netfilter-persistent save 可以进行保存规则，/etc/init.d/netfilter-persistent reload 可以将规则生效。<br />
Ubuntu 14.04之前版本执行：/etc/init.d/iptables-persistent save 可以进行保存规则，/etc/init.d/iptables-persistent reload 可以将规则生效。</p>
<p>开机启动的话执行：systemctl enable netfilter-persistent.service 或 systemctl enable iptables-persistent.service</p>
<p>这样就完成了Debian或Ubuntu下的关机自动保存规则，开机自动加载规则的设置。</p>
]]></content:encoded>
			<wfw:commentRss>https://wbsl.org/linux/357.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nginx 通过命令行查看并发连接数</title>
		<link>https://wbsl.org/linux/355.html</link>
		<comments>https://wbsl.org/linux/355.html#comments</comments>
		<pubDate>Mon, 04 Jul 2022 12:41:06 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">https://wbsl.org/?p=355</guid>
		<description><![CDATA[netstat -apn&#124;grep 'nginx: worker'&#124;wc -l]]></description>
				<content:encoded><![CDATA[<p><code>netstat -apn|grep 'nginx: worker'|wc -l</code></p>
]]></content:encoded>
			<wfw:commentRss>https://wbsl.org/linux/355.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux sed 指定行添加内容</title>
		<link>https://wbsl.org/linux/342.html</link>
		<comments>https://wbsl.org/linux/342.html#comments</comments>
		<pubDate>Fri, 15 Oct 2021 00:53:02 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[linux sed]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">https://wbsl.org/?p=342</guid>
		<description><![CDATA[将this is a test line添加至第7行 sed -i '7a\this is a test li<a href="https://wbsl.org/linux/342.html" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>将this is a test line添加至第7行</p>
<p><code>sed -i '7a\this is a test line' test.conf</code></p>
]]></content:encoded>
			<wfw:commentRss>https://wbsl.org/linux/342.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>查找并替换快速修改SSH端口命令</title>
		<link>https://wbsl.org/linux/339.html</link>
		<comments>https://wbsl.org/linux/339.html#comments</comments>
		<pubDate>Fri, 15 Oct 2021 00:02:15 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[修改SSH端口]]></category>
		<category><![CDATA[快速修改22端口]]></category>

		<guid isPermaLink="false">https://wbsl.org/?p=339</guid>
		<description><![CDATA[执行以下命令： sed -i 's/Port 22/Port 10086/g' /etc/ssh/sshd_c<a href="https://wbsl.org/linux/339.html" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>执行以下命令：</p>
<p><code>sed -i 's/Port 22/Port 10086/g' /etc/ssh/sshd_config</code></p>
<p>重启ssh服务即可</p>
<p><code>systemctl restart sshd</code></p>
]]></content:encoded>
			<wfw:commentRss>https://wbsl.org/linux/339.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
