全面详细介绍LAMP fastcgi方式配置细节(转)

原文地址:http://www.sunboyu.cn/upfiles/v/lamp.html

文档版本:V1.0

启动时间: 2009年05月20日

目的:全面详细介绍LAMP fastcgi方式配置细节

需要软件源码:

CentOS4.7

http://centos.ustc.edu.cn/centos/4.7/isos/i386/CentOS-4.7.ServerCD-i386.iso

http://centos.ustc.edu.cn/centos/4.7/isos/x86_64/CentOS-4.7.ServerCD-x86_64.iso

Apache-2.2.9

http://archive.apache.org/dist/httpd/httpd-2.2.9.tar.gz

MYSQL-5.2.6

http://downloads.mysql.com/archives/mysql-5.0/mysql-5.0.22.tar.gz

PHP-5.2.6

http://museum.php.net/php5/php-5.2.6.tar.gz

FCGID

http://ncu.dl.sourceforge.net/sourceforge/mod-fcgid/mod_fcgid.2.2.tgz

安装:

第一步:Linux系统安装,同时可以参照我原来的文档

http://www.sunboyu.cn/2008/06/13/centos5%E5%AE%89%E8%A3%85%E6%8C%87%E5%8D%97%EF%BC%88%E7%AE%80%E5%8D%95%E7%AF%87%EF%BC%89.shtml

视频。我按照最小化进行安装。最后ping百度不通,是因为没有重启,重启后是正常的。从过程可疑看出,我用的vmware进行安装,所以,要根据你实际的网络情况进行调整配置。

第二步:系统更新,组件安装。

首先更新一下yum源,具体查看这篇日志http://www.sunboyu.cn/2009/01/07/centos4%E5%88%9D%E5%A7%8B%E5%8C%96%E7%9A%84%E4%B8%80%E4%BA%9B%E8%84%9A%E6%9C%AC.shtml

升级一下系统:yum upgrade

安装一些必要的组件:yum install gcc gcc-c++ gcc4-c++ autoconf gd gd-devel libxml2 libxml2-devel zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel expat expat-devel sqlite sqlite-devel png-devel jpeg-devel libtool libjpeg* libpng* freetype-devel

安装MYSQL-5.0.22

解压mysql

#tar -zxvf mysql-5.0.22.tar.gz

#cd cd mysql-5.0.22

#groupadd mysql

#useradd -g mysql mysql

#./configure --prefix=/opt/mysql-5.0.22 /
--without-debug /
--enable-thread-safe-client /
--with-client-ldflags=-all-static /
--with-mysqld-ldflags=-all-static /
--enable-local-infile /
--enable-largefile /
--with-charset=utf8 /
--with-collation=utf8_unicode_ci /
--with-extra-charsets=complex /
--with-pic /
--with-mysqld-libs /
--with-comment /
--with-query-cache /
--with-bench /
--with-big-tables /
--with-innodb /
--with-mysqld-use=mysql

#make

#make install

#cp ./support-files/my-medium.cnf /etc/my.cnf

#cp ./support-files/mysql.server /etc/init.d/mysqld

#chmod 755 /etc/init.d/mysqld

#/opt/mysql-5.0.22/bin/mysql_install_db --user=mysql &

#echo "/opt/mysql-5.0.22/bin/mysqld_safe --user=mysql &">>/etc/rc.local

#service mysqld start

#/opt/mysql-5.0.22/bin/mysqladmin -u root password '123456'

#cd ..

安装APACHE

#groupadd apache

#useradd -g apache apache

#tar -zxvf httpd-2.2.9.tar.gz

#cd httpd-2.2.9

#./configure --prefix=/opt/httpd-2.2.9 /
--enable-dav /
--enable-dav-fs /
--enable-modules=all /
--enable-mods-shared=all /
--disable-auth-basic /
--enable-include /
--enable-substitute /
--enable-authz-dbm /
--enable-log-config /
--enable-headers /
--enable-setenvif /
--with-ssl /
--enable-static-ab /
--enable-http /
--enable-mime /
--enable-status /
--enable-isapi /
--enable-imagemap /
--enable-actions /
--enable-speling /
--enable-userdir /
--enable-alias /
--enable-vhost-alias /
--enable-dir /
--enable-rewrite /
--enable-dumpio /
--enable-echo /
--enable-so /
--enable-example /
--enable-case-filter /
--enable-substitute /
--enable-log-config /
--enable-logio /
--enable-env /
--with-mpm=worker /
--with-included-apr /
--with-apr /
--with-apr-util /
--with-z /
--enable-proxy /
--enable-proxy-connect /
--enable-proxy-ftp /
--enable-proxy-http /
--enable-proxy-ajp /
--enable-proxy-balancer /
--enable-suexec /
--with-suexec-caller=apache /
--with-suexec-userdir=www /
--with-suexec-docroot=/home /
--with-suexec-uidmin=100 /
--with-suexec-gidmin=100 /
--with-suexec-logfile=/var/log/suexec_log

