欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

lighttpd+mysql+php

程序员文章站 2022-05-07 08:22:20
...
博客已经搬家,请访问如下地址:http://www.czhphp.com

一:安装mysql

下载:wget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.1.33.zip

安装:

unzip mysql-5.1.33.zip

cd mysql-5.1.33.zip

./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase
make
make install
useradd mysql -d /data/mysql -s/sbin/nologin
/usr/local/mysql/bin/mysql_install_db--user=mysql
cd /usr/local/mysql
chown -R root:mysql .
mkdir -p /data/mysql/data
chown -R mysql /data/mysql/data
cp share/mysql/my-huge.cnf /etc/my.cnf
cp share/mysql/mysql.server/etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysql

service mysqld start

当重新启动时候总 报以下错误:

ERROR! MySQL manager or server PID file could not be found!

Starting MySQL. ERROR! Manager of pid-file quit without updating file.

解决办法:

MySQL编译安装,初始化数据库的时候出现:
unknown option '--skip-federated' 错误。

#vi /etc/my.cnf
#skip-federated 将此行注释掉即可。或者编译的时候加上如下参数:--with-plugins=all

如果还是不行的话那么就是因为您在配置的时候没有添加datadir,

#vi /etc/my.cnf

添加以下语句:

[mysqld]
port = 3306
socket = /tmp/mysql.sock
datadir = /usr/local/mysql/data
datadir是新加的

二、接着安装php

tar zxf php-5.2.4.tar.gz

cd php-5.2.4

./configure --prefix=/usr/local/php-fcgi --enable-fastcgi --enable-force-cgi-redirect --without-iconv --enable-mbstring --with-mysql=/usr/local/mysql

注意:php安装的过程中也许会报以下错误

collect2: ld returned 1 exit status
make: *** [sapi/cgi/php-cgi] Error 1

解决办法:

请安装lib所需的安装包

yum install ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel pam-devel kernel

执行安装完以后即可解决问题

make

make install


复制参数文件到目标目录:

cp php.ini-dist /usr/local/php-fcgi/lib/php.ini

检查fast-cgi是否安装成功可以运行如下命令

/usr/local/php-fcgi/bin/php-cgi -v

显示如下信息,内容里包含“PHP 5.2.4 (cgi-fcgi)"表示支持fast-cgi了

PHP 5.2.4 (cgi-fcgi) (built: Oct 28 2007 20:08:41)

Copyright (c) 1997-2007 The PHP Group

Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

早就听说lighttpd加PHP的FAST-CGI方式性能不错,抽时间装了下.只是完成了环境的安装,还没具体看性能什么的!

以下是我装lighttpd+PHP(FAST-CGI)+mysql的,如有问题,请给我评论.

三、最后安装lighttpd

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

# mkdir /usr/local/lighttpd/htdocs

# mv ./doc/lighttpd.conf /usr/local/lighttpd/conf/

# cp ./doc/rc.lighttpd.redhat /etc/init.d/lighttpd

vi conf/lighttpd.conf

将 #”mod_fastcgi”, 的#去掉

server.modules = (
"mod_rewrite",
"mod_redirect",
"mod_alias",
"mod_access",
"mod_cml",
"mod_trigger_b4_dl",
"mod_auth",
"mod_status",
"mod_setenv",
"mod_fastcgi",
# "mod_proxy",
# "mod_simple_vhost",
"mod_evhost",
# "mod_userdir",
# "mod_cgi",
# "mod_compress",
# "mod_ssi",
# "mod_usertrack",
# "mod_expire",
# "mod_secdownload",
# "mod_rrdtool",
"mod_accesslog" )

## a static document-root, for virtual-hosting take look at the
## server.virtual-* options
server.document-root = "/usr/local/lighttpd/htdocs/"

## where to send error-messages to
server.errorlog = "/usr/local/lighttpd/log/lighttpd/error.log"

找到fastcgi的定义

#### fastcgi module

## read fastcgi.txt for more info

## for PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini

fastcgi.server = ( ".php" =>

( "localhost" =>

( "socket" => "/var/run/lighttpd/php-fastcgi.socket",

"bin-path" => "/usr/local/php-fcgi/bin/php-cgi" )

)

)

/var/run/lighttpd 该目录需要创建如果没有的话
一开始我把配置写"bin-path" => "/usr/local/php-fcgi/bin/php"这样,发现报错,后来改了下以上的配置,发现OK了!

启动lighttpd命令是这样的:

chown -R lighttpd:lighttpd /usr/local/lighttpd

service lighttpd restart

PHP FastCGI环境测试 --

echo "" > /usr/local/lighttpd/htdocs/index.php

curl http://127.0.0.1/index.php

大概的安装过程如上,有什么问题请大家多多指教,欢迎大家留下宝贵意见,谢谢。

博客已经搬家,请访问如下地址:http://www.czhphp.com

相关标签: lighttpd+mysql+php