PHP 服务器配置(使用Apache及IIS两种方法)
一、使用Apache
≡ PHP 5.2.5 的安装 ≡
1、到其官方站点下载 php-5.2.5-Win32.zip 并解压(据说:不要下载及使用它的Installer,这种方式虽然很自动化、很智能,但也存在很多方面的限制,因为不推荐。)到一个目录"D:\PHP\PHP"。
将PHP目录(D:\PHP\PHP)下的php.ini-recommended复制到windows(有的系统是winnt目录)目录下,并改名为php.ini,并找到extension_dir,将它修改为extension_dir="D:\PHP\PHP\ext"。其实使用php.ini-dist也能达到同样的效果,但建议使用 php.ini-recommended,因为此文件对默认设置作了性能和安全上的优化。
PHP.ini部分说明:
default_charset="gb2312" ,修改默认字符集,这里,如果前面有分号“;”,去掉这个分号;
register_globals=Off 改为 register_globals=On ,使传递全局变量有效;
extension=php_dba.dll 如果前面有分号,取消分号,以下同;
extension=php_dbase.dll
extension=php_gd2.dll GD库做图,一般用于图形验证码;
extension=php_mysql.dll 用于连接MYSQL数据库;
short_open_tag=On 支持和…?>,Off为仅支持
复制D:\PHP\PHP目录下的php5ts.dll和libmysql.dll(用于支持mysql)文件到windows的系统文件夹里,即:C:\windows\system32。
≡ Apache 2.2.8 的安装 ≡
1、到其官方站点下载 apache_2.2.8-win32-x86-no_ssl.msi 并执行。
按3次Next按钮,安装程序要求输入你的Network Domain(网络域名)、Server Domain(服务器域名)和网站管理员的E-mail,有的话就如实填写,本说明介绍的是本地自建测试环境,所以随便一下,前两个填 localhost ,邮件写自己的即可。
进入Next后,默认的安装路径是"C:\Program Files\Apache Software Foundation\Apache2.2\",修改路径,改为自己所要的"D:\PHP\Apache2.2"。
然后一路下去,直到安装结束;此时,打开D盘下的PHP文件夹,可以看到有一个名为Apache2.2的文件夹。
2、打开IE,然后在地址栏输入:"http://localhost" 或者 "http://127.0.0.1" 可以看到Apache安装完成的成功页面;
3、conf/httpd.conf文件的配置
1)查找“DocumentRoot”,这里是指定主页放置的目录。默认是:“D:\PHP\Apache2.2\htdocs”,你可以使用默认的目录,也可以自己定义一个,如:“D:/PHP”。注意:目录末尾不要加“/”。
2)查找“DirectoryIndex”,这里是默认首页文件名,可以在index.html 的后面加入index.php等。多个文件名用空格分隔。
3)查找
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
修改为:
Options FollowSymLinks
AllowOverride None
Order deny,allow
allow from all
如果不改这里的话,可能会出现 You don't have permission to access / on this server. 这样的错误提示,尤其在改变了默认主页的路径后。
4)建立虚拟目录
找到
添加Alias /webpath "D:\PHP\Apache2.2\phptxt"
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
其中/webpath为虚拟目录名称,"D:\PHP\Apache2.2\phptxt"为文件存放位置。
访问的地址为:http://localhost/webpath/
5)使服务器支持PHP,在相应位置加入如下两句代码
LoadModule php5_module "D:\PHP\PHP\php5apache2_2.dll"
AddType application/x-httpd-php .php .php3 .inc
注意:修改了httpd.conf文件,需要重启Apache2.2才生效。
二、使用IIS解析PHP文件
1、同上,先安装 PHP 5.2.5。
2、打开IIS管理器,选择“默认网站”->"属性",弹出的对话框中选择“主目录”先项卡,执行权限改为“脚本和可执行文件”,点击“配置”,添加应用程序扩展名映射,可执行文件选择“D:\PHP\PHP\php5isapi.dll”,扩展名“.php”,并选择全部动作、脚本引擎、确认文件是否存在。
若为win2003系统,还需要添加web服务扩展,要求的文件为“D:\PHP\PHP\php5isapi.dll”,扩展名为“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 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.

PHP remains a powerful and widely used tool in modern programming, especially in the field of web development. 1) PHP is easy to use and seamlessly integrated with databases, and is the first choice for many developers. 2) It supports dynamic content generation and object-oriented programming, suitable for quickly creating and maintaining websites. 3) PHP's performance can be improved by caching and optimizing database queries, and its extensive community and rich ecosystem make it still important in today's technology stack.

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 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

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.

This article introduces several methods to check the OpenSSL configuration of the Debian system to help you quickly grasp the security status of the system. 1. Confirm the OpenSSL version First, verify whether OpenSSL has been installed and version information. Enter the following command in the terminal: If opensslversion is not installed, the system will prompt an error. 2. View the configuration file. The main configuration file of OpenSSL is usually located in /etc/ssl/openssl.cnf. You can use a text editor (such as nano) to view: sudonano/etc/ssl/openssl.cnf This file contains important configuration information such as key, certificate path, and encryption algorithm. 3. Utilize OPE

This article will explain how to improve website performance by analyzing Apache logs under the Debian system. 1. Log Analysis Basics Apache log records the detailed information of all HTTP requests, including IP address, timestamp, request URL, HTTP method and response code. In Debian systems, these logs are usually located in the /var/log/apache2/access.log and /var/log/apache2/error.log directories. Understanding the log structure is the first step in effective analysis. 2. Log analysis tool You can use a variety of tools to analyze Apache logs: Command line tools: grep, awk, sed and other command line tools.

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.
