


Configure Apache2.2+PHP5+CakePHP1.2+MySQL5 operating environment_PHP tutorial
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
...
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:
'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.

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


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

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

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