练习记录

 
通过yum安装所需的软件包其中包括mysql-server php php-mysql
 
[root@localhost ~]# yum -y install gcc gcc-c++ bzip2-devel zlib zlib-devel mysql-server php php-mysql
 
安装pcre:
[root@localhost ~]# tar -zxvf pcre-8.21.tar.gz
[root@localhost ~]# cd pcre-8.21
[root@localhost pcre-8.21]# ./configure
[root@localhost pcre-8.21]# make && make install
 
安装lighttpd:
[root@localhost ~]# tar zxvf lighttpd-1.4.30.tar.gz
[root@localhost ~]# cd lighttpd-1.4.30
[root@localhost lighttpd-1.4.30]# ./configure --prefix=/usr/local/lighttpd
[root@localhost lighttpd-1.4.30]# make && make install
 
配置lighttpd:
[root@localhost lighttpd-1.4.30]# cp doc/initscripts/rc.lighttpd.redhat /etc/init.d/lighttpd
[root@localhost lighttpd-1.4.30]# chmod a+rx /etc/init.d/lighttpd
[root@localhost lighttpd-1.4.30]# cp -p doc/initscripts/sysconfig.lighttpd /etc/sysconfig/lighttpd
[root@localhost lighttpd-1.4.30]# mkdir -p /etc/lighttpd
[root@localhost lighttpd-1.4.30]# cp -rf doc/config/* /etc/lighttpd/
[root@localhost lighttpd-1.4.30]# chkconfig --add lighttpd
[root@localhost lighttpd-1.4.30]# chkconfig lighttpd on
 
 
[root@localhost ~]# vim +29 /etc/init.d/lighttpd
lighttpd="/usr/sbin/lighttpd"
修改成:
lighttpd="/usr/local/lighttpd/sbin/lighttpd"
 
[root@localhost ~]# mkdir -p /srv/www/htdocs
[root@localhost ~]# mkdir /var/log/lighttpd
[root@localhost ~]# touch /var/log/lighttpdaccess.log
[root@localhost ~]# touch /var/log/lighttpd/error.log
[root@localhost ~]# useradd -s /sbin/nologin lighttpd
[root@localhost ~]# chown -R lighttpd:lighttpd /var/log/lighttpd
 
[root@localhost ~]# vim +93 /etc/lighttpd/lighttpd.conf
server.use-ipv6 = "enable"
修改成:
server.use-ipv6 = "disable"
将压缩缓存目录修改到/tmp下
vim /etc/lighttpd/lighttpd.conf +63
var.cache_dir    = "/tmp/cache/lighttpd"
 
 
配置lighttpd modules(/etc/lighttpd/modules.conf)取消需要用到模块的注释:mod_rewrite,mod_redirect,mod_access,mod_fastcgi,mod_compress,mod_accesslog
 
修改后:
[root@localhost htdocs]# grep -v "#" /etc/lighttpd/modules.conf | grep -v "^$"
server.modules = (
 "mod_access",
 "mod_redirect",
 "mod_rewrite",
)
include "conf.d/compress.conf"
include "conf.d/fastcgi.conf"
 
配置/etc/lighttpd/conf.d/fastcgi.conf支持PHP
fastcgi.server =(".php"=>
        ("localhost"=>
        (
         "socket"=>"/tmp/php-fastcgi.socket",
        "bin-path"=>"/usr/bin/php-cgi",
        "max-procs"=>2,
        "bin-environment"=>
        (
        "PHP_FCGI_CHILDREN"=>"84",
        "PHP_FCGI_MAX_REQUESTS"=>"1000"
        ),
        "broken-scriptfilename"=>"enable"
        )
        )
         )
修改/etc/php.ini中522行与lighttpd.conf中server.document-root一致:
[root@localhost ~]# vim /etc/php.ini +522
doc_root =/srv/www/htdocs
 
将下载的discuz中的upload文件夹中的所有文件上传到服务器/srv/www/htdocs目录中,并将权限改成777