<b>CentOS搭建配置lighttpd(php、Virtual Host)</b>[服务器安全]
本文“<b>CentOS搭建配置lighttpd(php、Virtual Host)</b>[服务器安全]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
1、解压lighttpd-1.4.23.tar.gz
[root@localhost ~]# tar zxvf lighttpd-1.4.23.tar.gz
2、试安装lighttpd-1.4.23
[root@localhost ~]# cd lighttpd-1.4.23
[root@localhost lighttpd-1.4.23]# ./configure --prefix=/usr/local/lighttpd
configure: error: in `/root/lighttpd-1.4.23':
configure: error: no acceptable C compiler found in $PATH
3、配置yum网站
1、安装gcc呈现错误
[root@localhost yum.repos.d]# yum install gcc
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=addons error was
[Errno 4] IOError: <urlopen error (-3, 'Temporary failure in name resolution')>
Error: Cannot find a valid baseurl for repo: addons
2、改正yum目录及设置域名服务
[root@localhost lighttpd-1.4.23]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vi CentOS-Base.repo
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
改成
baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
另:国内镜像http://centos.ustc.edu.cn
[root@localhost yum.repos.d]# echo "nameserver 8.8.8.8" >> /etc/resolv.conf
Google答应将严峻遵守DNS协议,即不拦阻、不劫持和不过滤用户查询.
Google Public DNS服务器IP
8.8.8.8 谷歌-public-dns-a.谷歌.com
8.8.4.4 谷歌-public-dns-b.谷歌.com
3、确认能拜候mirrorlist.centos.org
[root@localhost yum.repos.d]# ping mirrorlist.centos.org
4、安装gcc
[root@localhost yum.repos.d]# yum install gcc
5、安装其他包
[root@localhost yum.repos.d]# yum install pcre pcre-devel zlib-devel bzip2 bzip2-devel
6、安装lighttpd-1.4.23
[root@localhost yum.repos.d]# cd ~/lighttpd-1.4.23
[root@localhost lighttpd-1.4.23]# ./configure --prefix=/usr/local/lighttpd
[root@localhost lighttpd-1.4.23]# make
[root@localhost lighttpd-1.4.23]# make install
7、配置lighttpd-1.4.23
[root@localhost lighttpd-1.4.23]# cp ./doc/lighttpd.conf /usr/local/lighttpd/
[root@localhost lighttpd-1.4.23]# cd /usr/local/lighttpd/
[root@localhost lighttpd]# vi lighttpd.conf
server.modules = (
"mod_rewrite",
"mod_redirect",
"mod_alias",
"mod_access",
# "mod_trigger_b4_dl",
# "mod_auth",
# "mod_status",
# "mod_setenv",
# "mod_fastcgi",
"mod_proxy",
# "mod_simple_vhost",
"mod_evhost", #虚拟主机
# "mod_userdir",
# "mod_cgi",
# "mod_compress",
# "mod_ssi",
# "mod_usertrack",
# "mod_expire",
# "mod_secdownload",
# "mod_rrdtool",
"mod_accesslog" )
server.document-root = "/var/www/htdocs/"
#proxy
#tomcat proxy 域名转向TOMCAT
$HTTP["host"] == "www.6688.cc" {
proxy.server = ( "" => ( ( "host" => "192.168.0.243",
"port" => 8001,
"fix-redirects" => 1
) ) )
}
#web proxy
$HTTP["host"] == "www.linuxidc.com" {
proxy.server = ( "" => ( ( "host" => "192.168.0.244" ) ) )
}
#Virtual Host
$HTTP["host"] == "www.linuxidc.net" {
server.name = "www.linuxidc.net"
server.document-root = "/var/www/htdocs/test"
server.errorlog = "/var/log/lighttpd/test-error.log"
accesslog.filename = "/var/log/lighttpd/test-access.log"
}
8、成立相关目录
[root@localhost lighttpd]# mkdir -p /var/log/lighttpd
[root@localhost lighttpd]# mkdir -p /var/www/htdocs
[root@localhost lighttpd]# cd /var/www/htdocs
[root@localhost htdocs]# vi index.html
<html><body><h1>It works on lighttpd</h1></body></html>
启动lighttpd
[root@localhost htdocs]# /usr/local/lighttpd/sbin/lighttpd -f /usr/local/lighttpd/lighttpd.conf
搭建http端口为8001的TOMCAT
WINDOWS平台可在C:\WINDOWS\system32\drivers\etc\hosts文件加上192.168.0.243 www.6688.cc
便可通过www.6688.cc拜候lighttpd域名转向
9、配置light支持php
1、安装php
[root@localhost ~]# yum install php
[root@localhost ~]# /usr/bin/php-cgi -v
呈现的信息中有个(cgi-fcgi)表示支持fast-cgi了
2、配置ighttpd.conf
[root@localhost ~]# cd /usr/local/lighttpd/
以上是“<b>CentOS搭建配置lighttpd(php、Virtual Host)</b>[服务器安全]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |