Windows下PHP5和Apache的安装与配置_PHP
Apache
在这里以PHP5为例介绍一下Windows下Apache和PHP5的安装与配置方法。一 下载安装程序
Apache可以从http://www.apache.org/dyn/closer.cgi/httpd/binaries/win32/下载
PHP可以从http://www.php.net下载.
二 安装程序
1、Apache的程序安装相对来说要较为的简单一些,我们从网站下来的是一个Windows下的安装程序,我们可以直接双击运行,这样我们就便利Apache在我们的电脑上安下家来了。
2、我们在这里要注意的就是在下载PHP时一定要下载那个zip包的,而不要下载Installer的.将我们下载下来的PHP包解压到C盘下的根目录下,并将解压出来的文件夹改名为php。
三 配置
1、最好是无论使用何种接口(CGI 或者 SAPI)都确保 php5ts.dll 可用,因此必须将此文件放到 Windows 路径中。最好的位置是 Windows 的 system 目录:
c:\windows\system for Windows 9x/ME
c:\winnt\system32 for Windows NT/2000 或者 c:\winnt40\system32 for Windows NT/2000 服务器版
c:\windows\system32 for Windows XP
2、下一步是设定有效的 PHP 配置文件,php.ini。压缩包中包括两个 ini 文件,php.ini-dist 和 php.ini-recommended。建议使用 php.ini-recommended,因为此文件对默认设置作了性能和安全上的优化。
将选择的 ini 文件拷贝到 PHP 能够找到的目录下并改名为 php.ini。PHP 默认在 Windows 目录下搜索 php.ini:
3 在 Windows 9x/ME/XP 下将选择的 ini 文件拷贝到 %WINDIR%,通常为 c:\windows。
在 Windows NT/2000 下将选择的 ini 文件拷贝到 %WINDIR% 或 %SYSTEMROOT% 下,通常为 c:\winnt 或 c:\winnt40 对应于服务器版本。
4 Apache中PHP的设置
有两种方法使得 PHP 工作在 Windows 下的 Apache。一是使用 CGI 二进制文件,另一是使用 Apache 模块 DLL。无论那种方法,您首先必须停止 Apache 服务器,然后编辑 httpd.conf,以配置 Apache 和 PHP 协同工作。
如果我们要使用CGI二进制文件,那么我们要将如下指令插入到 Apache 的 httpd.conf 配置文件中,以设置 CGI 二进制文件:
PHP 以 CGI 方式安装到 Apache 2.0:
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php.exe"
如果我们想把 PHP 作为 Apache 2.0 的模块,那么就一定要移动 php4ts.dll 到 winnt/system32(Windows NT/2000)或 windows/system32(Windows XP),覆盖原有文件(如果有的话),对于 PHP 5,这个文件是 php5ts.dll。然后我们要插入如下两行到 httpd.conf 中,以使我们的 PHP 作为 Apache 的 PHP-Module 安装:
PHP 以模块方式安装到 Apache 2.0:
; For PHP 4 do something like this:
LoadModule php4_module "c:/php/php4apache2.dll"
AddType application/x-httpd-php .php
; For PHP 5 do something like this:
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php
经过这样的配置以后,我们就安装好了我们的PHP和Apache服务器了。我们可以简单的测试一下:
1、测试Apache:
我们打开浏览器,在地址栏中输入localhost,如果可以出现Apache页面,则说明我们的Apache可以正常工作了。
2、测试PHP设置:
我们可以简单的编写一个PHP页面,我们可以用文本编辑器,输入下面的代码:
<html>
<head>
<title>
hello
</title>
</head>
<body>
<?php echo "hello,php"; ?>
</body>
</html>
然后将这个文件存为hello.php,将其放在Apache的htdocs目录中(我们也可以在http.conf文件中来更改这个目录的),然后在我们的浏览器中输入http://localhost/hello.php,如果能够正确的显示hello,php就说明我们的PHP配置是可以正常工作的。
这样以后我们也可以来设计我们的PHP站点了。

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

AI Hentai Generator
Generate AI Hentai for free.

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



PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

To set up a CGI directory in Apache, you need to perform the following steps: Create a CGI directory such as "cgi-bin", and grant Apache write permissions. Add the "ScriptAlias" directive block in the Apache configuration file to map the CGI directory to the "/cgi-bin" URL. Restart Apache.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

The steps to start Apache are as follows: Install Apache (command: sudo apt-get install apache2 or download it from the official website) Start Apache (Linux: sudo systemctl start apache2; Windows: Right-click the "Apache2.4" service and select "Start") Check whether it has been started (Linux: sudo systemctl status apache2; Windows: Check the status of the "Apache2.4" service in the service manager) Enable boot automatically (optional, Linux: sudo systemctl

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.
