\u5b8c\u6210\u540e\uff0c\u68c0\u67e5\u60a8\u5b89\u88c5\u7684 lighttpd \u7684\u7248\u672c\u3002<\/p>\n
# lighttpd -v<\/pre>\n\u5982\u679c\u60a8\u8fd0\u884c\u7684\u662f Ubuntu 20.04\uff0c\u5b83\u5e94\u8be5\u8fd4\u56delighttpd\/1.4.55 (ssl) - a light and fast webserver\u200b. \u901a\u8fc7\u8bbf\u95ee\u60a8\u7684\u7ad9\u70b9\u6765\u786e\u4fdd\u5b89\u88c5\u6210\u529f\uff0c\u4f8b\u5982http:\/\/build.example.com. \u4f60\u5e94\u8be5\u5f97\u5230 lighttpd \u5360\u4f4d\u7b26\u9875\u9762\u3002
\n<\/p>\n
\u6dfb\u52a0lighttpd\u7528\u6237\u548c\u7ec4\uff1a<\/p>\n
\r\n# groupadd lighttpd\r\n# useradd -g lighttpd -d \/var\/www\/html -s \/sbin\/nologin lighttpd\r\n<\/pre>\n<\/p>\n
\u4f7flighttpd\u200b\u7528\u6237\u548c\u7ec4\u6210\u4e3a\/var\/www\/html\u76ee\u5f55\u7684\u6240\u6709\u8005\uff1a<\/p>\n
# chown -R lighttpd:lighttpd \/var\/www\/html\/<\/pre>\n<\/p>\n
3. \u5b89\u88c5 MariaDB \u548c PHP<\/strong><\/span><\/div>\n\u9664\u4e86 lighttp\uff0c\u5b89\u88c5 MariaDB \u548c PHP\uff1a<\/p>\n
\r\n# apt install -y php-{cli,gd,fpm,mysql,curl,json,xml} mariadb-server\r\n<\/pre>\n<\/p>\n
\u5b89\u88c5 MariaDB \u540e\uff0c\u4fdd\u62a4 MariaDB \u5b89\u88c5\u3002<\/p>\n
\r\n# mysql_secure_installation\r\n<\/pre>\n\u901a\u8fc7\u70b9\u51fb\u786e\u8ba4\u7a7a\u767d\u7684root\u5bc6\u7801ENTER<\/ol>\n\u901a\u8fc7\u8f93\u5165\u540c\u610f\u66f4\u6539\u5bc6\u7801\uff0cY\u7136\u540eENTER<\/ol>\n\u8f93\u5165\u65b0\u7684\u5b89\u5168\u5bc6\u7801\u3002<\/ol>\n\u901a\u8fc7\u8f93\u5165\u5220\u9664\u533f\u540d\u7528\u6237\uff0cY\u7136\u540eENTER<\/ol>\n\u901a\u8fc7\u8f93\u5165\u7981\u6b62 root \u767b\u5f55\uff0cY\u7136\u540e\u8f93\u5165ENTER<\/ol>\n\u901a\u8fc7\u8f93\u5165\u5220\u9664\u6d4b\u8bd5\u6570\u636e\u5e93\uff0cY\u7136\u540e\u8f93\u5165ENTER<\/ol>\nY\u901a\u8fc7\u8f93\u5165\u540e\u8ddf\u91cd\u65b0\u52a0\u8f7d\u6743\u9650\u8868ENTER<\/ol>\n\u91cd\u547d\u540d\u9ed8\u8ba4 PHP FPM \u6c60\u4ee5\u4e0e Web \u670d\u52a1\u5668\u540d\u79f0\u4fdd\u6301\u4e00\u81f4\uff1a<\/p>\n
\r\n# mv \/etc\/php\/8.1\/fpm\/pool.d\/www.conf \/etc\/php\/8.1\/fpm\/pool.d\/lighttpd.conf\r\n<\/pre>\n<\/p>\n
\u901a\u8fc7\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\u66f4\u6539\u4e0e\u6c60\u5173\u8054\u7684\u5173\u8054\u7528\u6237\u548c Unix \u5957\u63a5\u5b57\uff1a<\/p>\n
# nano \/etc\/php\/8.1\/fpm\/pool.d\/lighttpd.conf\r\n<\/pre>\n\u66f4\u6539\u56db\u884c\uff1a<\/p>\n
\u5c06\u8bbe\u7f6e\u6c60\u540d\u79f0\u7684\u62ec\u53f7\u5185\u7684\u7b2c\u4e00\u884c\u66f4\u6539[www]\u4e3a[lighttpd]<\/ol>\n\u5c06\u884c\u66f4\u6539user = www-data\u4e3auser = lighttpd<\/ol>\n\u5c06\u884c\u66f4\u6539group = www-data\u4e3agroup = lighttpd<\/ol>\n\u5c06\u884c\u66f4\u6539listen = \/run\/php\/php8.1-fpm.sock\u4e3alisten = \/run\/php\/php8.1-lighttpd-fpm.sock<\/ol>\n\u4fdd\u5b58\u6587\u4ef6\u5e76\u91cd\u542f PHP FPM \u670d\u52a1\uff1a<\/p>\n
# service php8.1-fpm restart<\/pre>\n<\/p>\n
4. \u5347\u7ea7Lighttpd<\/strong><\/span><\/div>\n\u6dfb\u52a0\u4e00\u4e9b\u4ece\u6e90\u4ee3\u7801\u6784\u5efa\u6700\u65b0\u7248\u672c\u7684 lighttpd \u6240\u9700\u7684\u5305\u3002<\/p>\n
# apt install -y gcc libpcre3 libpcre3-dev zlib1g-dev checkinstall libssl-dev<\/pre>\n\u4ece\u547d\u4ee4\u63d0\u793a\u7b26\u4e0b\u8f7d\u6700\u65b0\u7684 lighttpd \u538b\u7f29\u5305\u3002\u5728\u64b0\u5199\u672c\u6587\u65f6\uff0c\u6700\u65b0\u7248\u672c\u662f 1.4.66\u3002\u60a8\u53ef\u4ee5\u5728https:\/\/download.lighttpd.net\/lighttpd\/\u627e\u5230\u6700\u65b0\u7684\u4e0b\u8f7d\u94fe\u63a5<\/p>\n
# wget https:\/\/download.lighttpd.net\/lighttpd\/releases-1.4.x\/lighttpd-1.4.66.tar.gz<\/pre>\n\u63d0\u53d6\u538b\u7f29\u5305\u3002<\/p>\n
# tar xzf lighttpd-1.4.66.tar.gz<\/pre>\n\u5207\u6362\u5230 lighttpd \u5de5\u4f5c\u76ee\u5f55\u3002<\/p>\n
# cd lighttpd-1.4.66<\/pre>\n\u5c06\u5305\u914d\u7f6e\u4e3a\u5305\u542b SSL \u5e76\u5b89\u88c5\u5728\/usr\/sbin\u76ee\u5f55\u4e2d\u3002<\/p>\n
# .\/configure --with-openssl --sbindir=\/usr\/sbin<\/pre>\n\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u5236\u4f5c\u5305\u5e76\u5b89\u88c5\u3002<\/p>\n
\r\n# make\r\n# make install\r\n<\/pre>\n\u8fd0\u884clighttpd -v\u200b\u786e\u4fdd1.4.66\u7248\u672c\u5b89\u88c5\u6210\u529f\u3002\u8be5\u547d\u4ee4\u5e94\u8be5\u8fd4\u56delighttpd\/1.4.66 (ssl) - a light and fast webserver<\/p>\n
5. \u914d\u7f6eLighttpd<\/strong><\/span><\/div>\n\u4e0e Ubuntu 20.04 \u4e00\u8d77\u6253\u5305\u7684\u65e7 1.4.55 \u7248\u672c\u6709\u4e00\u4e2a\u5df2\u5f03\u7528\u7684mod_compress\u200b\u6a21\u5757\uff0c\u60a8\u5fc5\u987b\u5c06\u5176\u66ff\u6362\u4e3amod_deflate. \u8981\u66f4\u6539\u6a21\u5757\u52a0\u8f7d\uff0c\u8bf7\u7f16\u8f91\u9ed8\u8ba4\u914d\u7f6e\uff1a<\/p>\n
# nano \/etc\/lighttpd\/lighttpd.conf<\/pre>\n\u66f4\u6539\u4ee5\u4e0b\u4e09\u884c\uff1a<\/p>\n
\u5c06\u5305\u542b\u7684\u884c\u66f4\u6539compress.cache-dir\u4e3adeflate.cache-dir<\/ol>\n\u5220\u9664\u5305\u542b\u7684\u884ccompress.filetype<\/ol>\n\u5c06\u6a21\u5757\u914d\u7f6e\u4ece \u66f4\u6539mod_compress\u4e3amod_deflate\u5e76\u4fdd\u5b58\u6587\u4ef6\u3002<\/ol>\n\u901a\u8fc7\u8fd0\u884c\u68c0\u67e5\u914d\u7f6e\uff1a<\/p>\n
# \/usr\/sbin\/lighttpd -tt -f \/etc\/lighttpd\/lighttpd.conf<\/pre>\n6. \u4e3a Lighttpd \u914d\u7f6e PHP<\/strong><\/span><\/div>\n\u542f\u7528cgi\u548cphp\u6a21\u5757\u3002<\/p>\n
\r\n# lighttpd-enable-mod fastcgi\r\n# lighttpd-enable-mod fastcgi-php\r\n<\/pre>\n\u7f16\u8f91 PHP \u914d\u7f6e\u3002<\/p>\n
# nano \/etc\/lighttpd\/conf-enabled\/15-fastcgi-php.conf<\/pre>\n\u5220\u9664\u6574\u4e2a\u6587\u4ef6\u5185\u5bb9\u5e76\u5c06\u5176\u66ff\u6362\u4e3a\u4ee5\u4e0b\u5185\u5bb9\uff0c\u5b83php\u4e3a\u60a8\u5728\u6b65\u9aa4 3 \u4e2d\u6240\u505a\u7684 sock \u8bbe\u7f6e\u914d\u7f6e\u6a21\u5757\u3002<\/p>\n
\r\nfastcgi.server += ( \".php\" =>\r\n ((\r\n \"socket\" => \"\/run\/php\/php8.1-lighttpd-fpm.sock\",\r\n \"broken-scriptfilename\" => \"enable\"\r\n ))\r\n)\r\n<\/pre>\n\u91cd\u65b0\u542f\u52a8\u670d\u52a1\u5668\u4ee5\u8fdb\u884c\u65b0\u7684\u914d\u7f6e\u66f4\u6539\uff1a<\/p>\n
# service lighttpd restart<\/pre>\n\u6dfb\u52a0\u6d4b\u8bd5 PHP \u6587\u4ef6\u4ee5\u786e\u4fdd PHP \u6b63\u5728\u8fd0\u884c\uff1a<\/p>\n
# nano \/var\/www\/html\/pi.php<\/pre>\n\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a
\n\u8981\u68c0\u67e5\u914d\u7f6e\uff0c\u8bf7\u8bbf\u95eehttp:\/\/build.example.com\/pi.php\u200b\u5e76\u627e\u5230 PHP \u4fe1\u606f\u9875\u9762\u3002\u5728\u8be5PHP Variables\u200b\u90e8\u5206\u4e2d\uff0c\u786e\u4fdd$_SERVER['USER']\u200b\u662f lighttpd\u3002<\/p>\n
7. \u4fdd\u62a4 Lighttpd<\/strong><\/span><\/div>\n\u8981\u4fdd\u62a4 Web \u670d\u52a1\u5668\uff0c\u8bf7\u6dfb\u52a0 Let\u2019s Encrypt TLS \u8bc1\u4e66\u5e76\u542f\u7528 HTTPS \u534f\u8bae\u3002
\n\u5b89\u88c5\u8ba9\u6211\u4eec\u52a0\u5bc6\u3002<\/p>\n
# apt install -y certbot<\/pre>\n\u7533\u8bf7\u8bc1\u4e66\u3002\u786e\u4fdd\u66f4\u6539build.example.com\u4e3a\u60a8\u7684\u670d\u52a1\u5668\u7684\u57df\u540d\u3002<\/p>\n
# certbot certonly --webroot -w \/var\/www\/html\/ -d build.example.com<\/pre>\n\u8be5\u5411\u5bfc\u4f1a\u8be2\u95ee\u60a8\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3001\u540c\u610f\u670d\u52a1\u6761\u6b3e\u4ee5\u53ca\u60a8\u662f\u5426\u60f3\u6210\u4e3a\u7535\u5b50\u524d\u6cbf\u57fa\u91d1\u4f1a\u7684\u4e00\u5458\u3002<\/p>\n
\u542f\u7528 Lighttpdssl\u6a21\u5757\u3002<\/p>\n
# lighttpd-enable-mod ssl<\/pre>\n\u7f16\u8f91 Lighttpd SSL \u914d\u7f6e\uff1a<\/p>\n
# nano \/etc\/lighttpd\/conf-enabled\/10-ssl.conf<\/pre>\n\u5c06\u6574\u4e2a$SERVER[\"socket\"]\u200b\u90e8\u5206\u66ff\u6362\u4e3a\u4ee5\u4e0b\u5185\u5bb9\u3002\u5728\u56db\u4e2a\u5730\u65b9\u66f4\u6539build.example.com\u60a8\u7684\u670d\u52a1\u5668\u7684\u57df\u540d\u3002<\/p>\n
$HTTP[\"scheme\"] == \"http\" {\r\n $HTTP[\"host\"] == \"build.example.com\" {\r\n url.redirect = (\"\/.*\" => \"https:\/\/build.example.com$0\")\r\n }\r\n}\r\n\r\n$SERVER[\"socket\"] == \"0.0.0.0:443\" {\r\n ssl.engine = \"enable\"\r\n ssl.pemfile = \"\/etc\/letsencrypt\/live\/build.example.com\/fullchain.pem\"\r\n ssl.privkey = \"\/etc\/letsencrypt\/live\/build.example.com\/privkey.pem\"\r\n ssl.cipher-list = \"HIGH\"\r\n}\r\n<\/pre>\n\u4fdd\u5b58\u6587\u4ef6\uff0c\u7136\u540e\u91cd\u65b0\u542f\u52a8 lighttpd\u3002<\/p>\n
# service lighttpd restart<\/pre>\n\u8bbf\u95eehttp:\/\/build.example.com\u200b\u4ee5\u786e\u4fdd\u5b83\u73b0\u5728\u91cd\u5b9a\u5411\u5230https:\/\/build.example.com\u5e76\u4f7f\u7528 SSL \u8bc1\u4e66\u3002<\/p>\n
8. \u66f4\u65b0\u670d\u52a1\u5668<\/strong><\/span><\/div>\n\u786e\u4fdd\u914d\u7f6e\u6b63\u786e\u540e\uff0c\u4f7f\u7528\u6700\u65b0\u8865\u4e01\u66f4\u65b0 Ubuntu \u670d\u52a1\u5668\u3002<\/p>\n
# apt update -y && apt dist-upgrade -y && apt autoremove -y<\/pre>\n\u91cd\u65b0\u542f\u52a8\u670d\u52a1\u5668\u4ee5\u5e94\u7528\u66f4\u65b0\u3002<\/p>\n
# reboot now<\/pre>\n9. \u66f4\u591a\u8bbe\u7f6e<\/strong><\/span><\/div>\n\u9664\u4e86\u521b\u5efa\u4e00\u4e2a\u72ec\u7279\u7684 PHP FPM \u6c60\u5916\uff0c\u8fd8\u53ef\u4ee5\u66f4\u6539\u8bbe\u7f6e\u4ee5\u8fdb\u4e00\u6b65\u4f18\u5316\u6027\u80fd\u548c\u901f\u5ea6\u3002\u8fd9\u4e9b\u8bbe\u7f6e\u5728\/etc\/php\/8.1\/fpm\/pool.d\u200b\u914d\u7f6e\u6587\u4ef6\u4e2d\u3002\u7ecf\u5e38\u66f4\u6539\u7684\u4e3b\u8981\u8bbe\u7f6e\u662fpm\u200b\u8bbe\u7f6e\uff0c\u5b83\u63a7\u5236\u5982\u4f55\u521b\u5efa\u6d41\u7a0b\uff0c\u53ef\u4ee5\u662fdynamic\u3001static\u6216ondemand\u3002\u66f4\u6539\u6b64\u8bbe\u7f6e\u4e5f\u4f1a\u5f71\u54cd\u6587\u4ef6\u4e2d\u7684\u5176\u4ed6\u8bbe\u7f6e\u3002\u4e0e\u4efb\u4f55\u5e94\u7528\u7a0b\u5e8f\u4e00\u6837\uff0c\u6b63\u786e\u7684\u670d\u52a1\u5668\u8bbe\u7f6e\u53d6\u51b3\u4e8e\u9884\u671f\u7528\u9014\u3001\u8d1f\u8f7d\u548c\u914d\u7f6e\u3002<\/p>\n
\u7ed3\u8bba<\/strong><\/div>\nLighttpd \u662f\u4e00\u4e2a\u5f3a\u5927\u800c\u7b80\u5355\u7684 Web \u670d\u52a1\u5668\uff0c\u5f53\u4e0e PHP \u548c MariaDB \u96c6\u6210\u65f6\uff0c\u5b83\u53ef\u4ee5\u4ee5\u6700\u5c0f\u7684\u5360\u7528\u7a7a\u95f4\u5904\u7406\u6570\u5343\u4e2a\u8bf7\u6c42\u3002\u4f7f\u7528 Lets Encrypt \u4fdd\u62a4\u5b83\u65e2\u7b80\u5355\u53c8\u5bb9\u6613\uff0c\u5e76\u4e3a\u60a8\u548c\u60a8\u7684\u8bbf\u95ee\u8005\u589e\u52a0\u4e86\u53e6\u4e00\u5c42\u4fdd\u62a4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
Lighttpd\uff0c\u4e5f\u79f0\u4e3a Lighty\uff0c\u662f\u4e00\u4e2a\u5360\u7528\u7a7a\u95f4\u5c0f\u7684\u5f00\u6e90 Web \u670d\u52a1\u5668\uff0c\u5f53\u4e0e PHP \u548c MySQL […]<\/p>\n","protected":false},"author":1329,"featured_media":251889,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-251682","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/251682","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1329"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=251682"}],"version-history":[{"count":13,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/251682\/revisions"}],"predecessor-version":[{"id":252165,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/251682\/revisions\/252165"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/251889"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=251682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=251682"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=251682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}