Configure APACHE2.2+PHP5+CAKEPHP1.2+MYSQL5 Run Environment _php instance

Source: Internet
Author: User
Tags phpinfo

1. Installation Configuration Apahce

Installation configuration Apache is relatively simple, follow the installation wizard step-by-step down can be done. At most, you need to be aware that if you have installed another Web server that occupies 80 ports, you should remember to choose a different port when configuring the port. I forgot to set it in the wizard, so I'll just change the following sentence in the Apache conf/httpd.conf:

Listen 127.0.0.1:80

2. Installation Configuration PHP5

PHP5 is also installed all the way over. To allow Apache to interpret the PHP page, continue to modify the Apache conf/httpd.conf file. First, suppose PHP5 is installed in the D:\PHP5 directory.

The first is to load the PHP5 module in Apache, add the following sentence:

LoadModule Php5_module D:/php5/php5apache2_2.dll

Then let Apache know the PHP page mime, find <ifmodule mime_module> block, add a sentence in this block AddType statement:

<ifmodule Mime_module>
...
AddType application/x-httpd-php. php
...
</IfModule>

Finally, the index.php is set to the default page so that the index.php is automatically found when the page is not specified when browsing. Locate the <ifmodule dir_module> block and modify the DirectoryIndex configuration inside:

<ifmodule Dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>

Here to note the order of the default page, according to the above configuration, if a directory at the same time index.html and index.php, will first find and open the index.html.

Finally, let Apache find the configuration of PHP. The general idea is to copy the php.ini to the Windows directory, but I prefer to configure this location in Apache:

<ifmodule Php5_module>
Phpinidir D:/php5/php.ini
</IfModule>

OK, now that PHP should be configured, write a simple PHP try-start or restart the Apache server, Under the Apache Htdocs directory, create a new phpinfo.php file (if DocumentRoot is modified, the location is determined according to the modified DocumentRoot), as follows:

?
Phpinfo ();
?>

Now open the browser to see the http://localhost/phpinfo.php(not the default port remember to write the port number), to see the effect.

3. Installation Configuration Cake

The so-called installation, is actually decompression just. First to extract the cake to D:\cakephp, then cake extracted the directory structure is probably like this:

D:\CakePHP
│.htaccess
│index.php
│readme
├──app
│└──webroot
├──cake
└──vendors

From a variety of Google data to view, Web applications have about three ways to configure, even the order of introduction has not changed. The second, that is, does not change cake's directory structure, there is a certain degree of security, I think it is good, adopted.

First, the App/webroot directory below the cake is set to Apache DocumentRoot; then you open the Rewrite module (remove the annotation symbol) , and configure the AllowOverride property of the DocumentRoot directory to all. Then modify the following in the Apache configuration file:

...
LoadModule Rewrite_module modules/mod_rewrite.so
...
DocumentRoot "D:/cakephp/app/webroot"
...
<directory "D:/cakephp/app/webroot">
AllowOverride All
</Directory>
...

Then restart Apache again, visit http://localhost/ to try, this time should be able to display some information of cake.

If you use the Advanced configuration when configuring cake, you may experience a warning on the page when you try to run it:

Warning (): Cache not configured properly. ...
Warning (2): Array_merge () [Function.array-merge]: ...
Warning (2): Array_merge () [Function.array-merge]: ...

Encountered this problem I really head, check a half-day data, the results in almost despair, do not know where to see a message, that is to let the app under the Tmp/cache/persistent directory has write permission. Look, the original TMP does not exist in the cache directory, so they created the cache/persistent directory. If you are in the Linux directory, also give this directory 777 permissions.

4. Install configuration MySQL

MySQL installation is also very simple, after installation also has a wizard to configure some things. These are the things on the database, just follow the wizard step by step. The key is to get PHP and cake to use the MySQL database.

About the configuration in PHP, directly modify the php.ini, the extension=php_mysql.dll before the annotation symbol removed, which is

...
Extension=php_mysql.dll
...

Then write the phpinfo.php copy to the cake under the App/webroot, and then browse a http://localhost/phpinfo.php, to see if there is no MySQL configuration information on the page-- Probably not. Because there was less to do-I was so depressed that I had to spend half a day here.

There are a bunch of DLLs in the PHP5 directory that are copied directly to the Apache Bin directory (if your PHP5 directory is in path, you may not need to be so troublesome). Now look again, the page should have MySQL configuration information.

Cake's configuration is in the config/database.php in the app directory. Didn't you find this file? Have you seen a database.php.default? Make a copy of it, name it database.php. And then of course I have to a pity dorado things.

There is only one Database_config class in this configuration, it has a $default variable, save is the default database configuration information. Almost configured to look like this:

var $default = Array (
' Driver ' => ' MySQL ',
' Persistent ' => false,
' Host ' => ' localhost ',
' Login ' => ' your-username ',
' Password ' => ' Your-password ',
' Database ' => ' your-database ',
' Prefix ' => ',
);

Note that login, password, and database three are configured according to the actual situation. After the configuration is complete, browse http://localhost/, and there should be a "Your database configuration file is present" on this page. ”。 If your database is ready, you will see "Cake is able to connect to". If you are not ready, you may see some warnings or error messages.

Summary

This configuration is really exhausting. Who is interested to do a full installation package, according to the installation location automatic configuration, how good! Or a GUI or a Web interface configuration program is also good.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.