搭建一个轻量级服务器环境 LIGHTTPD + MYSQL + PHP(FAST-CGI)
来源:互联网 发布:宣传展板设计软件 编辑:程序博客网 时间:2024/04/30 05:56
Lighttp是一个新兴的安全,高效,兼容性都非常好的WEB服务器软件。相对APACHE来说lighttpd的显著特点是:非常低的内存占用,非常快的相应速度。今天我在LINUX上配置了一下感觉的确不错,在这里和大家分享一下。安装lighttpd前需要预装下列软件包:
pcre
zlib
pcre-devel
zlib-devel
1.安装配置lighttpd
1.1 首先创建运行lighttpd的用户和组
# groupadd lighttpd
# useradd -g lighttpd -s /sbin/nologin -d /dev/null lighttpd
1.2 开始安装lighttpd
# wget http://www.lighttpd.net/download/lighttpd-1.4.8.tar.gz
# tar -zxvf lighttpd-1.4.8.tar.gz
# cd lighttpd-1.4.8
# ./configure --prefix=/usr/local/lighttpd
# make
# make install
# mkdir /usr/local/lighttpd/conf
# mkdir /usr/local/lighttpd/log
# mv ./doc/lighttpd.conf /usr/local/lighttpd/conf/
# cp ./doc/rc.lighttpd.redhat /etc/init.d/lighttpd
1.3 配置lighttpd
# vi /usr/local/lighttpd/conf/lighttpd.conf
================+===============+================
server.modules = (
"mod_rewrite",
"mod_redirect",
"mod_access",
"mod_fastcgi",
"mod_compress",
"mod_accesslog" )
#$HTTP["url"] =~ "/.pdf$" {
#server.range-requests = "disable"
#}
server.document-root = "/usr/local/lighttpd/html"
server.errorlog = "/usr/local/lighttpd/log/lighttpd.error.log"
accesslog.filename = "/usr/local/lighttpd/log/access.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "lighttpd"
server.groupname = "lighttpd"
compress.cache-dir = "/tmp"
compress.filetype = ("text/plain", "text/html")
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fastcgi.socket",
"bin-path" => "/usr/local/php-fcgi/bin/php"
)
)
)
================+===============+================
# cp ./doc/spawn-php.sh /usr/local/lighttpd/bin/
# chown -R lighttpd:lighttpd /usr/local/lighttpd
2.安装配置MYSQL服务器
# yum install mysql-server
# yum install mysql
# service mysqld start
3. 安装配置PHP(FAST-CGI)
3.1 下载安装PHP
# cd ..
# wget http://mirrors.easynews.com/php/php-4.3.10.tar.gz
# tar -zxvf php-4.3.10.tar.gz
# cd php-4.3.10
# ./configure /
--prefix=/usr/local/php-fcgi /
--enable-fastcgi --with-mysql /
--enable-zend-multibyte /
--with-config-file-path=/etc /
--enable-discard-path /
--enable-force-cgi-redirect
# make
# make install
# cp php.ini-dist /etc/php.ini
4. 安装配置EAccelerator(PHP加速器)
4.1 下载安装EAccelerator
# cd ..
# wget http://kent.dl.sourceforge.net/sourceforge/eaccelerator/ /
eaccelerator-0.9.4-rc1.tar.bz2
# bunzip2 -d eaccelerator-0.9.4-rc1.tar.bz2
# tar -xvf eaccelerator-0.9.4-rc1.tar
# cd eaccelerator-0.9.4-rc1
# export PHP_PREFIX="/usr/local/php-fcgi"
# $PHP_PREFIX/bin/phpize
# ./configure /
--enable-eaccelerator=shared /
--with-php-config=$PHP_PREFIX/bin/php-config
# make
# make install
# cat eaccelerator.ini >> /etc/php.ini
4.2 配置PHP变量
# vi /etc/php.ini
================+===============+================
cgi.fix_pathinfo = 1
extension_dir = "/usr/local/php-fcgi/lib/php/extensions//
no-debug-non-zts-20020429/"
zlib.output_compression = On
cgi.fix_pathinfo=1
eaccelerator.cache_dir="/tmp"
////下面的是关于eaccelerator的配置////
zend_extension="/usr/local/php-fcgi/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator.so"
eaccelerator.shm_size = "0"
eaccelerator.cache_dir = "/tmp"
eaccelerator.enable = "1"
eaccelerator.optimizer = "1"
eaccelerator.debug = 0
eaccelerator.log_file = "/var/log/eaccelerator_log"
eaccelerator.name_space = ""
eaccelerator.check_mtime = "1"
eaccelerator.filter = ""
eaccelerator.shm_max = "0"
eaccelerator.shm_ttl = "0"
eaccelerator.shm_prune_period = "0"
eaccelerator.shm_only = "0"
eaccelerator.compress = "1"
eaccelerator.compress_level = "9"
eaccelerator.keys = "shm_and_disk"
eaccelerator.sessions = "shm_and_disk"
eaccelerator.content = "shm_and_disk"
eaccelerator.admin.name="yourusername"
eaccelerator.admin.password="yourpassword"
================+===============+================
4.3 初始化PHP with FastCGI
# vi /usr/local/lighttpd/bin/spawn-php.sh
================+===============+================
SPAWNFCGI="/usr/local/lighttpd/bin/spawn-fcgi"
FCGIPROGRAM="/usr/local/php-fcgi/bin/php"
USERID=lighttpd
GROUPID=lighttpd
================+===============+================
# /usr/local/lighttpd/bin/spawn-php.sh
5. 测试
把/etc/init.d/lighttpd文件中不符的路径更改一下
# chmod 755 /etc/init.d/lighttpd
# chown root:root /etc/init.d/lighttpd
# chkconfig --add lighttpd
# chkconfig lighttpd on
# service lighttpd start
# ps afx | grep php
12222 pts/2 S 0:00 /_ grep php
12193 ? S 0:00 /usr/local/php-fcgi/bin/php
12194 ? S 0:00 /_ /usr/local/php-fcgi/bin/php
12195 ? S 0:00 /_ /usr/local/php-fcgi/bin/php
12196 ? S 0:00 /_ /usr/local/php-fcgi/bin/php
12197 ? S 0:00 /_ /usr/local/php-fcgi/bin/php
12198 ? S 0:00 /_ /usr/local/php-fcgi/bin/php
12199 ? S 0:00 /_ /usr/local/php-fcgi/bin/php
12200 ? S 0:00 /_ /usr/local/php-fcgi/bin/php
12201 ? S 0:00 /_ /usr/local/php-fcgi/bin/php
12202 ? S 0:00 /_ /usr/local/php-fcgi/bin/php
12203 ? S 0:00 /_ /usr/local/php-fcgi/bin/php
最后在server.document-root目录中放一个test.php,用浏览器看看结果。
该文章转载自宋氏电脑 技术无忧:http://www.pc51.net/server/web/apache/2007-02-25/7081.html
- 搭建一个轻量级服务器环境 LIGHTTPD + MYSQL + PHP(FAST-CGI)
- 搭建一个轻量级服务器环境 LIGHTTPD + php
- lighttpd+PHP(FAST-CGI)+mysql的学习笔记(转)
- Centos6.3 编译源码搭建 PHP(fast-cgi)+Nginx+Mysql+Memcached+Redis高性能服务器
- Ubuntu下搭建Lighttpd+PHP+MySQL环境
- centos 下搭建lighttpd php mysql环境
- linux,lighttpd,php,mysql环境搭建
- centos5下搭建NGINX+PHP(fast cgi)+MySql+PHPMyAdmin
- 在openwrt 下配置lighttpd,并使用PHP fast-cgi
- 在debian4上搭建一个lighttpd+fastcgi+php5+mysql环境
- lighttpd 服务器搭建过程记录2【with CGI】
- 手把手教你在centos下编译安装配置高性能web服务器环境nginx+php(fast-cgi)+mysql等/适合小内存vps使用
- 手把手教你在centos下编译安装配置高性能web服务器环境nginx+php(fast-cgi)+mysql等/适合小内存vps使用
- 手把手教你在centos下编译安装配置高性能web服务器环境nginx+php(fast-cgi)+mysql等/适合小内存vps使用
- cgi、fast-cgi、php-fpm
- CGI FAST-CGI PHP-FPM
- 【linux + lighttpd + php + zeromq】之环境搭建
- php fast cgi+nginx
- 用php生成wappush文件
- 程序员应该具备
- 如何增强软件研发队伍的凝聚力
- 为什么C++(感谢waterwalk翻译)
- 在运行时通过鼠标拖动移动控件位置(c#)
- 搭建一个轻量级服务器环境 LIGHTTPD + MYSQL + PHP(FAST-CGI)
- 多线程、Socket技术及委托技术的关系
- 自动播控系统软件的性能要求
- 实现调用外部EXE程序的代码
- 迁移Exchange Server 2003
- 通过短信网关发送Wappush消息
- 查询前几条记录在不同数据库中的用法
- 巴比伦富翁
- 注意、提示、错误通用对话框函数