配置Apache2.2+PHP5+CakePHP1.2+MySQL5运行环境
1. 安装配置Apahce
安装配置Apache是比较简单的, 跟着安装向导一步步往下走就能搞定。最多就是在配置端口的地方需要注意一下,如果已经安装了其它Web服务器占用了80端口,那记得配置的时候选一个别的端口。向导中忘了设置,在Apache的conf/httpd.conf中修改下面这句就好:
2. 安装配置PHP5
PHP5也是一路安装就完了。要让Apache能解释PHP页面,继续修改Apache的conf/httpd.conf文件。 首先,假设PHP5是安装在D:\php5目录。
首先是要在Apache中载入PHP5的模块,加下面这句:
然后是让Apache认识PHP页面的Mime,找到
...
AddType application/x-httpd-php .php
...
最后还要把index.php设置成默认页面,这样在浏览时没指定页面的情况下会自动找到index.php。找到
DirectoryIndex index.html index.htm index.php
这里要注意默认页面的顺序,按上面的配置,如果一个目录下同时存在index.html和index.php的情况下,会优先找到并打开index.html。
最后还要让Apache能找到PHP的配置。一般说法是把php.ini拷贝到Windows目录下,但是我宁愿在Apache中配置这个位置:
PHPIniDir d:/php5/php.ini
好了,现在PHP应该配置完了,写个最简单的PHP试试看——启动或重启Apache服务器,在Apache的htdocs目录下去新建个phpinfo.php文件(如果修改了DocumentRoot,就根据修改后的DocumentRoot决定位置),内容如下:
phpinfo();
?>
现在打开浏览器看看http://localhost/phpinfo.php(非默认端口记得写端口号),看看效果。
3. 安装配置CakePHP
所谓安装,其实就是解压而已。先把CakePHP解压到D:\cakephp,那么CakePHP解压出来的目录结构大概是这个样子:
│ .htaccess
│ index.php
│ README
├──app
│ └──webroot
├──cake
└──vendors
从Google上的各种资料来查看,Web应用的大概有三种配置方式,连介绍的顺序都没变过。其中第二种,也就是不改变CakePHP的目录结构,也有一定安全性的一种,我觉得还不错,采用了。
先要把CakePHP下面的app/webroot目录设置成Apache的DocumentRoot;然后要打开rewrite模块(去掉注释符号);还要配置DocumentRoot目录的AllowOverride属性改为All。那么要修改Apache的配置文件的下面这些内容:
LoadModule rewrite_module modules/mod_rewrite.so
...
DocumentRoot "D:/cakephp/app/webroot"
...
AllowOverride All
...
然后再次重启Apache,访问http://localhost/试试,这时候应该能显示CakePHP的一些信息了。
如果配置CakePHP的时候采用的高级配置,在试运行的时候可能会遇到页面上有如下这样的警告:
Warning (2): array_merge() [function.array-merge]: ...
Warning (2): array_merge() [function.array-merge]: ...
遇到这个问题我真是头大,查了半天资料,结果在几乎绝望的时候,不知道在哪里看到一则信息,说是要让APP下的tmp/cache/persistent目录有写权限。查看了一下,原来tmp并不存在cache目录,所以自己创建了cache/persistent目录。如果在在Linux目录下,还要给这个目录777权限。
4. 安装配置MySQL
MySQL的安装也很简单,安装完之后也有向导配置一些东西。这些都是数据库上的事情,根据向导一步步操作就好。关键是要让PHP和CakePHP能使用MySQL数据库。
关于PHP中的配置,直接修改php.ini,把extension=php_mysql.dll前面的注释符号去掉,也就是
extension=php_mysql.dll
...
然后把刚才写的phpinfo.php拷贝到CakePHP的app/webroot下面来,再浏览一次http://localhost/phpinfo.php,看看页面中有没有关于MySQL的配置信息——多半没得。因为还少做了点事情——我很郁闷,这里就耽误了我半天时间。
PHP5目录下有一大堆DLL,直接把这些DLL拷贝到Apache的bin目录下去(如果你的PHP5目录在PATH中,也许不用这么麻烦)。现在再看看,页面上应该有MySQL的配置信息了吧。
CakePHP的配置在app目录下的config/database.php中。没发现这个文件么?有没有看到一个database.php.default?把它拷贝一份更名为database.php就好。然后当然还要改点东西。
这个配置里只有一个DATABASE_CONFIG类,它有一个$default变量,保存就是默认数据库的配置信息。差不多配置成这个样子:
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'your-username',
'password' => 'your-password',
'database' => 'your-database',
'prefix' => '',
);
注意login、password和database三项根据实际情况来配置。配置完成后浏览http://localhost/,这个页面上应该有一句“Your database configuration file is present. ”。如果你的数据库准备好了,会看到“Cake is able to connect to the database.”;如果没准备好,可能会看到一些警告或者错误消息。
小结
这个配置真是累死人。谁有兴趣做个完整安装包吧,根据安装位置自动配置,多好!或者做个GUI或者Web界面的配置程序也不错。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Solution to the problem that Win11 system cannot install Chinese language pack With the launch of Windows 11 system, many users began to upgrade their operating system to experience new functions and interfaces. However, some users found that they were unable to install the Chinese language pack after upgrading, which troubled their experience. In this article, we will discuss the reasons why Win11 system cannot install the Chinese language pack and provide some solutions to help users solve this problem. Cause Analysis First, let us analyze the inability of Win11 system to

