四、安装 php #cd /usr/local/src
# tar xzvf php-5.3.8.tar.gz # cd php-5.3.8
php 编译选项: './configure' '--prefix=/usr/local/php' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-config-file-path=/usr/local/php/etc' '--enable-ftp' '--enable-zip' '--with-mysql=/usr/local/mysql' '--with-png-dir' '--with-iconv'
'--with-jpeg-dir'
'--with-freetype-dir=/usr/local/freetype'
'--with-lib
xml-dir=/usr/local/libxml2' '--with-zlib-dir=/usr/local/zlib' '--with-gd' '--enable-gd-native-ttf' '--enable-calendar' '--with-curl=/usr/local/libcurl' '--enable-sockets' '--with-pear' '--enable-exif'
'--enable-mbstring'
'--without-pdo-sqlite' '--without-sqlite' # make # make install 整合 php 和 apache: (1)在 httpd.conf 文件尾添加: AddType application/x-httpd-php .php .phtml AddType application/x-httpd-php-source .phps (2)打开 Apache 配置文件(httpd.conf) ,找到 DirectoryIndex 入口,确定在行的末尾有 index.php。 DirectoryIndex index.html index.html.var index.php (3) 通过使用下面的命令将 php.ini-development 复制到/ect/php.ini 文件夹下。 cp php.ini-development /etc/php.ini. **查看 php 是否安装成功,及其与 apache 是否整合成功: 在/usr/local/apache2/htdoc 中添加 index.php,在 body 中写入,再用浏览器 访问本机,看能否正确输出 php 的信息。 五、一些可能的错误及其解决
方案 1. 安装 apache 时安装成功后,启动时出现以下
问题提示:
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName 解决办法非常简单: #vim /web/apache/conf/httpd.conf (在这里/
web/apahce 是我安装 apache 的目录, 你默认安装的话应该是/usr/local/apache2/icons) 找到#ServerName example:80 把#去掉,再重启 apache 即可没事了。