• 如来神掌第一式第二十五招----lighttpd详解


    ###############################################################################
    # Name : Mahavairocana                                                                                                                                           
    # Author : Mahavairocana                                                                                                                                         
    # QQ : 10353512                                                                                                                                                    
    # WeChat : shenlan-qianlan                                                                                                                                      
    # Blog : http://www.cnblogs.com/Mahavairocana/                                                                                                       
    # Description : You are welcome to reprint, or hyperlinks to indicate the                                                                        
    #                    source of the article, as well as author information.                                                                                ###############################################################################

    第一步 下载编译
    
    1. 去官方网站下载 http://www.lighttpd.net/download
    
    [root@s ~]# yum install pcre
    
    [root@s ~]# yum install pcre-devel
    
    [root@s local]# wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.30.tar.gz
    
    [root@s local]# tar xvf lighttpd-1.4.30.tar.gz
    
    [root@s local]# cd lighttpd-1.4.30
    
    [root@s lighttpd-1.4.30]# ./configure --prefix=/usr/local/lighttpd
    
    [root@s lighttpd-1.4.30]# make
    
    [root@s lighttpd-1.4.30]# make install
    
     
    
    第二步 配置lighttpd
    
    1. 拷贝配置文件
    
    [root@s lighttpd-1.4.30]# mkdir /etc/lighttpd
    
    [root@s lighttpd-1.4.30]# cp doc/config/lighttpd.conf /etc/lighttpd/
    
    [root@s lighttpd-1.4.30]# cp doc/config/modules.conf /etc/lighttpd/
    
    [root@s lighttpd-1.4.30]# cp doc/config/conf.d/ /etc/lighttpd/ -r
    
    [root@s lighttpd-1.4.30]# cp doc/initscripts/sysconfig.lighttpd /etc/sysconfig/lighttpd
    
    [root@s lighttpd-1.4.30]# cp doc/initscripts/rc.lighttpd.redhat /etc/init.d/lighttpd
    
    2. 修改配置文件
    
    [root@s lighttpd-1.4.30]# vi /etc/lighttpd/lighttpd.conf
    
    注释下面3行
    
    #server.username = "lighttpd"
    #server.groupname = "lighttpd"
    
    #server.use-ipv6 = "enable"
    
    最重要就是加载 PHP, 如果不知道 php-cgi 请用 whereis php-cgi 确定目录
    
    server.modules += ( "mod_fastcgi" )
    fastcgi.server = ( ".php" =>
      (( "socket" => "/tmp/php-fastcgi.socket",
        "bin-path" => "/usr/bin/php-cgi",
         "min-procs" => 1,
         "max-procs" => 1,
         "max-load-per-proc" => 4,
         "bin-environment" => (
         "PHP_FCGI_CHILDREN" => "2",
            "PHP_FCGI_MAX_REQUESTS" => "10000" ),
          "bin-copy-environment" => (
            "PATH", "SHELL", "USER" ),
          "broken-scriptfilename" => "enable",
         "idle-timeout" => 20
      ))
    )
    
    [root@s lighttpd-1.4.30]# vi /etc/init.d/lighttpd
    
    将 lighttpd="/usr/sbin/lighttpd" 改为
    
    lighttpd="/usr/local/lighttpd/sbin/lighttpd"
    
     
    
    3. 新建几个需要的文件
    
    [root@s lighttpd-1.4.30]# mkdir -p /var/log/lighttpd
    
    [root@s lighttpd-1.4.30]# touch /var/log/lighttpd/error.log
    
    [root@s lighttpd-1.4.30]# mkdir -p /srv/www/htdocs
    
     
    
    第三步 启动 lighttpd 服务器
    
    [root@s lighttpd-1.4.30]# service lighttpd start
    
    默认是 80 端口,我这里使用的域名是  http://www.google.com  打开就可以看到粗体的 404 - Not Found 表示成功
    
    当添加了 index.php 内容为:
    
    <?php
    phpinfo()
    ?>
    
    后,就可以看到是否支持 php 了
    
    用 [root@s htdocs]# curl -I http://www.google.com
    HTTP/1.1 200 OK
    X-Powered-By: PHP/5.3.3
    Content-type: text/html
    Date: Thu, 19 Jan 2012 03:01:09 GMT
    Server: lighttpd/1.4.30
    
    可以看到确实是 lighttpd 还有 PHP的版本
  • 相关阅读:
    CF1091E
    jzoj5703
    CF1109F
    杂题
    CF1194F
    杂题
    个人作业1-数组(二维数组)
    第三周-学习进度条
    构建之法阅读笔记02
    个人作业1-数组(续1)
  • 原文地址:https://www.cnblogs.com/Mahavairocana/p/8290240.html
Copyright © 2020-2023  润新知