海运的博客

Apache/PHP/Mysql/Nginx编译参数查看

发布时间:June 20, 2012 // 分类:Apache,Nginx,PHP,数据库 // No Comments

查看Nginx编译参数:

/usr/local/nginx/sbin/nginx -V

查看Apache编译参数:

cat /usr/local/apache/build/config.nice

查看PHP编译参数:

/usr/local/php/bin/php -i |grep configure

查看Mysql编译参数:

cat /usr/local/mysql/bin/mysqlbug|grep configure

Linux/Centos安装nagios监控服务器

发布时间:June 3, 2012 // 分类:Nagios // No Comments

CentOS安装LAMP及编译环境:

yum -y install httpd httpd-devel mysql mysql-server mysql-devel php php-devel php-common php-gd \
php-mysql php-mbstring php-mcrypt php-xml php-snmp gcc make automake autoconf
/etc/init.d/httpd start
/etc/init.d/mysqld start
/usr/bin/mysqladmin -u root password "password"
chkconfig httpd on
chkconfig mysqld on

安装Nagios

#https://www.haiyun.me
useradd nagios
groupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd apache
cd /usr/local/src/
#安装主程序
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.1.tar.gz
tar zxvf nagios-3.4.1.tar.gz 
cd nagios
./configure --with-command-group=nagcmd --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios 
make all
make install
#安装主程序
make install-init
#安装init管理脚本
make install-config
#安装示例配置文件
make install-commandmode
#配置目录权限
make install-webconf
#安装Apache配置文件
#make install-exfoliation
#安装简洁白色主题,此为默认
make install-classicui
安装经典黑色主题
cd ../
#安装插件
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
tar zxvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins
./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/usr/local/nagios
make
make install
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
#生成nagiosadmin验证密码,用于web界面验证。
/etc/init.d/httpd restart
/etc/init.d/nagios start
chkconfig nagios on
setsebool -P httpd_disable_trans 1
#关闭selinux对httpd的防护,不然会出现权限问题

安装完成,访问www.haiyun.me/nagios即可。
nagios管理界面.png

Apache动态编译添加模块

发布时间:May 22, 2012 // 分类:Apache // No Comments

Apache基于模块化设计,编译完成后还可动态编译添加其它模块,此功能Apache编译时需添加--enable-so参数,1.x版本--enable-module=so。
查看已加载的模块:

#https://www.haiyun.me
/usr/local/httpd/bin/httpd -M

以编译添加expires模块为例:

cd /src/httpd/modules/metadata/ #进入源码模块目录
/usr/local/httpd/bin/apxs -c -i -a mod_expires.c #编译、安装、启用expires模块
/etc/init.d/httpd restart #重新启动httpd加载

Apache运行模式选择prefork和worker

发布时间:May 22, 2012 // 分类:Apache // No Comments

prefork是Unix平台上默认的MPM,编译时可使用参数./configure –with-mpm=worker自定义。
查看当前MPM:

#https://www.haiyun.me
httpd -V|grep mpm
 -D APACHE_MPM_DIR="server/mpm/prefork"

prefork采用预派生子进程方式,用单独的子进程来处理不同的请求,每个进程时间内只能维持一个连接,进程之间彼此独立。
prefork配置:

<IfModule prefork.c>
ServerLimit      256 #服务器端连接数限制,最大2000
StartServers       8 #初始启动8个进程
MinSpareServers    5 #最小空闲进程数
MaxSpareServers   20 #最大空闲进程数,超过限制父进程将杀死多余的子进程。
MaxClients       256 #最大连接、进程数,一般和ServerLimit相同,超过此限制的请求进入等候队列。
MaxRequestsPerChild  4000 #每个进程生存期间可处理请求次数,超过终结此进程。
</IfModule>

worker支持多线程和多进程混合模型的MPM,使用多线程来处理,可以处理相对大量的请求,而系统资源的开销要小于基于prefork的服务器。
worker配置:

<IfModule worker.c>
StartServers         10 #默认启动子进程数
MaxClients         150 #同一时间最大连接数
MinSpareThreads     25 #最小空闲线程数
MaxSpareThreads     75 #最大空闲线程数
ThreadsPerChild     25 #每个进程建立的常驻线程数
MaxRequestsPerChild  40000 #每个进程生存期间可处理请求次数,超过终结此进程。
</IfModule>

Apache配置301重定向

发布时间:May 19, 2012 // 分类:Apache // No Comments

网站目录或网页出现变动要使用301重定向转移权重,有时域名也要将www.haiyun.me重定向到www.haiyun.me,本文记录下Apaceh下301重定向方法,Nginx下301重定向请参考:https://www.haiyun.me/archives/nginx-301.html
1.使用RedirectMatch和Redirect重定向,这两个命令使用方法相似,RedirectMatch支持正则表达式,可以批量重定向。
使用语法:

Redirect [status] URL URL
RedirectMatch [status] regex URL

[status]可用参数:

permanent 返回永久性重定向状态码(301),表示此资源的链接变动是永久性的。
temp 返回临时性重定向状态码(302),默认值。
seeother 返回一状态码(303),表示此资源已经被替代。
gone 返回状态码(410),表示此资源已经被永久性地删除了。如果指定了这个状态码,则URL参数将被忽略。

应用示例:

Redirect permanent /index.html https://www.haiyun.me/index.php
RedirectMatch 301 (.*).gif$ https://www.haiyun.me/$1.jpg

2.使用URL重写模块mod_rewrite重定向

RewriteEngine on
rewritecond %{http_host} ^www.haiyun.me [nc] #定义主机名变量,匹配执行下条规则。
rewriterule ^/(.*)$ https://www.haiyun.me/$1 [r=301,nc] #301重定向到www.haiyun.me,nc不区分大小写。
分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...