{"id":20824,"date":"2024-08-13T23:16:53","date_gmt":"2024-08-13T15:16:53","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=20824"},"modified":"2024-08-13T23:16:53","modified_gmt":"2024-08-13T15:16:53","slug":"install-lighttpd-server","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/install-lighttpd-server.html","title":{"rendered":"\u5728 Linux \u4e2d\u5b89\u88c5 Lighttpd Web \u670d\u52a1\u5668"},"content":{"rendered":"
Lighttpd \u662f\u4e00\u6b3e\u5f00\u6e90 Web \u670d\u52a1\u5668\u8f6f\u4ef6\u3002Lighttpd \u5b89\u5168\u5feb\u901f\uff0c\u7b26\u5408\u884c\u4e1a\u6807\u51c6\uff0c\u9002\u914d\u6027\u5f3a\u5e76\u4e14\u9488\u5bf9\u9ad8\u914d\u7f6e\u73af\u5883\u8fdb\u884c\u4e86\u4f18\u5316\u3002\u76f8\u5bf9\u4e8e\u5176\u5b83\u7684 Web \u670d\u52a1\u5668\u800c\u8a00\uff0cLighttpd \u5360\u7528\u5185\u5b58\u66f4\u5c11\uff1b\u56e0\u5176\u5bf9 CPU \u5360\u7528\u5c0f\u548c\u5bf9\u5904\u7406\u901f\u5ea6\u7684\u4f18\u5316\u800c\u5728\u6548\u7387\u548c\u901f\u5ea6\u65b9\u9762\u4ece\u4f17\u591a Web \u670d\u52a1\u5668\u4e2d\u8131\u9896\u800c\u51fa\u3002\u800c Lighttpd \u8bf8\u5982 FastCGI\u3001CGI\u3001\u8ba4\u8bc1\u3001\u8f93\u51fa\u538b\u7f29\u3001URL \u91cd\u5199\u7b49\u9ad8\u7ea7\u529f\u80fd\u66f4\u662f\u90a3\u4e9b\u9762\u4e34\u6027\u80fd\u538b\u529b\u7684\u670d\u52a1\u5668\u7684\u798f\u97f3\u3002<\/p>\n
\u4ee5\u4e0b\u662f\u6211\u4eec\u5728\u8fd0\u884c Ubuntu 15.04 \u6216 CentOS 7 Linux \u53d1\u884c\u7248\u7684\u673a\u5668\u4e0a\u5b89\u88c5 Lighttpd Web \u670d\u52a1\u5668\u7684\u7b80\u8981\u6d41\u7a0b\u3002<\/p>\n
\u8fd9\u91cc\u6211\u4eec\u901a\u8fc7\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u8fd9\u79cd\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u6765\u5b89\u88c5 Lighttpd\u3002\u53ea\u9700\u4ee5 sudo \u6a21\u5f0f\u5728\u7ec8\u7aef\u6216\u63a7\u5236\u53f0\u4e2d\u8f93\u5165\u4e0b\u9762\u7684\u6307\u4ee4\u5373\u53ef\u3002<\/p>\n
CentOS 7<\/strong><\/p>\n \u7531\u4e8e CentOS 7.0 \u5b98\u65b9\u4ed3\u5e93\u4e2d\u5e76\u6ca1\u6709\u63d0\u4f9b Lighttpd\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u5728\u7cfb\u7edf\u4e2d\u5b89\u88c5\u989d\u5916\u7684\u8f6f\u4ef6\u6e90 epel \u4ed3\u5e93\u3002\u4f7f\u7528\u4e0b\u9762\u7684 yum \u6307\u4ee4\u6765\u5b89\u88c5 epel\u3002<\/p>\n \u7136\u540e\uff0c\u6211\u4eec\u9700\u8981\u66f4\u65b0\u7cfb\u7edf\u53ca\u4e3a Lighttpd \u7684\u5b89\u88c5\u505a\u524d\u7f6e\u51c6\u5907\u3002<\/p>\n <\/p>\n Ubuntu 15.04<\/strong><\/p>\n Ubuntu 15.04 \u5b98\u65b9\u4ed3\u5e93\u4e2d\u5305\u542b\u4e86 Lighttpd\uff0c\u6240\u4ee5\u53ea\u9700\u66f4\u65b0\u672c\u5730\u4ed3\u5e93\u7d22\u5f15\u5e76\u4f7f\u7528 apt-get \u6307\u4ee4\u5373\u53ef\u5b89\u88c5 Lighttpd\u3002<\/p>\n <\/p>\n \u5982\u679c\u60f3\u4ece Lighttpd \u6e90\u7801\u5b89\u88c5\u6700\u65b0\u7248\u672c\uff08\u4f8b\u5982 1.4.39\uff09\uff0c\u6211\u4eec\u9700\u8981\u5728\u672c\u5730\u7f16\u8bd1\u6e90\u7801\u5e76\u8fdb\u884c\u5b89\u88c5\u3002\u9996\u5148\u6211\u4eec\u8981\u5b89\u88c5\u7f16\u8bd1\u6e90\u7801\u6240\u9700\u7684\u4f9d\u8d56\u5305\u3002<\/p>\n \u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u6267\u884c\u4e0b\u9762\u7684\u6307\u4ee4\u89e3\u538b\u7f29\u3002<\/p>\n \u7136\u540e\u4f7f\u7528\u4e0b\u9762\u7684\u6307\u4ee4\u8fdb\u884c\u7f16\u8bd1\u3002<\/p>\n \u6ce8\uff1a<\/strong>\u5728\u8fd9\u4efd\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5b89\u88c5\u7684\u662f\u9ed8\u8ba4\u914d\u7f6e\u7684 Lighttpd\u3002\u5176\u4ed6\u62d3\u5c55\u529f\u80fd\uff0c\u5982\u5bf9 SSL \u7684\u652f\u6301\uff0cmodrewrite\uff0cmod<\/em>redirect \u7b49\uff0c\u9700\u81ea\u884c\u914d\u7f6e\u3002<\/p>\n \u5f53\u7f16\u8bd1\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u628a\u5b83\u5b89\u88c5\u5230\u7cfb\u7edf\u4e2d\u4e86\u3002<\/p>\n \u5982\u679c\u6709\u66f4\u9ad8\u7684\u9700\u6c42\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u9ed8\u8ba4\u8bbe\u7f6e\u6587\u4ef6\uff0c\u5982\/etc\/lighttpd\/lighttpd.conf\uff0c\u6765\u5bf9 Lighttpd \u8fdb\u884c\u8fdb\u4e00\u6b65\u8bbe\u7f6e\u3002 \u800c\u5728\u8fd9\u4efd\u6559\u7a0b\u4e2d\u6211\u4eec\u5c06\u4f7f\u7528\u9ed8\u8ba4\u8bbe\u7f6e\uff0c\u4e0d\u5bf9\u8bbe\u7f6e\u6587\u4ef6\u8fdb\u884c\u4fee\u6539\u3002\u5982\u679c\u4f60\u66fe\u505a\u8fc7\u4fee\u6539\u5e76\u60f3\u68c0\u67e5\u8bbe\u7f6e\u6587\u4ef6\u662f\u5426\u51fa\u9519\uff0c\u53ef\u4ee5\u6267\u884c\u4e0b\u9762\u7684\u6307\u4ee4\u3002<\/p>\n \u5728 CentOS 7 \u4e2d\uff0c\u6211\u4eec\u9700\u521b\u5efa\u4e00\u4e2a\u5728 Lighttpd \u9ed8\u8ba4\u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6e\u7684 webroot \u6587\u4ef6\u5939\uff0c\u4f8b\u5982\/src\/www\/htdocs\u3002<\/p>\n \u800c\u540e\u5c06\u9ed8\u8ba4\u6b22\u8fce\u9875\u9762\u4ece\/var\/www\/lighttpd\u590d\u5236\u81f3\u521a\u521a\u65b0\u5efa\u7684\u76ee\u5f55\u4e2d\uff1a<\/p>\n \u73b0\u5728\uff0c\u901a\u8fc7\u6267\u884c systemctl \u6307\u4ee4\u6765\u91cd\u542f Web \u670d\u52a1\u3002<\/p>\n \u7136\u540e\u6211\u4eec\u5c06\u5b83\u8bbe\u7f6e\u4e3a\u4f34\u968f\u7cfb\u7edf\u542f\u52a8\u81ea\u52a8\u8fd0\u884c\u3002<\/p>\n \u5982\u8981\u8ba9\u6211\u4eec\u8fd0\u884c\u5728 Lighttpd \u4e0a\u7684\u7f51\u9875\u6216\u7f51\u7ad9\u80fd\u5728 Internet \u6216\u540c\u4e00\u4e2a\u7f51\u7edc\u5185\u88ab\u8bbf\u95ee\uff0c\u6211\u4eec\u9700\u8981\u5728\u9632\u706b\u5899\u7a0b\u5e8f\u4e2d\u8bbe\u7f6e\u6253\u5f00 80 \u7aef\u53e3\u3002\u7531\u4e8e CentOS 7 \u548c Ubuntu15.04 \u90fd\u9644\u5e26 Systemd \u4f5c\u4e3a\u9ed8\u8ba4\u521d\u59cb\u5316\u7cfb\u7edf\uff0c\u6240\u4ee5\u6211\u4eec\u9ed8\u8ba4\u7528\u7684\u90fd\u662f firewalld\u3002\u5982\u679c\u8981\u6253\u5f00 80 \u7aef\u53e3\u6216 http \u670d\u52a1\uff0c\u6211\u4eec\u53ea\u9700\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a<\/p>\n \u5728\u5c06 80 \u7aef\u53e3\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u7aef\u53e3\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee Lighttpd \u7684\u9ed8\u8ba4\u6b22\u8fce\u9875\u4e86\u3002\u6211\u4eec\u9700\u8981\u6839\u636e\u8fd0\u884c Lighttpd \u7684\u8bbe\u5907\u6765\u8bbe\u7f6e\u6d4f\u89c8\u5668\u7684 IP \u5730\u5740\u548c\u57df\u540d\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u4ee4\u6d4f\u89c8\u5668\u8bbf\u95ee http:\/\/lighttpd.linoxide.com\/ \uff0c\u540c\u65f6\u5c06\u8be5\u5b50\u57df\u540d\u6307\u5411\u4e0a\u8ff0 IP \u5730\u5740\u3002\u5982\u6b64\u4e00\u6765\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u6d4f\u89c8\u5668\u4e2d\u770b\u5230\u5982\u4e0b\u7684\u6b22\u8fce\u9875\u9762\u4e86\u3002<\/p>\n <\/p>\n \u6b64\u5916\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u7f51\u7ad9\u7684\u6587\u4ef6\u6dfb\u52a0\u5230 webroot \u76ee\u5f55\u4e0b\uff0c\u5e76\u5220\u9664 Lighttpd \u7684\u9ed8\u8ba4\u7d22\u5f15\u6587\u4ef6\uff0c\u4f7f\u6211\u4eec\u7684\u9759\u6001\u7f51\u7ad9\u53ef\u4ee5\u5728\u4e92\u8054\u7f51\u4e0a\u8bbf\u95ee\u3002<\/p>\n \u5982\u679c\u60f3\u5728 Lighttpd Web \u670d\u52a1\u5668\u4e2d\u8fd0\u884c PHP \u5e94\u7528\uff0c\u8bf7\u53c2\u8003\u4e0b\u9762\u7684\u6b65\u9aa4\uff1a<\/p>\n \u5728 Lighttpd \u6210\u529f\u5b89\u88c5\u540e\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5 PHP \u53ca\u76f8\u5173\u6a21\u5757\uff0c\u4ee5\u5728 Lighttpd \u4e2d\u8fd0\u884c PHP5 \u811a\u672c\u3002<\/p>\n \u5982\u8981\u8ba9 PHP \u4e0e Lighttpd \u534f\u540c\u5de5\u4f5c\uff0c\u6211\u4eec\u53ea\u8981\u6839\u636e\u6240\u4f7f\u7528\u7684\u53d1\u884c\u7248\u6267\u884c\u5982\u4e0b\u5bf9\u5e94\u7684\u6307\u4ee4\u5373\u53ef\u3002<\/p>\n \u9996\u5148\u8981\u505a\u7684\u4fbf\u662f\u4f7f\u7528\u6587\u4ef6\u7f16\u8f91\u5668\u7f16\u8f91 php \u8bbe\u7f6e\u6587\u4ef6\uff08\u4f8b\u5982\/etc\/php.ini\uff09\u5e76\u53d6\u6d88\u6389\u5bf9cgi.fix_pathinfo=1\u8fd9\u4e00\u884c\u7684\u6ce8\u91ca\u3002<\/p>\n \u5b8c\u6210\u4e0a\u9762\u7684\u6b65\u9aa4\u4e4b\u540e\uff0c\u6211\u4eec\u9700\u8981\u628a PHP-FPM \u8fdb\u7a0b\u7684\u6240\u6709\u6743\u4ece Apache \u8f6c\u79fb\u81f3 Lighttpd\u3002\u8981\u5b8c\u6210\u8fd9\u4e9b\uff0c\u9996\u5148\u7528\u6587\u4ef6\u7f16\u8f91\u5668\u6253\u5f00\/etc\/php-fpm.d\/www.conf\u6587\u4ef6\u3002<\/p>\n \u7136\u540e\u5728\u6587\u4ef6\u4e2d\u589e\u52a0\u4e0b\u9762\u7684\u8bed\u53e5\uff1a<\/p>\n \u505a\u5b8c\u8fd9\u4e9b\uff0c\u6211\u4eec\u4fdd\u5b58\u5e76\u9000\u51fa\u6587\u672c\u7f16\u8f91\u5668\u3002\u7136\u540e\u4ece\/etc\/lighttpd\/modules.conf\u8bbe\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0 FastCGI \u6a21\u5757\u3002<\/p>\n \u7136\u540e\uff0c\u53bb\u6389\u4e0b\u9762\u8bed\u53e5\u524d\u9762\u7684#\u6765\u53d6\u6d88\u5bf9\u5b83\u7684\u6ce8\u91ca\u3002<\/p>\n \u6700\u540e\u6211\u4eec\u8fd8\u9700\u5728\u6587\u672c\u7f16\u8f91\u5668\u8bbe\u7f6e FastCGI \u7684\u8bbe\u7f6e\u6587\u4ef6\u3002<\/p>\n \u5728\u6587\u4ef6\u5c3e\u90e8\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n \u5728\u7f16\u8f91\u5b8c\u6210\u540e\u4fdd\u5b58\u5e76\u9000\u51fa\u6587\u672c\u7f16\u8f91\u5668\u5373\u53ef\u3002<\/p>\n \u5982\u9700\u542f\u7528 Lighttpd \u7684 FastCGI\uff0c\u53ea\u9700\u6267\u884c\u4e0b\u5217\u4ee3\u7801\uff1a<\/p>\n \u7136\u540e\uff0c\u6267\u884c\u4e0b\u5217\u547d\u4ee4\u6765\u91cd\u542f Lighttpd\u3002<\/p>\n \u5982\u9700\u68c0\u6d4b PHP \u662f\u5426\u6309\u9884\u671f\u5de5\u4f5c\uff0c\u6211\u4eec\u9700\u5728 Lighttpd \u7684 webroot \u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a php \u6587\u4ef6\u3002\u672c\u6559\u7a0b\u4e2d\uff0c\u5728 Ubuntu \u4e0b \/var\/www\/html \u76ee\u5f55\uff0cCentOS \u4e0b \/src\/www\/htdocs \u76ee\u5f55\u4e0b\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u521b\u5efa\u5e76\u6253\u5f00 info.php\u3002<\/p>\n \u7136\u540e\u53ea\u9700\u5c06\u4e0b\u9762\u7684\u8bed\u53e5\u6dfb\u52a0\u5230\u6587\u4ef6\u91cc\u5373\u53ef\u3002<\/p>\n \u5728\u7f16\u8f91\u5b8c\u6210\u540e\u4fdd\u5b58\u5e76\u63a8\u51fa\u6587\u672c\u7f16\u8f91\u5668\u5373\u53ef\u3002<\/p>\n \u73b0\u5728\uff0c\u6211\u4eec\u9700\u6839\u636e\u8def\u5f84 http:\/\/lighttpd.linoxide.com\/info.php \u4e0b\u7684 info.php \u6587\u4ef6\u7684 IP \u5730\u5740\u6216\u57df\u540d\uff0c\u6765\u8ba9\u6211\u4eec\u7684\u7f51\u9875\u6d4f\u89c8\u5668\u6307\u5411\u7cfb\u7edf\u4e0a\u8fd0\u884c\u7684 Lighttpd\u3002\u5982\u679c\u4e00\u5207\u90fd\u6309\u7167\u4ee5\u4e0a\u8bf4\u660e\u8fdb\u884c\uff0c\u6211\u4eec\u5c06\u770b\u5230\u5982\u4e0b\u56fe\u6240\u793a\u7684 PHP \u9875\u9762\u4fe1\u606f\u3002<\/p>\n <\/p>\n \u81f3\u6b64\uff0c\u6211\u4eec\u5df2\u7ecf\u5728 CentOS 7 \u548c Ubuntu 15.04 Linux \u53d1\u884c\u7248\u4e0a\u6210\u529f\u5b89\u88c5\u4e86\u8f7b\u5de7\u5feb\u6377\u5e76\u4e14\u5b89\u5168\u7684 Lighttpd Web \u670d\u52a1\u5668\u3002\u73b0\u5728\uff0c\u6211\u4eec\u5df2\u7ecf\u53ef\u4ee5\u4e0a\u4f20\u7f51\u7ad9\u6587\u4ef6\u5230\u7f51\u7ad9\u6839\u76ee\u5f55\u3001\u914d\u7f6e\u865a\u62df\u4e3b\u673a\u3001\u542f\u7528 SSL\u3001\u8fde\u63a5\u6570\u636e\u5e93\uff0c\u5728\u6211\u4eec\u7684 Lighttpd Web \u670d\u52a1\u5668\u4e0a\u8fd0\u884c Web \u5e94\u7528\u7b49\u529f\u80fd\u4e86\u3002<\/p>\n \u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn\/article-7547-1.html<\/a><\/p>\n# yum install epel-release\r\n<\/pre>\n
# yum update\r\n# yum install lighttpd\r\n<\/pre>\n
# apt-get update\r\n# apt-get install lighttpd\r\n<\/pre>\n
# cd \/tmp\/\r\n# wget http:\/\/download.lighttpd.net\/lighttpd\/releases-1.4.x\/lighttpd-1.4.39.tar.gz\r\n<\/pre>\n
# tar -zxvf lighttpd-1.4.39.tar.gz\r\n<\/pre>\n
# cd lighttpd-1.4.39\r\n# .\/configure\r\n# make\r\n<\/pre>\n
# make install\r\n<\/pre>\n
# lighttpd -t -f \/etc\/lighttpd\/lighttpd.conf\r\n<\/pre>\n
# mkdir -p \/srv\/www\/htdocs\/\r\n<\/pre>\n
# cp -r \/var\/www\/lighttpd\/* \/srv\/www\/htdocs\/\r\n<\/pre>\n
# systemctl start lighttpd\r\n<\/pre>\n
# systemctl enable lighttpd\r\n<\/pre>\n
# firewall-cmd --permanent --add-service=http\r\nsuccess\r\n# firewall-cmd --reload\r\nsuccess\r\n<\/pre>\n
# apt-get install php5 php5-cgi php5-fpm php5-mysql php5-curl php5-gd php5-intl php5-imagick php5-mcrypt php5-memcache php-pear\r\n<\/pre>\n
# yum install php php-cgi php-fpm php-mysql php-curl php-gd php-intl php-pecl-imagick php-mcrypt php-memcache php-pear lighttpd-fastcgi\r\n<\/pre>\n
# nano \/etc\/php.ini\r\n<\/pre>\n
# nano \/etc\/php-fpm.d\/www.conf\r\n<\/pre>\n
user = lighttpd\r\ngroup = lighttpd\r\n<\/pre>\n
# nano \/etc\/lighttpd\/modules.conf\r\n<\/pre>\n
include \"conf.d\/fastcgi.conf\"\r\n<\/pre>\n
# nano \/etc\/lighttpd\/conf.d\/fastcgi.conf\r\n<\/pre>\n
fastcgi.server += ( \".php\" =>\r\n((\r\n\"host\" => \"127.0.0.1\",\r\n\"port\" => \"9000\",\r\n\"broken-scriptfilename\" => \"enable\"\r\n))\r\n)\r\n<\/pre>\n
# lighttpd-enable-mod fastcgi\r\n\r\nEnabling fastcgi: ok\r\nRun \/etc\/init.d\/lighttpd force-reload to enable changes\r\n\r\n# lighttpd-enable-mod fastcgi-php\r\n\r\nEnabling fastcgi-php: ok\r\nRun `\/etc\/init.d\/lighttpd` force-reload to enable changes\r\n<\/pre>\n
# systemctl force-reload lighttpd\r\n<\/pre>\n
# nano \/var\/www\/info.php\r\n<\/pre>\n
# nano \/srv\/www\/htdocs\/info.php\r\n<\/pre>\n
<?php phpinfo(); ?>\r\n<\/pre>\n
\n