lighttpd + php 移植配置

本文介绍如何在Buildroot环境下配置lighttpd Web服务器及PHP支持,包括安装必要的软件包、设置配置文件等步骤,适用于嵌入式系统的开发。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • buildroot 内添加 lighttpd 和php 等相关选项

    // make menuconfig
    Target packages  --->
        Interpreter languages and scripting  --->
            [*] perl
            [*] php
            [*]   CGI interface
            [*]   FPM interface
                Extensions  --->
                    [*] Readline
                    [*] Session
                    [*] zlib
                    [*] JSON
                    [*] FTP
                    [*] sockets
                    [*] Posix
                    [*] libxml

    Networking applications  --->
        [*] lighttpd
        [*]   openssl support
        [*]   zlib support
        [*]   bzip2 support
        [*]   pcre support
        [*]   webdav support        
  • 进入生成的文件系统配置 lighttpd + php

    //  vim etc/lighttpd/lighttpd.conf
    var.log_root    = "/usr/share/lighttpd/log"            // log 日志存放点
    var.server_root = "/usr/share/lighttpd/www"
    var.state_dir   = "/usr/share/lighttpd/run"
    var.home_dir    = "/usr/share/lighttpd/lib/lighttpd"
    var.conf_dir    = "/etc/lighttpd"

    var.cache_dir   = "/usr/share/lighttpd/cache/lighttpd"

    var.socket_dir  = home_dir + "/sockets"       // /usr/share/lighttpd/lib/lighttpd/sockets

    server.use-ipv6 = "disable"
    
    server.document-root = server_root + "/webpages"

    server.event-handler = "linux-sysepoll"
    
    server.network-backend = "writev"
    
    server.upload-dirs = ( "/usr/share/lighttpd/upload" )
    //  vim etc/lighttpd/modules.conf
    server.modules = ( 
   "mod_access",
   "mod_alias",
    #  "mod_auth",
    #  "mod_authn_file",
    #  "mod_evasive",
    #  "mod_redirect",
    #  "mod_rewrite",
    #  "mod_setenv",
    #  "mod_usertrack",
    #  "mod_compress",
    )

    include "conf.d/compress.conf"
    
    include "conf.d/fastcgi.conf"
    // vim etc/lighttpd/conf.d/fastcgi.conf
    server.modules += ( "mod_fastcgi" )

    ##
    ## PHP Example
    ## For PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini.
    ##
    ## The number of php processes you will get can be easily calculated:
    ##
    ## num-procs = max-procs * ( 1 + PHP_FCGI_CHILDREN )
    ##
    ## for the php-num-procs example it means you will get 17*5 = 85 php
    ## processes. you always should need this high number for your very
    ## busy sites. And if you have a lot of RAM. :)
    ##
    fastcgi.server = ( 
                ".php" =>
                    ( "php-local" =>
                       (   
                    "socket" => socket_dir + "/php-fastcgi-1.socket",
                            "bin-path" => "/usr/bin/php-cgi",
                            "max-procs" => 1,
                    "broken-scriptfilename" => "enable",
                       )   
                    )   
                ) 
    // vim etc/lighttpd/conf.d/compress.conf 
    server.modules += ( "mod_compress" )

    ##
    ## where should the compressed files be cached?
    ## see the base config for the declaration of the variable.
    ##
    ## This directory should be changed per vhost otherwise you can
    ## run into trouble with overlapping filenames
    ##
    compress.cache-dir         = cache_dir + "/compress"

    ##
    ## FileTypes to compress.
    ## 
    compress.filetype          = ("text/plain", "text/html")
    // vim etc/php.ini
    cgi.fix_pathinfo=1
  • 创建相关目录

    mkdir -p /usr/share/lighttpd
    cd /usr/share/lighttpd
    mkdir  cache   lib     log     run     upload  www
    mkdir  -p  cache/lighttpd/
    mkdir  -p  lib/lighttpd/sockets/
    mkdir  -p  www/webpages
    touch  www/webpages/index.php
  • 给 usr/share/lighttpd/www/webpages/index.php 添加内容

   //    vim usr/share/lighttpd/www/webpages/index.php
   <?php
            echo phpinfo();
    ?>  
OpenWrt是一个嵌入式设备的Linux操作系统,而Lighttpd是一款轻量级的Web服务器。在OpenWrt中安装和配置Lighttpd可以按照以下步骤进行操作。 第一步,使用以下命令安装Lighttpd和相关模块: opkg update opkg install lighttpd lighttpd-mod-cgi 第二步,设置默认端口和目录以及添加额外的端口和目录: 在配置文件/etc/config/uhttpd中进行编辑。默认的端口设置为80,对应的目录为/srv/php。如果需要添加额外的端口和目录,可以在配置文件中进行相应的修改。例如,将默认端口修改为88,对应的目录为/srv/www 。 第三步,重启uhttpd和Lighttpd服务: 使用以下命令重启uhttpd和Lighttpd服务,以使修改生效: /etc/init.d/uhttpd restart /etc/init.d/lighttpd restart 通过上述步骤,您可以在OpenWrt中成功安装和配置Lighttpd。如果您需要更详细的移植高版本的Lighttpd到MTK7628N OpenWrt的过程和遇到的问题,可以参考以下博客文章:https://blog.youkuaiyun.com/caofengtao1314/article/details/83140841 。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [openwrt里安装php配置lightted多端口监听](https://blog.youkuaiyun.com/king_jie0210/article/details/78928696)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [mtk7628n_openwrt_lighttpd](https://download.youkuaiyun.com/download/caofengtao1314/10728875)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值