centos 下搭建lighttpd php mysql环境_MySQL
centos下搭建webserver开发环境
一、安装相关软件包
[root@web ~]# yum -y install pcre pcre-devel bzip2-devel zlib zlib-devel mysql-server php php-mysql
二、编译并安装lighttpd
[root@web ~]# tar zxf lighttpd-1.4.30.tar.gz
[root@web ~]# cd lighttpd-1.4.30
[root@web lighttpd-1.4.30]# ./configure --prefix=/usr/local/lighttpd --with-openssl --with-openssl-libs=/usr/lib
[root@web lighttpd-1.4.30]# make && make install
配置启动及配置文件目录
[root@web lighttpd-1.4.30]# cp doc/initscripts/rc.lighttpd.redhat /etc/init.d/lighttpd
[root@web lighttpd-1.4.30]# chmod +x /etc/init.d/lighttpd
[root@web lighttpd-1.4.30]# cp -p doc/initscripts/sysconfig.lighttpd /etc/sysconfig/lighttpd
[root@web lighttpd-1.4.30]# mkdir -p /etc/lighttpd
[root@web lighttpd-1.4.30]# cp -rf doc/config/* /etc/lighttpd/
[root@web lighttpd-1.4.30]# chkconfig --add lighttpd
[root@web lighttpd-1.4.30]# chkconfig lighttpd on
[root@web ~]# vim +29 /etc/init.d/lighttpd
lighttpd="/usr/sbin/lighttpd"
修改成:
lighttpd="/usr/local/lighttpd/sbin/lighttpd"
[root@web ~]# mkdir -p /srv/www/htdocs
[root@web ~]# mkdir /var/log/lighttpd
[root@web ~]# touch /var/log/lighttpd/access.log
[root@web ~]# touch /var/log/lighttpd/error.log
[root@web ~]# useradd -s /sbin/nologin lighttpd
[root@web ~]# chown -R lighttpd:lighttpd /var/log/lighttpd/
关闭ipv6的支持
[root@web ~]# vim +93 /etc/lighttpd/lighttpd.conf
server.use-ipv6 = "enable"
修改成:
server.use-ipv6 = "disable"
将压缩缓存目录修改到/tmp下
vim /etc/lighttpd/lighttpd.conf
var.cache_dir = "/tmp/cache/lighttpd"
启动服务,查看端口监听
[root@web ~]# /etc/init.d/lighttpd start
Starting lighttpd: [ OK ]
[root@web ~]# netstat -tnlp | grep lighttpd
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 10601/lighttpd
三、配置fastcgi支持php
配置lighttpd modules(/etc/lighttpd/modules.conf)取消需要用到模块的注释:mod_rewrite,mod_redirect,mod_access,mod_fastcgi,mod_compress,mod_accesslog
修改后:
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(注意:socket和bin-path需要修改)
fastcgi.server = ( “.php” =>
( “php-local” =>
(
“socket” => “/tmp/php-fastcgi-1.socket“,
“bin-path” => “/usr/bin/php-cgi“,
“max-procs” => 1,
“broken-scriptfilename” => “enable”,
)
),
( “php-tcp” =>
(
“host” => “127.0.0.1″,
“port” => 9999,
“check-local” => “disable”,
“broken-scriptfilename” => “enable”,
)
),
( “php-num-procs” =>
(
“socket” => “/tmp/php-fastcgi-2.socket“,
“bin-path” => “/usr/bin/php-cgi“,
“bin-environment” => (
“PHP_FCGI_CHILDREN” => “16″,
“PHP_FCGI_MAX_REQUESTS” => “10000″,
),
“max-procs” => 5,
“broken-scriptfilename” => “enable”,
)
),
)
测试,在/srv/www/htdocs下建立以下测试文件:
[root@web ~]# cat /srv/www/htdocs/test.php
phpinfo();
?>
上一篇: 从Oracle的约束到索引
推荐阅读
-
mac下Apache + MySql + PHP搭建网站开发环境
-
Linux centos7环境下MySQL安装教程
-
CentOS 7.x编译安装Nginx1.10.3+MySQL5.7.16+PHP5.2 5.3 5.4 5.5 5.6 7.0 7.1多版本全能环境
-
简单介绍win7下搭建apache+php+mysql开发环境
-
Gentoo 下安装与配置Nginx+ MySQL + PHP (fastcgi) 环境步骤分享
-
Mac环境下php操作mysql数据库的方法分享
-
详解Lamp环境搭建Linux CentOS6.5编译安装mysql5.6
-
Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17详细配置
-
Win2012 R2 IIS8.5+PHP(FastCGI)+MySQL运行环境搭建教程
-
nginx+apache+mysql+php+memcached+squid搭建集群web环境