Home Backend Development PHP Tutorial 安装Apache和PHP的一些补充,一篇很实用的文章_PHP

安装Apache和PHP的一些补充,一篇很实用的文章_PHP

Jun 01, 2016 pm 12:37 PM
a php Can Install practical article set up question

Apache

Anywhere   liuxiLzl@163.net
PHP的安装步骤,网上有很多资料,都非常详细。但是,由于Apache,PHP这类自由软件的安装并不象商业软件那样有一个友好的用户界面,许多网友又很少碰上这类东东,所以尽管旁边有一份安装资料,但还是碰上许多问题。我在国内许多关于Linux和php的论坛上,也注意到了不少网友总问相似的问题。因此,我把我所知道的这类问题的解决方法写出来,不对的地方,还请各位指出。
    一、自由软件的安装,无论是在Win32还是在Linux,一般都有README,安装之前,仔细读一读,会有很多收获。
二、安装Apache
  这一步应该比较简单,只要你记得设置httpd.conf里面的BindAddress、ServerName、DocumentRoot ,应该就可以看到熟悉的Apache图标了。BindAddress是指可以接听的IP地址,可以是*、IP地址,也可以是完整的域名。ServerName是主机名,如果没有域名,可以用IP。DocumentRoot为预设的首页位置。修改httpd.conf之后要记得重起Apache。
    三、安装PHP
  这一步问题比较多,归根结底就是两个原因,一个是PHP没有起作用,这是因为httpd.conf中关于PHP部分的设置有问题;另一个问题是PHP启动了,但运行PHP文件的时候有错误,这是因为php.ini没有设置好。
  1、httpd.conf的设置
    在win32下,这几行是不能少的
  ScriptAlias /php "d:/php/php.exe"
  Action application/x-httpd-php "/php"
          AddType application/x-httpd-php .php .php3
          前两行指出PHP脚本解释器的位置,第三行指出PHP脚本要解释的文件后缀。
  如果不是PHP4而是PHP3,把"application/x-httpd-php" 改为 "......httpd-php3",切记。
  前面两行如果没有设置好,将会出现下载或者在页面显示PHP文件的情况。
在Linux中,如果PHP以Apache模块方式运行,那么只添加第三行就可以了,但是在安装的时候就应该注意步骤了,必须先安装PHP,之后 configure Apache的时候,要加上 --activate-module={libphp4.a的路径},然后 make,make install ......

如果要支持预设index.php这类的东西,还要找到这一句: Directory Index index.html ,后面加上 index.php index.php3 ......

这几个步骤完成后,写一个php程序,,应该有一个结果了,呵呵。
   
   2、php.ini的设置
     很多网友安装完php后,总是出现
"X-Powered-By: PHP/4.0.0 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-cache, post-check=0, pre-check=0 Pragma: no-cache Content-type: text/html "
这类东西,我第一次安装PHP4的时候也有这个现象,当时由于PHP4刚出来,网上的资料很少,自己瞎蒙改好了。只要你把
    ;Windows Extensions
这一段内容都用分号注释掉,就可以解决了,因为PHP4已经包含了支持MySQL,GD等等,不象PHP3,在win32下还要把这些dll包含进来。

除了这个问题,还有象session、文件上传等问题,这类问题可以参照 phpinfo() 的执行结果找原因,一般都是没有设定路径,只要在php.ini里面找到相应的设置段,看看还有什么没有设置好,填上就可以了,旁边都有很详细的英文注释。
                             
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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

CakePHP Working with Database CakePHP Working with Database Sep 10, 2024 pm 05:25 PM

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles