利用lighttpd Web引擎在Ubuntu 16.04系统中搭建网站系统

咱们在Linux服务器中搭建建站系统较为多见的是利用Nginx或者是Apache,这个应该是占用大部分网站站长使用的WEB引擎。可是,也有不少网友会选择其余引擎环境的,好比咱们熟知的还有Litespeed、Lighttpd,以及其余多种引擎方式。其实这些引擎方式都是能够建站使用的,并且各有优势。好比lighttpd占用资源小,适合在资源不足且须要节省资源的服务器中运行。php

Lighttpd提供了一个轻量级的Web服务器,它可以在比Apache等服务器使用更少内存的状况下为大型负载提供服务。 在这篇文章中将介绍如何在Ubuntu 16.04上安装和配置lighttpd Web服务器。 若是咱们有喜欢的也能够参考使用到生产环境中。html

利用lighttpd Web引擎在Ubuntu 16.04系统中搭建网站系统

第1、升级软件源和系统python

apt-get update && apt-get upgrade -yweb

若是咱们有必要的话能够也将当前服务器别名更换成须要的,通常咱们就默认。浏览器

第2、安装Lighttpd和设置ruby

apt-get install lighttpd -y服务器

直接执行脚本安装,一旦安装以后咱们能够直接在浏览器输入当前服务器的IP地址,能够看到默认的界面。php7

/etc/lighttpd/lighttpd.conf并发

配置文件位于这里,咱们能够根据实际须要开启和设置参数。在server.modules里咱们能够看到列出的模块,若是是#表示禁止的,咱们删除他表示开启。server.max-connections 是并发数的设置,能够调节参数。socket

第3、建立WEB网站环境实例

一、建立网站环境

lighty-enable-mod simple-vhost

二、重启Lighttpd生效

systemctl restart lighttpd.service

三、修改配置

/etc/lighttpd/conf-available/10-simple-vhost.conf

在当前文件设置。

simple-vhost.server-root = "/var/www/html"
simple-vhost.document-root = "htdocs"
simple-vhost.default-host = "bandwagonhoster.com"

根据须要修改为咱们配置网站的参数。网站目录位于/var/www/html中。

systemctl restart lighttpd.service

配置完毕后重启生效。

第4、虚拟机设置过程

一、启动

lighty-enable-mod evhost

二、重启lighttpd

systemctl restart lighttpd.service

三、配置文件

/etc/lighttpd/conf-available/10-evhost.conf

修改配置文件:

evhost.path-pattern = "/var/www/html/%0/htdocs/"

server.document-root = "/var/www/html/bandwagonhoster.com/htdocs"

修改对应网站域名和目录。

四、重启生效

systemctl restart lighttpd.service

第5、建立网站目录

既然咱们上面配置完毕文件目录后,咱们尚未建立网站文件夹,这里来建立。

mkdir -p /var/www/html/bandwagonhoster.com/htdocs/

根据实际的域名建立,咱们若是有多个域名能够一并建立多个。

mkdir -p /var/www/html/{example.net/htdocs,example.org/htdocs}

咱们再建立软链接。

ln -s /home/example-user/bandwagonhoster.com/ /var/www/html/bandwagonhoster.com

第6、配置FastCGI

一、安装Python

apt-get install python

二、安装Ruby

apt-get install ruby

三、为CGI安装PHP7

apt-get install php7.0-cgi

四、检查配置文件

/etc/lighttpd/conf-enabled/15-fastcgi-php.conf

检查:

fastcgi.server += ( ".php" =>
((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/var/run/lighttpd/php.socket",
"max-procs" => 1,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "10000"
),
"bin-copy-environment" => (
"PATH", "SHELL", "USER"
),
"broken-scriptfilename" => "enable"
))
)

最后,是否是比较麻烦?若是咱们只是建站应用就没有必要这样操做,确实浪费时间也没有必要。咱们平时本身使用仍是安装网站环境,常规的就能够。

相关文章
相关标签/搜索