You may not be able to install guest additions to a virtual machine in OracleVirtualBox. When we click on Devices>InstallGuestAdditionsCDImage, it just throws an error as shown below: VirtualBox - Error: Unable to insert virtual disc C: Programming FilesOracleVirtualBoxVBoxGuestAdditions.iso into ubuntu machine In this post we will understand what happens when you What to do when you can't install guest additions in VirtualBox. Unable to install guest additions in VirtualBox If you can't install it in Virtua

If you have successfully downloaded the installation file of Baidu Netdisk, but cannot install it normally, it may be that there is an error in the integrity of the software file or there is a problem with the residual files and registry entries. Let this site take care of it for users. Let’s introduce the analysis of the problem that Baidu Netdisk is successfully downloaded but cannot be installed. Analysis of the problem that Baidu Netdisk downloaded successfully but could not be installed 1. Check the integrity of the installation file: Make sure that the downloaded installation file is complete and not damaged. You can download it again, or try to download the installation file from another trusted source. 2. Turn off anti-virus software and firewall: Some anti-virus software or firewall programs may prevent the installation program from running properly. Try disabling or exiting the anti-virus software and firewall, then re-run the installation

How to execute .sh file in Linux system? In Linux systems, a .sh file is a file called a Shell script, which is used to execute a series of commands. Executing .sh files is a very common operation. This article will introduce how to execute .sh files in Linux systems and provide specific code examples. Method 1: Use an absolute path to execute a .sh file. To execute a .sh file in a Linux system, you can use an absolute path to specify the location of the file. The following are the specific steps: Open the terminal

Understanding Linux Bashrc: Function, Configuration and Usage In Linux systems, Bashrc (BourneAgainShellruncommands) is a very important configuration file, which contains various commands and settings that are automatically run when the system starts. The Bashrc file is usually located in the user's home directory and is a hidden file. Its function is to customize the Bashshell environment for the user. 1. Bashrc function setting environment

Installing Android applications on Linux has always been a concern for many users. Especially for Linux users who like to use Android applications, it is very important to master how to install Android applications on Linux systems. Although running Android applications directly on Linux is not as simple as on the Android platform, by using emulators or third-party tools, we can still happily enjoy Android applications on Linux. The following will introduce how to install Android applications on Linux systems.

If you have used Docker, you must understand daemons, containers, and their functions. A daemon is a service that runs in the background when a container is already in use in any system. Podman is a free management tool for managing and creating containers without relying on any daemon such as Docker. Therefore, it has advantages in managing containers without the need for long-term backend services. Additionally, Podman does not require root-level permissions to be used. This guide discusses in detail how to install Podman on Ubuntu24. To update the system, we first need to update the system and open the Terminal shell of Ubuntu24. During both installation and upgrade processes, we need to use the command line. a simple

While studying in high school, some students take very clear and accurate notes, taking more notes than others in the same class. For some, note-taking is a hobby, while for others, it is a necessity when they easily forget small information about anything important. Microsoft's NTFS application is particularly useful for students who wish to save important notes beyond regular lectures. In this article, we will describe the installation of Ubuntu applications on Ubuntu24. Updating the Ubuntu System Before installing the Ubuntu installer, on Ubuntu24 we need to ensure that the newly configured system has been updated. We can use the most famous "a" in Ubuntu system
