CentOS lighttpd安装及网站目录配置是怎样的

2023-04-14 03:03:00 配置 安装 是怎样

CentOS lighttpd安装及网站目录配置是怎样的

1.安装lighttpd

yum -y install lighttpd

2.启动lighttpd

service lighttpd start

3.设置开机启动

chkconfig lighttpd on

4.配置虚拟主机

vim /etc/lighttpd/lighttpd.conf

server.modules = (

"mod_access",

"mod_alias",

"mod_compress",

"mod_redirect",

##"mod_rewrite",

)

server.document-root = "/var/www/html"

server.port = 80

server.pid-file = "/var/run/lighttpd.pid"

server.username = "lighttpd"

server.groupname = "lighttpd"

server.errorlog = "/var/log/lighttpd/error.log"

index-file.names = ( "index.php", "index.html",

"index.htm", "default.htm" )

url.access-deny = ( "~", ".inc" )

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

## Use ipv6 if available

##include_shell "/usr/share/lighttpd/use-ipv6.pl"

dir-listing.encoding = "utf-8"

server.dir-listing = "enable"

compress.cache-dir = "/var/cache/lighttpd/compress/"

compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6

##server.port = 80

# bind to port 8080 instead of 80 for IPv4

##server.bind = "127.0.0.1"

# bind to port 8081 instead of 80 for IPv6

##server.port = 8081

##server.bind = "::1"

vim /etc/lighttpd/conf.d/fastcgi.conf

fastcgi.server = ( ".php" =>

((

"bin-path" => "/usr/bin/php-cgi",

"socket" => "/tmp/php.socket",

"max-procs" => 1,

"bin-environment" => (

"PHP_FCGI_MAX_REQUESTS" => "10000",

"PHP_FCGI_CHILDREN" => "4"

),

"bin-copy-environment" => (

"PATH", "SHELL", "USER"

),

"daemonize" => "no"

))

)

5.重启lighttpd

service lighttpd restart

6.查看是否启动成功

ps aux|grep lighttpd

7.配置虚拟主机目录

mkdir -p /var/www/vhosts/www.test.com

vim /etc/lighttpd/conf.d/vhosts.conf

$HTTP["host"] == "www.test.com" {

server.document-root = "/var/www/vhosts/www.test.com"

}

8.重启lighttpd

service lighttpd restart

9.查看是否启动成功

ps aux|grep lighttpd

相关文章