浏览模式: 标准 | 列表分类:apache/web
Submitted by admin on 2013, March 15, 4:45 PM
[Thu Aug 15 17:32:57.808228 2013] [authz_core:error] [pid 1418:tid 140248106297088] [client 183.31.217.145:15391] AH01630: client denied by server configuration: /www/web/default/index.html
<Directory />
AllowOverride none
Require all denied
</Directory>
<Directory /www/web>
AllowOverride none
Require all granted
#Require all denied
</Directory>
<Directory /www/web/default>
Options FollowSymLinks
AllowOverride None
#Order allow,deny
#Allow from all
Require all granted
</Directory>
apache/web | 评论:0
| Trackbacks:0
| 阅读:808
Submitted by admin on 2013, March 15, 3:54 PM
wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6
/usr/local/apache2/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
如果出现如下错误:
mod_rpaf-2.0.c: In function 'rpaf_cleanup':
mod_rpaf-2.0.c:150: error: 'conn_rec' has no member named 'remote_ip'
mod_rpaf-2.0.c:151: error: 'conn_rec' has no member named 'remote_addr'
mod_rpaf-2.0.c:151: warning: implicit declaration of function 'inet_addr'
mod_rpaf-2.0.c:151: error: 'conn_rec' has no member named 'remote_ip'
mod_rpaf-2.0.c: In function 'change_remote_ip':
mod_rpaf-2.0.c:164: error: 'conn_rec' has no member named 'remote_ip'
mod_rpaf-2.0.c:183: error: 'conn_rec' has no member named 'remote_ip'
mod_rpaf-2.0.c:186: error: 'conn_rec' has no member named 'remote_ip'
mod_rpaf-2.0.c:187: error: 'conn_rec' has no member named 'remote_addr'
mod_rpaf-2.0.c:187: error: 'conn_rec' has no member named 'remote_ip'
apxs:Error: Command failed with rc=65536
#将mod_rpaf-2.0.c的150、151、164、183、186、187这几行的remote_ip修改成client_ip,remote_addr修改成client_addr。
在httpd.conf加入如下代码:
LoadModule rpaf_module modules/mod_rpaf-2.0.so
<IfModule mod_rpaf.c>
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 127.0.0.1
RPAFheader X-Forwarded-For
</IfModule>
apache/web | 评论:0
| Trackbacks:0
| 阅读:1023
Submitted by admin on 2013, January 8, 9:12 PM
1.
Error: Configure: error: xml2-config not found. Please check your libxml2 installation.
Fix: yum install libxml2 libxml2-devel
# aptitude install libxml2-dev (For ubuntu)
2.
Error: configure: error: Cannot find OpenSSL’s
Fix: yum install openssl openssl-devel
3.
Error: Configure: error: Please reinstall the BZip2 distribution
Fix: yum install bzip2 bzip2-devel
4.
Error: Configure: error: Please reinstall the libcurl distribution -easy.h should be in /include/curl/
Fix: yum install curl curl-devel (For Redhat & Fedora)
# install libcurl4-gnutls-dev (For Ubuntu)
5.
Error: Configure: error: libjpeg.(also) not found.
Fix: yum -y install gd
yum -y install gd-devel
yum install libjpeg libjpeg-devel
6.
Error: Configure: error: libpng.(also) not found.
Fix: yum install libpng libpng-devel
#apt-get install libpng12-dev
7) Configure: error: freetype.h not found.
Solutions :
yum install freetype-devel
8) Configure: error: Unable to locate gmp.h
Solutions :
yum install gmp-devel
9) Configure: error: Cannot find MySQL header files under /usr.
Note that the MySQL client library is not bundled anymore!
Solutions :
yum install mysql-devel (For Redhat & Fedora)
# apt-get install libmysql++-dev (For Ubuntu)
10) Configure: error: Please reinstall the ncurses distribution
Solutions :
yum install ncurses ncurses-devel
11) Checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
Solutions :
yum install unixODBC-devel
12. --with-pspell=shared
Error: Configure: error: Cannot find pspell
Fix: yum install pspell-devel
13) --with-mcrypt=shared
Error: configure: error: mcrypt.h not found. Please reinstall libmcrypt.
Fix: yum install libmcrypt-devel
# apt-get install libmcrypt-dev
14) Configure: error: snmp.h not found. Check your SNMP installation.
Solutions :
yum install net-snmp net-snmp-devel
15)开启LDAP服务还需要
yum -y install openldap-devel openldap-servers openldap-clients
16)configure: error: No curses/termcap library found
网上有的说法是:
–with-named-curses-libs=/usr/lib/libncursesw.so.5
其实是不对的,虽然能解决configure的错误,但是make的时候会提示错误,正确的做法应该是
yum -y install ncurses-devel (for redhat)
apt-get install libncurses5-dev(for debian)
17)configure: error: cannot find output from lex; giving up
yum -y install flex
18)configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
yum -y install zlib-devel openssl-devel
debian:apt-get install zlib1g-dev
19)configure: error: libXpm.(a|so) not found.
apt-get install libxpm-dev
20) configure: error: Could not find pcre.h in /usr
Fix: yum install pcre-devel
21) configure: error: Could not find libpcre.(a|so) in /usr
Fix: cp /usr/lib/libpcre.a /usr/libpcre.a
Refer: http://bugs.php.net/bug.php?id=1647
22. --with-db4
Error: configure: error: DBA: Could not find necessary header file(s).
Fix: yum install gdbm-devel db4-devel
Error: configure: error: Header contains different version
Fix: --with-libdir=lib (--libdir=/usr/lib64, which is wrong)
Refer: http://bugs.php.net/bug.php?id=40707
23) configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing
Fix: yum install libc-client-devel
24. --enable-intl=shared
Error: configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.
25.--with-ldap=shared
Error: configure: error: Cannot find ldap.h
Fix: yum install openldap-devel
Error: configure: error: Cannot find ldap libraries in /usr/lib64.
26.--with-readline=shared
Error: configure: error: Please reinstall readline - I cannot find readline.h
Fix: yum install readline-devel
27.--with-tidy=shared
Error: configure: error: Cannot find libtidy
Fix: yum install libtidy-devel
28.--with-xsl=shared
Error: configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
Fix: yum install libxslt-devel
apache/web | 评论:0
| Trackbacks:0
| 阅读:954
Submitted by admin on 2013, January 8, 9:12 PM
yum install libxml2-devel.x86_64
configure: error: Cannot find OpenSSL’s
yum install openssl-devel.x86_64
configure: error: Could not find pcre.h in /usr/local
yum install pcre-devel.x86_64
configure: error: Could not find pcre.h in /usr/local
"--with-pcre-regex=/usr/include" \
configure: error: Could not find libpcre.(a|so) in /usr/include
"--with-pcre-regex=/usr" \
configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/
yum install curl-devel.x86_64
configure: error: libjpeg.(a|so) not found.
yum install libjpeg-devel.x86_64
configure: error: libpng.(a|so) not found.
yum install libpng-devel.x86_64
configure: error: freetype.h not found.
yum install freetype-devel.x86_64
configure: error: Please reinstall the iconv library.
"--with-iconv" \
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
yum install libmcrypt.x86_64 libmcrypt-devel.x86_64
configure: error: Please reinstall libmhash – I cannot find mhash.h
yum install mhash.x86_64 mhash-devel.x86_64
Note that the MySQL client library is not bundled anymore!
yum install php-mysql.x86_64 mysql-devel.x86_64
configure: error: Please reinstall the BZip2 distribution
yum install bzip2-devel.x86_64
configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
DISABLE IMAP
configure: error: Cannot find pspell
yum install aspell-devel.x86_64
configure: error: Cannot find libtidy
yum install libtidy.x86_64 libtidy-devel.x86_64
error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
yum install libxslt.x86_64 libxslt-devel.x86_64
collect2: ld returned 1 exit status
yum install glibc-utils.x86_64 libtool-ltdl-devel.x86_64
Step by step to guide PHP Compile
Step 1: Update & Install Development Tools & Libraries
yum update yum group install "Development Tools" yum group install "Development Libraries"
apache/web | 评论:0
| Trackbacks:0
| 阅读:1639
Submitted by admin on 2013, January 8, 9:11 PM
1. 安装Apahce, PHP, Mysql, 以及php连接mysql库组件。
yum -y install httpd php mysql mysql-server php-mysql
2. 配置开机启动服务
/sbin/chkconfig httpd on [设置apache服务器httpd服务开机启动]
/sbin/chkconfig --add mysqld [在服务清单中添加mysql服务]
/sbin/chkconfig mysqld on [设置mysql服务开机启动]
/sbin/service httpd start [启动httpd服务,与开机启动无关]
/sbin/service mysqld start [启动mysql服务,与开机无关]
3.设置 mysql数据库root帐号密码。
mysqladmin -u root password 'newpassword' [引号内填密码]
4. 让mysql数据库更安全
mysql -u root -p [此时会要求你输入刚刚设置的密码,输入后回车即可]
mysql> DROP DATABASE test; [删除test数据库]
mysql> DELETE FROM mysql.user WHERE user = ''; [删除匿名帐户]
mysql> FLUSH PRIVILEGES; [重载权限]
5. 按照以上的安装方式, 配置出来的默认站点目录为/var/www/html/新建一个php脚本:
phpinfo();
?>
6. 新建一个数据库,添加一个数据库用户,设置用户权限。写个php脚本测试一下数据库连接吧。
mysql> CREATE DATABASE my_db;
mysql> GRANT ALL PRIVILEGES ON my_db.* TO 'user'@'localhost' IDENTIFIED BY 'password';
//安 装apache扩展
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
//安装php的扩展
yum install php-gd
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
// 安装mysql扩展
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
7, 如果命令行没有phpize,运行以下命令
yum -y install php-devel
8,安装pdo
pecl install pdo
PHP_PDO_SHARED=1 pecl install pdo_mysql
pecl install PDO_SQLITE
9, 安装memcache
yum -y install php-pecl-memcache
10, 安装php-eaccelerator
yum install php-eaccelerator.i686
CentOS 5.x 系统下使用yum 升级php到5.2.x 最方便方法
近期使用testlink 1.82 ,提及php需要升级到5.2以上,而centos 5.x目前提供php版本为5.1.6,
通过以下方法升级PHP到5.2比较方便,现推荐给大家。
先将以下地址导入。
# rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
# vi /etc/yum.repos.d/CentOS-Base.repo 增加下面信息
[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
执行命令,自动升级。
yum update php -y
yum install libmcrypt -y
apache/web | 评论:0
| Trackbacks:0
| 阅读:831
Submitted by admin on 2012, September 27, 11:09 PM
--with-included-apr --with-apr=/usr --with-apr-util=/usr
apache/web | 评论:0
| Trackbacks:0
| 阅读:1009
Submitted by admin on 2012, July 21, 4:20 PM
大家好,今天51开源给大家介绍apache rewrite规则。apache的重写规则主要通过apache的mod_rewrite模块来实现。
(1) 认识规则重写
规则重写就是Web服务器会改写客户机符合特定规则的URL,用于实现资源重定向。Apache中文手册中所言,Apache的mod_rewreit模块是提供了强大URL操作的杀手级模块。可以实现几乎所有你梦想的URL操作类型,但其复杂性让很多初学者望而止步,对于apache rewrite规则需要你长时间的实践与理解。手册中有句话,我觉得很有意思。“对于mod_rewrite,或者是打退堂鼓永不再用,或是喜欢它并一生受用。”真的,apache rewrite比你想象的更有用。apache rewrite的实用性和灵活性会让你对它痴迷,51开源给大家加气,不要退缩。
(2) 规则重写的配置命令
-rewriteengine on/off
设置apache是否启用重写引擎
-rewriterule
作用: 为重写引擎定义重写规则
格式: rewriterule 正则表达式 替代字符串 [标记]
正则表达式元字符:
. 任意一个单字符
[chars] 字符类: "chars"中的任意一个字符
[^chars] 字符类: 不在"chars"中的字符
text1|text2 选择: text1 或 text2
? 前面的字符出现 0 或 1 次
* 前面的字符出现 0 或 N 次(N > 0)
+ 前面的字符出现 1 或 N 次(N > 1)
^ 锚定到行首
$ 锚定到行尾
\字符 转义字符
标记: C 链接到下一条件规则
F 强制禁止URL
G 强制废弃URL
L 结尾规则
N 跳转到开头、从开再来
NC 忽略大小写
P 强制为代理
R 强制为重定向
实例:rewriterule ^/$ http://bbs.51osos.com [R,L]
//对网站根目录的访问请求全转向http://bbs.51osos.com
-rewritecond
作用:定义重写发生的条件
格式:rewritecond 字符串 正则表达式 [标记]
字符串所包含一些特殊字符:
a. $N 反向rewriterule中的分组
b. %N 反向rewritecond中的分组
c. 服务器变量
%{HTTP_USER_AGENT} 客户机信息,包括操作系统和浏览器信息
%{HTTP_HOST} 请求的主机名
%{REMOTE_ADDR} 客户机IP地址
%{REMOTE_HOST} 客户机的主机名
%{REMOTE_PORT} 客户机连接服务器所有端口
%{REQUEST_METHOD} 客户机的请求方法
%{REQUEST_FILENAME} 客户机的请求的文件名
%{REQUEST_URI} 客户机请求URI
%{DOCUMENT_ROOT} 服务器的站点主目录
%{SERVER_NAME} 服务器的名称
%{SERVER_ADDR} 服务器的IP地址
%{SERVER_PORT} 服务器的端口号
特殊比较符号:
< 小于
> 大于
= 等于
-d 判断是不是存在的目录
-f 判断是不是存在的普通文件
-s 判断是不是为非空的普通文件
-x 判断是不是为可执行的文件
-l 判断是不是为链接文件
-U 判断是不是有效的URL
标记:
-NC 忽略大小写
-OR 或
实例:rewritecond %{REMOTE_ADDR} ^192.168.3.1
-rewritebase
作用:设置目录级重写的基准URL
格式:rewritebase URL-PATH
(3) 规则重写的应用案例
-移动站点主目录到站点的/bbs路径下
rewriteengine on
rewriterule ^/$ /bbs [R,L]
-利用规则重写实现基于域名的虚拟主机
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.abc\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^www\.abc\.com(.*) /web/abc$1
RewriteCond %{HTTP_HOST} ^www\.51osos \.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^www\.51osos\.com(.*) /web/51osos$1
apache/web | 评论:0
| Trackbacks:0
| 阅读:910
Submitted by admin on 2012, February 23, 5:02 PM
1.时区设置
有些时候,当你在PHP里使用date或mktime函数时,由于时区的不同,它会显示出一些很奇怪的信息。下面是解决这个问题的方法之一。就是设置你的服务器的时区。你可以在这里找到所有支持的时区的清单。
1.SetEnv TZ Australia/Melbourne
2. 搜索引擎友好的301永久转向方法
为什么这是搜索引擎友好的呢?因为现在很多现代的搜索引擎都有能根据检查301永久转向来更新它现有的记录的功能。
1.Redirect 301 http://www.aqee.net/home http://www.aqee.net/
3. 屏蔽下载对话框
通常,当你下载东西的时候,你会看到一个对话框询问你是保持这个文件还是直接打开它。如果你不想看到这个东西,你可以把下面的一段代码放到你的.htaccess文件里。
1.AddType application/octet-stream .pdf
2.AddType application/octet-stream .zip
3.AddType application/octet-stream .mov
4. 省去www前缀
SEO的一个原则是,确保你的网站只有一个URL。因此,你需要把所有的通过www的访问转向的非www,或者反这来。
1.RewriteEngine On
2.RewriteBase /
3.RewriteCond %{HTTP_HOST} ^www.lvtao.net [NC]
4.RewriteRule ^(.*)$ http://lvtao.net/$1 [L,R=301]
5. 个性化Error页面
对每个错误代码定制自己个性化的错误页面。
1.ErrorDocument 401 /error/401.php
2.ErrorDocument 403 /error/403.php
3.ErrorDocument 404 /error/404.php
4.ErrorDocument 500 /error/500.php
6. 压缩文件
通过压缩你的文件体积来优化网站的访问速度。
1.# 压缩 text, html, javascript, css, xml:
2.AddOutputFilterByType DEFLATE text/plain
3.AddOutputFilterByType DEFLATE text/html
4.AddOutputFilterByType DEFLATE text/xml
5.AddOutputFilterByType DEFLATE text/css
6.AddOutputFilterByType DEFLATE application/xml
7.AddOutputFilterByType DEFLATE application/xhtml+xml
8.AddOutputFilterByType DEFLATE application/rss+xml
9.AddOutputFilterByType DEFLATE application/javascript
10.AddOutputFilterByType DEFLATE application/x-javascript
7. 缓存文件
缓存文件是另外一个提高你的网站访问速度的好方法。
1.
2.Header set Cache-Control “max-age=2592000″
3.
8. 对某些文件类型禁止使用缓存
而另一方面,你也可以定制对某些文件类型禁止使用缓存。
1.# 显式的规定对脚本和其它动态文件禁止使用缓存
2.
3.Header unset Cache-Control
4.
安全问题
下面的htaccess代码能够提高你的web服务器的安全水平。图片链接盗用保护非常有用,它能防止其他人偷盗使用你的服务器上的图片资源。
1. 通过.htaccess放盗链
痛恨那些偷盗链接你的web服务器上的图片资源而耗尽了你的带宽的行为吗?试试这个,你可以防止这种事情的发生。
1.RewriteBase /
2.RewriteCond %{HTTP_REFERER} !^$
3.RewriteCond %{HTTP_REFERER} !^http://(www.)?aqee.net/.*$ [NC]
4.RewriteRule .(gif|jpg|swf|flv|png)$ /feed/ [R=302,L]
2. 防黑客
如果你想提高网站的安全等级,你可以去掉下面的几行代码,这样可以防止一些常见恶意URL匹配的黑客攻击技术。
1.RewriteEngine On
2.
3.# proc/self/environ? 没门!
4.RewriteCond %{QUERY_STRING} proc/self/environ [OR]
5.
6.# 阻止脚本企图通过URL修改mosConfig值
7.RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
8.
9.# 阻止脚本通过URL传递的base64_encode垃圾信息
10.RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]
11.
12.# 阻止在URL含有<\script>标记的脚本
13.RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
14.
15.# 阻止企图通过URL设置PHP的GLOBALS变量的脚本
16.RewriteCond %{QUERY_STRING} GLOBALS(=|[|\%[0-9A-Z]{0,2}) [OR]
17.
18.# 阻止企图通过URL设置PHP的_REQUEST变量的脚本
19.RewriteCond %{QUERY_STRING} _REQUEST(=|[|\%[0-9A-Z]{0,2})
20.
21.# 把所有被阻止的请求转向到403禁止提示页面!
22.RewriteRule ^(.*)$ index.php [F,L]
3. 阻止访问你的 .htaccess 文件
下面的代码可以阻止别人访问你的.htaccess文件。同样,你也可以设定阻止多种文件类型。
1.# 保护你的 htaccess 文件
2.
3.order allow,deny
4.deny from all
5.
6.
7.# 阻止查看指定的文件
8.
9. order allow,deny
10. deny from all
11.
12.
13.# 多种文件类型
14.
15. Order Allow,Deny
16. Deny from all
17.
4. 重命名 htaccess 文件
你可以通过重命名htaccess文件来对其进行保护。
1.AccessFileName htacc.ess
5. 禁止目录浏览
禁止服务器对外显示目录结构,反之亦然。
1.# 禁止目录浏览
2.Options All -Indexes
3.
4.# 开放目录浏览
5.Options All +Indexes
6. 改变缺省的Index页面
你可以把缺省的 index.html, index.php 或 index.htm 改成其它页面。
1.DirectoryIndex business.html
7. 通过引用信息来阻止某些不欢迎的浏览者
1.# 阻止来自某网站的用户
2.
3. RewriteEngine on
4. RewriteCond %{HTTP_REFERER} scumbag.com [NC,OR]
5. RewriteCond %{HTTP_REFERER} wormhole.com [NC,OR]
6. RewriteRule .* – [F]
7.
8.
8. 通过判断浏览器头信息来阻止某些请求
这个方法可以通过阻止某些机器人或蜘蛛爬虫抓取你的网站来节省你的带宽流量。
1.# 阻止来自某些特定网站的用户
2.
3.SetEnvIfNoCase ^User-Agent$ .*(craftbot|download|extract|stripper|sucker|ninja|clshttp|webspider
|leacher|collector|grabber|webpictures) HTTP_SAFE_BADBOT
4.SetEnvIfNoCase ^User-Agent$ .*(libwww-perl|aesop_com_spiderman) HTTP_SAFE_BADBOT
5.Deny from env=HTTP_SAFE_BADBOT
6.
9. 禁止脚本执行,加强你的目录安全
1.# 禁止某些目录里的脚本执行权限
2.AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi
3.Options -ExecCGI
apache/web | 评论:0
| Trackbacks:0
| 阅读:835