Linux下快速搭建Apache/Lighttpd+PHP+MySQL_Linux教程

编辑Tag赚U币

使用Ubuntu Linux, 编译过程提示缺啥补啥即可.

Apache:

./configure --prefix=/home/work/httpd --enable-so --enable-rewrite

配置文件:

LoadModule php5_module        modules/libphp5.so
AddType application/x-httpd-php .php
# PhpIniDir /home/work/php/php.ini

MYSQL:

 

./configure  --prefix=/home/work/mysql\
 --with-unix-socket-path=/home/work/mysql/tmp/mysql.sock\
 --with-big-tables\
 --with-plugins=innobase

groupadd mysql
useradd  -s /bin/false -g mysql -pmysql mysql
/home/work/mysql/bin/mysql_install_db --user=mysql
cp support-files/my-medium.cnf /home/work/mysql/etc/my.cnf

启动:

/home/work/mysql/share/mysql/mysql.server start

修改密码 mysqladmin password ‘xxx’

出错: Starting MySQL.Manager of pid-file quit without updating fi[FAILED]
解决: 权限问题, 他妈的MySQL都提示些什么狗屎!

innodb

如果还不支持innodb, 进入mysql命令行执行:
install plugin innodb soname ‘ha_innodb.so’;

PHP:

PHP 一定要安装 APC 模块, 否则性能会下降不少: http://pecl.php.net/package/APC (编译PHP模块的方法)

用Apache

./configure --prefix=/home/work/php --with-config-file-path=/home/work/php\
 --with-mysql=/home/work/mysql\
 --enable-mbstring\
 --with-pdo-mysql=/home/work/mysql\
 --with-apxs2=/home/work/httpd/bin/apxs\
 --with-gettext\
 --enable-soap\
 --with-zlib\
 --with-gd\
 --with-jpeg=/usr/lib

将源码目录下的php.ini-dist文件改名为php.ini, 拷贝到/home/work/php目录下.

用Lighttpd

./configure --prefix=/home/work/litty/php --with-config-file-path=/home/work/litty/php\
 --with-mysql=/home/work/mysql\
 --enable-mbstring\
 --with-pdo-mysql=/home/work/mysql\
 --with-gettext\
 --enable-soap\
 --with-zlib\
 --enable-fastcgi\
 --enable-force-cgi-redirect\
 --with-gd\
 --with-jpeg=/usr/lib

需要安装libjpeg62_dev

不能同时使用apxs2和fastcgi.

配置Apache虚拟主机

<VirtualHost *:80>
    DocumentRoot "/home/work/htdocs/ideawu.net"
    ServerName ideawu.net
    ServerAlias ideawu.net *.ideawu.net
    ErrorLog "/home/work/logs/ideawu.net-error.log"
    CustomLog "/home/work/logs/ideawu.net-access.log" common

    DirectoryIndex index.php index.html index.htm

    <Directory "/home/work/htdocs/ideawu.net">
        Options FollowSymLinks

        AllowOverride None 

        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

安装配置Lighttpd(litty)

$HTTP["host"] =~ "(.*\.)?ideawu.net" {
	server.name = "www.ideawu.net"
	server.document-root = "/home/work/htdocs/ideawu.net/"
	server.errorlog = "/home/work/litty/logs/ideawu.net-error.log"
	accesslog.filename = "/home/work/litty/logs/ideawu.net-access.log"
}

fastcgi.server = ( ".php" =>
	(
		(
			"socket" => "/tmp/php-fastcgi.socket",
			"bin-path" => "/home/work/litty/php/bin/php-cgi",
			#"min-procs" => 2, #这个参数在新版本里已经不起作用了.
			"max-prccs" => 16,
			"bin-environment" => (
				"PHP_FCGI_CHILDREN" => "1",
				"PHP_FCGI_MAX_REQUESTS" => "10000"
			),
		)
	)
)

(版本1.4.26), 已经集成了spawn-fcgi, 也就是不再单独生成这个名字的可执行文件, min-procs参数也不再起作用. 启动的php-cgi进程数是
max-procs * ( PHP_FCGI_CHILDREN + 1 ), PHP_FCGI_CHILDREN默认=1.

来源:网络搜集//所属分类:Linux教程/更新时间:2012-06-21
相关Linux教程