今天,在Vista上安装了 Apache 2.2, PHP 5.2.6,花费了三四个小时。 Apache 和 PHP 的新版本,在相互兼容性方面似乎是越来越差了!
Apache 2.2 下载完后安装,倒是很顺利,最后 http://localhost, 显示 It works.
一开始,打算以 Module 形式安装 PHP,安装后显示 缺少不少库,并且不能显示 phpinfo.php。
于是改成以 CGI 形式重新安装,配置如下:
ScriptAlias /php/ "D:/software/PHP/"
AddType application/x-httpd-php .php
# For PHP 5
Action application/x-httpd-php "/php/php-cgi.exe"
打开网址,什么也访问不了:
You don’t have permission to access / on this server.
通过如下设置解决:
DocumentRoot “D:/programdata/Apachehtdocs”
Options FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
Satisfy all
然后就一直显示:
You don’t have permission to access /php/php-cgi.exe/phpinfo.php on this server.
在后台 error.log:
[error] [client 127.0.0.1] client denied by server configuration: D:/software/PHP/php-cgi.exe
最后,增加如下设置,解决了问题:
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
解决了问题。但是,后台又出现了一个问题:
[Sun Oct 12 22:36:57 2008] [error] [client 127.0.0.1] PHP Fatal error: require_once() [function.require]: Failed opening required ‘SAM/php_sam.php’ (include_path=’.;C:\\php5\\pear’) in sam_factory on line 1
这个问题的解决,参考 [RESOLVED] PHP Install Problem – SAM Error 我只是简单地安装PHP时,只选择 MySQL扩展。
一开始,我在计算机上安装了buildix,发现 Buildix的各项功能也能正确运行。但是,一旦我安装并启用了 php5和mod-php5,就会导致buildix被卸载。如下:
liuzhr@suowan-master:/etc/apache2/sites-enabled$ sudo apt-get install php5 libapache2-mod-php5
Reading package lists... Done
Building dependency tree
Reading state information... Done
php5 is already the newest version.
The following packages were automatically installed and are no longer required:
python-libxslt1 libapache2-svn libapache2-mod-python sun-java5-jdk python-libxml2 python-svn libapache2-mod-fastcgi cruisecontrol sun-java5-demo
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
apache2-mpm-prefork
The following packages will be REMOVED:
apache2-mpm-worker buildix
The following NEW packages will be installed:
apache2-mpm-prefork libapache2-mod-php5
0 upgraded, 2 newly installed, 2 to remove and 60 not upgraded.
Need to get 0B/2978kB of archives.
After unpacking 5747kB of additional disk space will be used.
Do you want to continue [Y/n]?
如果选择继续,安装了php5和libapache2-mod-php5,则会导致buildix卸载,如果重新安装 buildix,安装过程中会出现下面的错误,原因大概是libapache-mod-php5被buildix自动卸载了。
liuzhr@suowan-master:/etc/apache2/sites-enabled$ sudo /etc/init.d/apache2 restart
* Restarting web server apache2
* We failed to correctly shutdown apache, so we're now killing all running apache processes. This is almost certainly suboptimal, so please make sure your system is working as you'd expect now!
apache2: Syntax error on line 183 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load: Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/apache2/modules/libphp5.so: cannot open shared object file: No such file or directory。
原因应该是 buildix 依赖于 apache2-mpm-worker, 而目前的 php5只能运行单线程的apache2,这样就必须使用 apache2-mpm-prefork。
使用 apt-cache show buildix 一看,果然buildix依赖于 apache2-mpm-worker。看来必须放弃将 buildix与目前的 php5(Module方式) 在一起安装的方法。
于是只能选择使用 cgi 的方式来安装。参考这篇文章:Installing Apache2 and PHP5 using mod_fcgid 。配置的过程中发生了一些错误(you don’t have permission to access ‘/index.php’),似乎是因为下面的配置中,AllowOverride ,FCGIWrapper ,AddHandler 或者 Options +ExecCGI 的顺序导致的。没有时间仔细研究这个问题,高手看到请指教。
<directory>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
FCGIWrapper /usr/lib/cgi-bin/php5 .php
AddHandler fcgid-script .php
Options +ExecCGI
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
#RedirectMatch ^/$ /apache2-default/
</directory>
php5 目前不能使用 apache2-mpm-worker 模块是因为不支持多线程的apache2。 PHP如此说:Why shouldn’t I use Apache2 with a threaded MPM in a production environment?
有关 apt-get 的命令,参考这里:https://help.ubuntu.com/community/AptGet/Howto
有关 Ubuntu上的LAMP,参考:ApacheMySQLPHP
Recent Comments