Table of Contents
1. 安装配置Apahce
2. 安装配置PHP5
3. 安装配置CakePHP
4. 安装配置MySQL
Summary
Home Backend Development PHP Tutorial Configure Apache2.2+PHP5+CakePHP1.2+MySQL5 operating environment_PHP tutorial

Configure Apache2.2+PHP5+CakePHP1.2+MySQL5 operating environment_PHP tutorial

Jul 21, 2016 pm 03:47 PM
Install environment run Configuration

1. 安装配置Apahce

  安装配置Apache是比较简单的, 跟着安装向导一步步往下走就能搞定。最多就是在配置端口的地方需要注意一下,如果已经安装了其它Web服务器占用了80端口,那记得配置的时候选一个别的端口。向导中忘了设置,在Apache的conf/httpd.conf中修改下面这句就好:

Listen 127.0.0.1:80

2. 安装配置PHP5

  PHP5也是一路安装就完了。要让Apache能解释PHP页面,继续修改Apache的conf/httpd.conf文件。 首先,假设PHP5是安装在D:\php5目录。

  首先是要在Apache中载入PHP5的模块,加下面这句:

LoadModule php5_module d:/php5/php5apache2_2.dll

  然后是让Apache认识PHP页面的Mime,找到块,在这个块里加一句AddType语句:

mime_module>
    ...
    AddType application/x-httpd-php .php
    ...

  最后还要把index.php设置成默认页面,这样在浏览时没指定页面的情况下会自动找到index.php。找到块,修改里面的DirectoryIndex配置:

dir_module>
    DirectoryIndex index.html index.htm index.php

  这里要注意默认页面的顺序,按上面的配置,如果一个目录下同时存在index.html和index.php的情况下,会优先找到并打开index.html。

  最后还要让Apache能找到PHP的配置。一般说法是把php.ini拷贝到Windows目录下,但是我宁愿在Apache中配置这个位置: 

php5_module>
    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解压出来的目录结构大概是这个样子:

D:\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"
...
"D:/cakephp/app/webroot">
    AllowOverride All   

...

  然后再次重启Apache,访问http://localhost/试试,这时候应该能显示CakePHP的一些信息了。

  如果配置CakePHP的时候采用的高级配置,在试运行的时候可能会遇到页面上有如下这样的警告:

Warning (512): Cache not configured properly. ...
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
...

Then copy the phpinfo.php you just wrote to CakePHP’s app/webroot, and browse http://localhost/phpinfo.php again to see if there is any MySQL configuration on the page. Information—probably none. Because I haven't done enough things - I'm very depressed, and it took me half a day here.

There are a lot of DLLs in the PHP5 directory. Copy these DLLs directly to Apache's bin directory (if your PHP5 directory is in PATH, you may not need to bother so much). Take a look now. There should be MySQL configuration information on the page.

The configuration of CakePHP is in config/database.php in the app directory. Didn't you find this file? Did you see a database.php.default? Just make a copy of it and rename it database.php. Then of course you have to change something.

There is only one DATABASE_CONFIG class in this configuration, which has a $default variable, which saves the configuration information of the default database. The configuration is almost 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 are configured according to the actual situation. After the configuration is completed, browse http://localhost/. There should be a sentence "Your database configuration file is present." on this page. If your database is ready, you will see "Cake is able to connect to the database."; if not, you may see some warning or error messages.

Summary

This configuration is really tiring. Who is interested in making a complete installation package? It will be automatically configured according to the installation location. How great! Or it would be good to make a GUI or Web interface configuration program.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319978.htmlTechArticle1. Install and configure Apache. Installing and configuring Apache is relatively simple. Just follow the installation wizard step by step and you can get it done. . The most you need to pay attention to is where you configure the port. If you have...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1266
29
C# Tutorial
1239
24
Solution to the problem that Win11 system cannot install Chinese language pack Solution to the problem that Win11 system cannot install Chinese language pack Mar 09, 2024 am 09:48 AM

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

Unable to install guest additions in VirtualBox Unable to install guest additions in VirtualBox Mar 10, 2024 am 09:34 AM

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

How to execute .sh file in Linux system? How to execute .sh file in Linux system? Mar 14, 2024 pm 06:42 PM

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

What should I do if Baidu Netdisk is downloaded successfully but cannot be installed? What should I do if Baidu Netdisk is downloaded successfully but cannot be installed? Mar 13, 2024 pm 10:22 PM

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

Understand Linux Bashrc: functions, configuration and usage Understand Linux Bashrc: functions, configuration and usage Mar 20, 2024 pm 03:30 PM

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

How to install Android apps on Linux? How to install Android apps on Linux? Mar 19, 2024 am 11:15 AM

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.

How to install Podman on Ubuntu 24.04 How to install Podman on Ubuntu 24.04 Mar 22, 2024 am 11:26 AM

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

How to Install and Run the Ubuntu Notes App on Ubuntu 24.04 How to Install and Run the Ubuntu Notes App on Ubuntu 24.04 Mar 22, 2024 pm 04:40 PM

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

See all articles