#make

#make install

#ln -s /opt/httpd-2.2.9/bin/apachectl /etc/init.d/httpd

#cd ..

修改apache配置文件 /opt/httpd-2.2.9/conf/httpd.conf

找到

User daemon
Group daemon

修改为

User apache
Group apache

安装 fcgid

#tar -zxvf mod_fcgid.2.2.tgz

#cd mod_fcgid.2.2

修改Makefile

top_dir = /usr/local/apache2 为 top_dir = /opt/httpd-2.2.9

#make

#make install

#cd ..

修改apache配置文件 httpd.conf

增加 LoadModule fcgid_module modules/mod_fcgid.so

安装PHP,记得增加cgi支持

#tar -zxvf php-5.2.6.tar.gz

#cd php-5.2.6

#./configure --prefix=/opt/php-5.2.6 --with-libxml-dir --enable-cli --enable-cgi --enable-fastcgi --enable-bcmath --enable-force-cgi-redirect --enable-discard-path --enable-path-info-check --with-openssl --with-pcre-regex --enable-calendar --enable-dom --enable-ftp --with-openssl-dir=/usr/local/ssl --enable-gd-jis-conv --enable-hash --with-iconv --enable-json --enable-mbstring --enable-mbregex --enable-pdo --enable-posix --enable-libxml --enable-simplexml --with-sqlite --enable-tokenizer --enable-xmlreader --enable-xmlwriter --enable-sockets --with-zlib --with-freetype-dir --with-gd --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-mime-magic --with-mysql=/opt/mysql-5.0.22 --with-zlib-dir=/usr/lib/libz.so --with-pdo-mysql=/opt/mysql-5.0.22 --with-pdo-sqlite --enable-posix --enable-soap

#make

#make install

修改apache配置文件httpd.conf

找到

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

修改为

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

修改apache配置文件 conf/extra/httpd-vhosts.conf

删除所有的虚拟主机

现在配置虚拟主机:

所有虚拟主机的组为 vhost

增加一个用户名为sunboyu的虚拟主机

#groupadd vhost

#useradd -g vhost sunboyu

用户主目录默认为 /home/sunboyu

增加两个目录

#mkdir /home/sunboyu/www

#mkdir /home/sunboyu/logs

增加虚拟主机配置文件

<VirtualHost *:80>
SuexecUserGroup sunboyu vhost
ServerAdmin sunboyu@gmail.com
DocumentRoot "/home/sunboyu/www"
ServerName 192.168.0.4
ServerAlias sunboyu.cn
ErrorLog "/home/sunboyu/logs/error_log"
CustomLog "|/opt/httpd-2.2.9/bin/rotatelogs /home/sunboyu/logs/%Y_%m_%d_log 86400 +480" common
<Directory /home/sunboyu/www>
AddHandler fcgid-script .php
#AddHandler cgi-script .pl .cgi
FCGIWrapper /home/sunboyu/php-cgi .php
Options ExecCGI FollowSymLinks
AllowOverride all
Order deny,allow
Allow from all
</Directory>
</VirtualHost>

创建文件 /home/sunboyu/php-cgi 文件内容为

#!/bin/sh
export PHPRC=/home/sunboyu
export PHP_FCGI_CHILDREN=4
export PHP_FCGI_MAX_REQUESTS=5000
exec /opt/php-5.2.6/bin/php-cgi "$@"

#chmod 755 -R /home/sunboyu

#chown sunboyu:vhost -R /home/sunboyu

配置到现在,重启apache

#service httpd restart

在虚拟目录根下 /home/sunboyu/www 下写文件 info.php 内容为 phpinfo() 修改权限为755 用户组为 sunboyu:vhost

现在访问应该是phpinfo的信息。

在写这篇文档的时候,基本是按照数续依次安装。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值