【请问】在Ubuntu上安装配置Apache&PHP,文件内容却直接显示出来
程序员文章站
2022-06-15 23:02:43
...
【请教】在Ubuntu下安装配置Apache&PHP,文件内容却直接显示出来
我按照如下方法(来自http://www.kreny.com/computer/linux/apache.html)在Ubuntu804中配置Apache和PHP都很顺利,但是启动Apache服务后,在主文件夹/var/www/中新建文件info.php 内容是,按理说应该显示关于PHP的信息表格,可是浏览器里就把文件内容显示出来了。请问这是什么问题,怎么解决?
以下安装将静态编译 php 到 apache 中去。
安装流程为:
[Configure apache 1.3.33] --> [编译安装 PHP 4.3.10] ---> [Reconfigure 编译安装 apache 1.3.33] --> [修改 httpd.conf]
这个配置将生成 libmodphp4.a 库,mod_php4.c 和一些相关的文件并且拷贝到 Apache 源程序目录中的 src/modules/php4 目录下。然后用 --activate-module=src/modules/php4/libphp4.a 编译 Apache,Apache 编译系统会生成 libphp4.a 并且将其静态地连接到 httpd 程序中。PostgreSQL 支持也直接包括在这个 httpd 程序中了,因此最终结果是单一的一个包括了所有 Apache 和 PHP 支持的 httpd 可执行文件。
--《PHP手册》--
从错误信息中总结出以上安装过程:
在配置 apache 之前如果首先配置 php 会有以下错误结果:
configure: error: Please run Apache\'s configure or src/Configure program once and try again
因此,首先要将 apache 的 source configure 一下。
安装过程:
# wget http://jp2.php.net/get/php-4.3.10.tar.gz/from/this/mirror
# wget http://sunsite.tus.ac.jp/pub/apache/httpd/apache_1.3.33.tar.gz
# tar -zxvf php-4.3.10.tar.gz
# tar -zxvf apache_1.3.33.tar.gz
# ls -l
Total 8340
drwxr-xr-x 8 mysql games 4096 10 28 01:47 apache_1.3.33
drwxr-xr-x 14 1003 1003 4096 12 15 02:55 php-4.3.10
# cd ./apache_1.3.33
# ./configure --prefix=/usr/local/apache --enable-module=so --enable-module=rewrite --enable-module=speling
Configuring for Apache, Version 1.3.33
+ using installation path layout: Apache (config.layout)
Creating Makefile
Creating Configuration.apaci in src
Creating Makefile in src
+ configured for Linux platform
+ setting C compiler to gcc
+ setting C pre-processor to gcc -E
+ using "tr [a-z] [A-Z]" to uppercase
+ checking for system header files
+ adding selected modules
o rewrite_module uses ConfigStart/End
+ using -lgdbm for DBM support
enabling DBM support for mod_rewrite
+ using system Expat
+ using -ldl for vendor DSO support
+ checking sizeof various data types
+ doing sanity check on compiler and options
Creating Makefile in src/support
Creating Makefile in src/regex
Creating Makefile in src/os/unix
Creating Makefile in src/ap
Creating Makefile in src/main
Creating Makefile in src/modules/standard
# cd ../php-4.3.10
#./configure --with-mysql=/usr/local/mysql --with-apache=/usr/src/apache_1.3.33 --with-zlib-dir --enable-mbstring=all
Generating files
updating cache ./config.cache
creating ./config.status
creating php4.spec
creating main/build-defs.h
creating scripts/phpize
creating scripts/php-config
creating sapi/apache/libphp4.module
creating sapi/cli/php.1
creating main/php_config.h
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------+
| *** NOTE *** |
| The default for register_globals is now OFF! |
| |
| If your application relies on register_globals being ON, you |
| should explicitly set it to on in your php.ini file. |
| Note that you are strongly encouraged to read |
我按照如下方法(来自http://www.kreny.com/computer/linux/apache.html)在Ubuntu804中配置Apache和PHP都很顺利,但是启动Apache服务后,在主文件夹/var/www/中新建文件info.php 内容是,按理说应该显示关于PHP的信息表格,可是浏览器里就把文件内容显示出来了。请问这是什么问题,怎么解决?
以下安装将静态编译 php 到 apache 中去。
安装流程为:
[Configure apache 1.3.33] --> [编译安装 PHP 4.3.10] ---> [Reconfigure 编译安装 apache 1.3.33] --> [修改 httpd.conf]
这个配置将生成 libmodphp4.a 库,mod_php4.c 和一些相关的文件并且拷贝到 Apache 源程序目录中的 src/modules/php4 目录下。然后用 --activate-module=src/modules/php4/libphp4.a 编译 Apache,Apache 编译系统会生成 libphp4.a 并且将其静态地连接到 httpd 程序中。PostgreSQL 支持也直接包括在这个 httpd 程序中了,因此最终结果是单一的一个包括了所有 Apache 和 PHP 支持的 httpd 可执行文件。
--《PHP手册》--
从错误信息中总结出以上安装过程:
在配置 apache 之前如果首先配置 php 会有以下错误结果:
configure: error: Please run Apache\'s configure or src/Configure program once and try again
因此,首先要将 apache 的 source configure 一下。
安装过程:
# wget http://jp2.php.net/get/php-4.3.10.tar.gz/from/this/mirror
# wget http://sunsite.tus.ac.jp/pub/apache/httpd/apache_1.3.33.tar.gz
# tar -zxvf php-4.3.10.tar.gz
# tar -zxvf apache_1.3.33.tar.gz
# ls -l
Total 8340
drwxr-xr-x 8 mysql games 4096 10 28 01:47 apache_1.3.33
drwxr-xr-x 14 1003 1003 4096 12 15 02:55 php-4.3.10
# cd ./apache_1.3.33
# ./configure --prefix=/usr/local/apache --enable-module=so --enable-module=rewrite --enable-module=speling
Configuring for Apache, Version 1.3.33
+ using installation path layout: Apache (config.layout)
Creating Makefile
Creating Configuration.apaci in src
Creating Makefile in src
+ configured for Linux platform
+ setting C compiler to gcc
+ setting C pre-processor to gcc -E
+ using "tr [a-z] [A-Z]" to uppercase
+ checking for system header files
+ adding selected modules
o rewrite_module uses ConfigStart/End
+ using -lgdbm for DBM support
enabling DBM support for mod_rewrite
+ using system Expat
+ using -ldl for vendor DSO support
+ checking sizeof various data types
+ doing sanity check on compiler and options
Creating Makefile in src/support
Creating Makefile in src/regex
Creating Makefile in src/os/unix
Creating Makefile in src/ap
Creating Makefile in src/main
Creating Makefile in src/modules/standard
# cd ../php-4.3.10
#./configure --with-mysql=/usr/local/mysql --with-apache=/usr/src/apache_1.3.33 --with-zlib-dir --enable-mbstring=all
Generating files
updating cache ./config.cache
creating ./config.status
creating php4.spec
creating main/build-defs.h
creating scripts/phpize
creating scripts/php-config
creating sapi/apache/libphp4.module
creating sapi/cli/php.1
creating main/php_config.h
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------+
| *** NOTE *** |
| The default for register_globals is now OFF! |
| |
| If your application relies on register_globals being ON, you |
| should explicitly set it to on in your php.ini file. |
| Note that you are strongly encouraged to read |
相关文章
相关视频
上一篇: PHP学习笔记-字符串操作1