Because I recently used PHP as a little thing and learned new PHP. As a result, it took only two hours to learn about PHP, but two days to configure the server. In order to avoid forgetting it in the future, write a blog and leave it to the bottom. 1. install and configure Apahce
It is relatively simple to install and configure Apache. You can follow the Installation Wizard step by step. At most, note the port configuration. If other Web servers have used port 80, select another port. In the wizard, you forgot to set the parameter. In Apache conf/httpd. conf, modify the following sentence:
Listen 127.0.0.1: 80
2. install and configure PHP5
PHP5 installation is complete. To enable Apache to interpret the PHP page, continue to modify the conf/httpd. conf file of Apache. First, assume that PHP5 is installed in the D: \ php5 directory.
First, load the PHP5 module in Apache, and add the following sentence:
LoadModule php5_module d:/php5/php5apache2_2.dll
Then let Apache know the Mime of the PHP page and find Add an AddType statement to the block:
Mime_module >
...
AddType application/x-httpd-php. php
...
Finally, you need to set index. php to the default page, so that index. php will be automatically found if no page is specified during browsing. Find To modify the DirectoryIndex Configuration:
Dir_module >
DirectoryIndex index.html index.htm index. php
.
Finally, Apache should be able to find the PHP configuration. In general, php. ini is copied to the Windows directory, but I would rather configure this location in Apache:
Php5_module >
PHPIniDir d:/php5/php. ini
Now, PHP should be configured. Write the simplest PHP and try it. Start or restart the Apache server and create a new phpinfo in the Apache htdocs directory. PHP file (if DocumentRoot is modified, the location is determined based on the modified DocumentRoot file). The content is as follows:
Phpinfo();
?>
Open the browser and check the http: // localhost/phpinfo. php (remember to write the port number for non-default ports.
3. install and configure CakePHP
The so-called installation is actually decompression. Decompress CakePHP to D: \ cakephp first, then the directory structure extracted by CakePHP is like this:
D: \ CakePHP
│. Htaccess
│ Index. php
│ README
── App
│ ── Webroot
── Cake
── Vendors
From the various information on Google, there are about three configuration methods for Web applications, and the order of introduction has not changed. The second method is not to change the directory structure of CakePHP, but also to ensure security. I think it is good to use it.
Set the app/webroot directory under CakePHP to the DocumentRoot directory of Apache, open the rewrite module (remove the annotator), and change the AllowOverride attribute of the DocumentRoot directory to All. Modify the following content in the Apache configuration file:
...
LoadModule rewrite_module modules/mod_rewrite.so
...
DocumentRoot "D:/cakephp/app/webroot"
...
"D:/cakephp/app/webroot" >
AllowOverride All
...
Restart Apache again and access http: // localhost/. At this time, some information about CakePHP should be displayed.
If you use advanced configuration When configuring CakePHP, you may encounter the following warning on the page during trial run:
Warning (512): Cache not configured properly ....
Warning (2): array_merge () [function. array-merge]:...
Warning (2): array_merge () [function. array-merge]:...
I was really big when I encountered this problem. I checked the information for half a day and found that when I was almost desperate, I did not know where to see a piece of information, to grant the write permission to the tmp/cache/persistent directory in the APP. Check that the tmp directory does not exist, so you have created the cache/persistent directory. If you are in the Linux directory, you also need to grant the 777 permission to this directory.
4. install and configure MySQL
The installation of MySQL is also very simple. After the installation, there are some wizard configuration items. These are all database tasks. Follow the wizard step by step. The key is to allow PHP and CakePHP to use the MySQL database.
For the configuration in PHP, directly modify php. ini and remove the annotation symbol before extension = php_mysql.dll, that is
...
Extension = php_mysql.dll
...
Then put the phpinfo. copy php to the app/webroot of CakePHP and browse http: // localhost/phpinfo again. php: Check whether MySQL configuration information is available on the page. Because I did not do anything much-I was very depressed, and I was delayed for half a day.
There are a lot of DLL under the PHP5 directory, and directly copy these DLL files to the Apache bin directory (If your PHP5 directory is in the PATH, it may not be so troublesome ). Now let's take a look at the configuration information of MySQL on the page.
The configuration of CakePHP is in config/database. php under the app directory. Didn't you find this file? Is there a database. php. default? Just copy it and rename it database. php. Then, of course, you have to change something.
There is only one DATABASE_CONFIG class in this configuration. It has a $ default variable, which is saved as the configuration information of the default database. The configuration is similar to 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 are configured according to the actual situation. After the configuration is complete, browse http: // localhost/. on this page, there should be a "Your database configuration file is present .". If your database is ready, you will see "Cake is able to connect to the database.". If you are not prepared, you may see some warning or error messages.
Summary
This configuration is really exhausting. Who is interested in creating a complete installation package? How nice is it to automatically configure it based on the installation location! Or a GUI or Web interface configuration program is also good.