phpfastcgi+lighttpd的安装
[
2010/06/08 07:28 | by xiaoyuwxz ]
2010/06/08 07:28 | by xiaoyuwxz ]
lighttpd的安装
1、先安装mysql
2、安装php,php的编译参数加上 --enable-fastcgi --enable-force-cgi-redirect
3、安装lighttpd
a、安装pcre
tar zxvf pcre-7.9.tar.gz
cd pcre-7.9/
./configure
make
make install
cd ../
b、安装lighttpd
tar xzvf lighttpd-1.4.26.tar.gz
cd lighttpd-1.4.26
./configure --prefix=/web/lighttpd
make
make install
mkdir /etc/lighttpd
cp doc/lighttpd.conf /etc/lighttpd/
cp doc/sysconfig.lighttpd /etc/sysconfig/lighttpd
cp doc/rc.lighttpd.redhat /etc/init.d/lighttpd
vi /etc/init.d/lighttpd
lighttpd="/usr/sbin/lighttpd修改为lighttpd="/web/lighttpd/sbin/lighttpd" 改为你的lighttpd的安装路径
vi /etc/lighttpd/lighttpd.conf 修改配置文件
打开需要的模块,去掉前面的# ( "mod_rewrite", "mod_alias", "mod_access", "mod_fastcgi", "mod_cgi", "mod_compress", "mod_accesslog" )
server.document-root = "/srv/www/htdocs/" 修改为自己的路径
如:
server.document-root = /home/wwwroot/htdocs
#server.pid-file = "/var/run/lighttpd.pid" 打开这一句
#server.username = "wwwrun" 改成自己的用户
#server.groupname = "wwwrun" 改成自己的用户组
如自己加一个
groupadd wwwrun
useradd wwwrun -g wwwrun -d /home/wwwroot/htdocs -s /sbin/nologin
查找下面的:
#fastcgi.server = ( ".php" =>
# ( "localhost" =>
# (
# "socket" => "/var/run/lighttpd/php-f astcgi.socket",
# "bin-path" => "/usr/local/bin/php-cg i"
# )
# )
# )
打开
#cgi.assign = ( ".pl" => "/usr/bin/perl",
# ".cgi" => "/usr/bin/perl" )
打开
mkdir -p /var/run/lighttpd/
chown -R www.www /var/run/lighttpd/
chmod -R 777 /var/run/lighttpd/
mkdir -p /var/log/lighttpd/
chmod -R 777 /var/log/lighttpd/
上面一段较重要,否则会启动不了lighttpd
chkconfig --add lighttpd
chkconfig lighttpd on
service lighttpd start
在/home/wwwroot/htdocs里建个phpinfo.php进行测试
phpinfo();
?>
1、先安装mysql
2、安装php,php的编译参数加上 --enable-fastcgi --enable-force-cgi-redirect
3、安装lighttpd
a、安装pcre
tar zxvf pcre-7.9.tar.gz
cd pcre-7.9/
./configure
make
make install
cd ../
b、安装lighttpd
tar xzvf lighttpd-1.4.26.tar.gz
cd lighttpd-1.4.26
./configure --prefix=/web/lighttpd
make
make install
mkdir /etc/lighttpd
cp doc/lighttpd.conf /etc/lighttpd/
cp doc/sysconfig.lighttpd /etc/sysconfig/lighttpd
cp doc/rc.lighttpd.redhat /etc/init.d/lighttpd
vi /etc/init.d/lighttpd
lighttpd="/usr/sbin/lighttpd修改为lighttpd="/web/lighttpd/sbin/lighttpd" 改为你的lighttpd的安装路径
vi /etc/lighttpd/lighttpd.conf 修改配置文件
打开需要的模块,去掉前面的# ( "mod_rewrite", "mod_alias", "mod_access", "mod_fastcgi", "mod_cgi", "mod_compress", "mod_accesslog" )
server.document-root = "/srv/www/htdocs/" 修改为自己的路径
如:
server.document-root = /home/wwwroot/htdocs
#server.pid-file = "/var/run/lighttpd.pid" 打开这一句
#server.username = "wwwrun" 改成自己的用户
#server.groupname = "wwwrun" 改成自己的用户组
如自己加一个
groupadd wwwrun
useradd wwwrun -g wwwrun -d /home/wwwroot/htdocs -s /sbin/nologin
查找下面的:
#fastcgi.server = ( ".php" =>
# ( "localhost" =>
# (
# "socket" => "/var/run/lighttpd/php-f astcgi.socket",
# "bin-path" => "/usr/local/bin/php-cg i"
# )
# )
# )
打开
#cgi.assign = ( ".pl" => "/usr/bin/perl",
# ".cgi" => "/usr/bin/perl" )
打开
mkdir -p /var/run/lighttpd/
chown -R www.www /var/run/lighttpd/
chmod -R 777 /var/run/lighttpd/
mkdir -p /var/log/lighttpd/
chmod -R 777 /var/log/lighttpd/
上面一段较重要,否则会启动不了lighttpd
chkconfig --add lighttpd
chkconfig lighttpd on
service lighttpd start
在/home/wwwroot/htdocs里建个phpinfo.php进行测试
phpinfo();
?>
vsftpd 的错误提示:500 OOPS: could not bind listening IPv4 socket
[
2010/06/05 01:58 | by xiaoyuwxz ]
2010/06/05 01:58 | by xiaoyuwxz ]
因redhat AS4的yum中未找到vsftpd,只好自己研究源码包的安装,原来的安装都是直接用脚本yum安装,碰上这系统,也没办法,逼自己去学源码安装。
经过一两小时的学习并测试,终于把源码安装vsftpd-2.2.2.tar.gz的脚本写好了,并把yum时安装的vsftpd服务脚本借鉴过来了,因自己并不懂C的语法(以前在学校学得太差了),只能凭感觉去改改,但最终能用了。
于是,上传源码到服务器,执行安装,几秒的时候安装结束,发现提示出错。
500 OOPS: could not bind listening IPv4 socket 依然google,
原因找到了,原来是系统原来安装了vsftpd,并且是以XINET守护进程启动的。后来被我卸载了
我的vsftpd是使用STANDALONE独立模式,要关闭xinet方式的启动。修改方法如下:
直接修改/etc/xinetd.d/vsftpd文件,把最后的disable=no改成disable=yes
service xinetd restart
service vsftpd restart
搞定。
经过一两小时的学习并测试,终于把源码安装vsftpd-2.2.2.tar.gz的脚本写好了,并把yum时安装的vsftpd服务脚本借鉴过来了,因自己并不懂C的语法(以前在学校学得太差了),只能凭感觉去改改,但最终能用了。
于是,上传源码到服务器,执行安装,几秒的时候安装结束,发现提示出错。
500 OOPS: could not bind listening IPv4 socket 依然google,
原因找到了,原来是系统原来安装了vsftpd,并且是以XINET守护进程启动的。后来被我卸载了
我的vsftpd是使用STANDALONE独立模式,要关闭xinet方式的启动。修改方法如下:
直接修改/etc/xinetd.d/vsftpd文件,把最后的disable=no改成disable=yes
service xinetd restart
service vsftpd restart
搞定。
为redhat AS4安装yum
[
2010/06/05 01:43 | by xiaoyuwxz ]
2010/06/05 01:43 | by xiaoyuwxz ]
前天接了个环境lnmp的配置,原让其安装centos5.5的,没想对方机房装了其他版本的linux,因平时接触的版本也不多,所以,通过查看 cat /proc/version 才得知系统为32位的redhat AS4。
登录后发现没法使用yum,于是网上搜索,找到方法,以下为转贴:
在标准的Redhat Enterprise Linux上,默认没有安装yum,需要单独下载并安装。
此外,Redhat Enterprise Linux的更新是由Redhat提供的收费服务,但由于Redhat Enterprise Linux和CentOS是基本通用的,所以可用CentOS源来升级redhat。
1. 首先安装yum和相关的rpm包
注意:本安装包只提供给as4系统之用
http://www.swsoft.com.cn/downloads/Prima/Tools/yum_forAS4.tar.gz
或 http://www.haoxm.net/tools/yum_forAS4.tar.gz
下载并解压缩yum包和升级文件
rpm -ivh *.rpm
2. 将解压缩后得到的CentOS-Base.repo复制到/etc/yum.repos.d/目录里边
注意:本CentOS-Base.repo文件只提供给as4系统之用
3. 执行如下命令导入GPG Key
rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-4
或 rpm --import http://www.haoxm.net/tools/RPM-GPG-KEY-CentOS-4
现在可以开始使用yum了。yum的主要参数包括search/install/upgrade/remove。
注意:
1. 使用yum的过程中,有些程序包是不能升级的。
2. 如果使用yum对全部系统都进行升级,则会发现升级后系统版本将从redhat变成centos
这是因为升级使用的是免费centos的yum源,所以升级最好有选择的执行
yum update了一下,文件是下载了,但提示出错未安装,看来能否升为centos还有待再次试验,于是又搜来redhat 的源更换,源码如下:
[base]
name=Red Hat Enterprise AS release 4 Updates
baseurl= http://apt.sw.be/redhat/el4/en/i386/dag/
http://apt.sw.be/redhat/el4/en/i386/rpmforge/
http://mirror.cpsc.ucalgary.ca/mirror/dag/redhat/el4/en/i386/dag/
http://mirror.cpsc.ucalgary.ca/mirror/dag/redhat/el4/en/i386/rpmforge/
gpgcheck=0
yum后发现能更新,就是有用的包太少了。
登录后发现没法使用yum,于是网上搜索,找到方法,以下为转贴:
在标准的Redhat Enterprise Linux上,默认没有安装yum,需要单独下载并安装。
此外,Redhat Enterprise Linux的更新是由Redhat提供的收费服务,但由于Redhat Enterprise Linux和CentOS是基本通用的,所以可用CentOS源来升级redhat。
1. 首先安装yum和相关的rpm包
注意:本安装包只提供给as4系统之用
http://www.swsoft.com.cn/downloads/Prima/Tools/yum_forAS4.tar.gz
或 http://www.haoxm.net/tools/yum_forAS4.tar.gz
下载并解压缩yum包和升级文件
rpm -ivh *.rpm
2. 将解压缩后得到的CentOS-Base.repo复制到/etc/yum.repos.d/目录里边
注意:本CentOS-Base.repo文件只提供给as4系统之用
3. 执行如下命令导入GPG Key
rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-4
或 rpm --import http://www.haoxm.net/tools/RPM-GPG-KEY-CentOS-4
现在可以开始使用yum了。yum的主要参数包括search/install/upgrade/remove。
注意:
1. 使用yum的过程中,有些程序包是不能升级的。
2. 如果使用yum对全部系统都进行升级,则会发现升级后系统版本将从redhat变成centos
这是因为升级使用的是免费centos的yum源,所以升级最好有选择的执行
yum update了一下,文件是下载了,但提示出错未安装,看来能否升为centos还有待再次试验,于是又搜来redhat 的源更换,源码如下:
[base]
name=Red Hat Enterprise AS release 4 Updates
baseurl= http://apt.sw.be/redhat/el4/en/i386/dag/
http://apt.sw.be/redhat/el4/en/i386/rpmforge/
http://mirror.cpsc.ucalgary.ca/mirror/dag/redhat/el4/en/i386/dag/
http://mirror.cpsc.ucalgary.ca/mirror/dag/redhat/el4/en/i386/rpmforge/
gpgcheck=0
yum后发现能更新,就是有用的包太少了。
nginx学习之Location,rewrite,防盗链,禁止访问
[
2010/06/03 20:09 | by xiaoyuwxz ]
2010/06/03 20:09 | by xiaoyuwxz ]
一、介绍Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为“engine X”, 是一个高性能的HTTP和反向代理服务器,同时也是一个IMAP/POP3/SMTP 代理服务器.
二、Location语法语法:location [=|~|~*|^~] /uri/ { … }
注:
1、~ 为区分大小写匹配
2、~* 为不区分大小写匹配
3、!~和!~*分别为区分大小写不匹配及不区分大小写不匹配
示例一:
location / { }
匹配任何查询,因为所有请求都以 / 开头。但是正则表达式规则将被优先和查询匹配。
示例二:
location =/ {}
仅仅匹配/
示例三:
location ~* \.(gif|jpg|jpeg)$ {
rewrite \.(gif|jpg)$ /logo.png;
}
注:不区分大小写匹配任何以gif,jpg,jpeg结尾的文件
三、ReWrite语法
last – 基本上都用这个Flag。
break – 中止Rewirte,不在继续匹配
redirect – 返回临时重定向的HTTP状态302
permanent – 返回永久重定向的HTTP状态301
1、下面是可以用来判断的表达式:
-f和!-f用来判断是否存在文件
-d和!-d用来判断是否存在目录
-e和!-e用来判断是否存在文件或目录
-x和!-x用来判断文件是否可执行
2、下面是可以用作判断的全局变量
例:http://localhost:88/test1/test2/test.php
$host:localhost
$server_port:88
$request_uri:http://localhost:88/test1/test2/test.php
$document_uri:/test1/test2/test.php
$document_root:D:\nginx/html
$request_filename:D:\nginx/html/test1/test2/test.php
四、Redirect语法
server {
listen 80;
server_name start.igrow.cn;
index index.html index.php;
root html;
if ($http_host !~ “^star\.igrow\.cn$" [点击图片可在新窗口打开] {
rewrite ^(.*) http://star.igrow.cn$1 redirect;
}
}
五、防盗链location ~* \.(gif|jpg|swf)$ {
valid_referers none blocked start.igrow.cn sta.igrow.cn;
if ($invalid_referer) {
rewrite ^/ http://$host/logo.png;
}
}
六、根据文件类型设置过期时间
location ~* \.(js|css|jpg|jpeg|gif|png|swf)$ {
if (-f $request_filename) {
expires 1h;
break;
}
}
七、禁止访问某个目录
location ~* \.(txt|doc)${
root /data/www/wwwroot/linuxtone/test;
deny all;
}
二、Location语法语法:location [=|~|~*|^~] /uri/ { … }
注:
1、~ 为区分大小写匹配
2、~* 为不区分大小写匹配
3、!~和!~*分别为区分大小写不匹配及不区分大小写不匹配
示例一:
location / { }
匹配任何查询,因为所有请求都以 / 开头。但是正则表达式规则将被优先和查询匹配。
示例二:
location =/ {}
仅仅匹配/
示例三:
location ~* \.(gif|jpg|jpeg)$ {
rewrite \.(gif|jpg)$ /logo.png;
}
注:不区分大小写匹配任何以gif,jpg,jpeg结尾的文件
三、ReWrite语法
last – 基本上都用这个Flag。
break – 中止Rewirte,不在继续匹配
redirect – 返回临时重定向的HTTP状态302
permanent – 返回永久重定向的HTTP状态301
1、下面是可以用来判断的表达式:
-f和!-f用来判断是否存在文件
-d和!-d用来判断是否存在目录
-e和!-e用来判断是否存在文件或目录
-x和!-x用来判断文件是否可执行
2、下面是可以用作判断的全局变量
例:http://localhost:88/test1/test2/test.php
$host:localhost
$server_port:88
$request_uri:http://localhost:88/test1/test2/test.php
$document_uri:/test1/test2/test.php
$document_root:D:\nginx/html
$request_filename:D:\nginx/html/test1/test2/test.php
四、Redirect语法
server {
listen 80;
server_name start.igrow.cn;
index index.html index.php;
root html;
if ($http_host !~ “^star\.igrow\.cn$" [点击图片可在新窗口打开] {
rewrite ^(.*) http://star.igrow.cn$1 redirect;
}
}
五、防盗链location ~* \.(gif|jpg|swf)$ {
valid_referers none blocked start.igrow.cn sta.igrow.cn;
if ($invalid_referer) {
rewrite ^/ http://$host/logo.png;
}
}
六、根据文件类型设置过期时间
location ~* \.(js|css|jpg|jpeg|gif|png|swf)$ {
if (-f $request_filename) {
expires 1h;
break;
}
}
七、禁止访问某个目录
location ~* \.(txt|doc)${
root /data/www/wwwroot/linuxtone/test;
deny all;
}





