# 安装php5

下载

```bash
wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
```

解压

```bash
tar zxf php-5.6.30.tar.gz
cd php-5.6.30
```

安装

```bash
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc  --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif


make && make install
```

配置

```bash
cp php.ini-production  /usr/local/php/etc/php.ini
```

php命令

* /usr/local/php/bin/php -m :查看静态模块
* /usr/local/php/bin/php -i ：查看相关配置

测试php解析

```php
# vim /usr/local/apache/htdocs/index1.php
<?php
  echo "Hello World";
?>
```

同时要修改httpd的配置文件/usr/local/apache/conf/httpd.conf

```bash
# 去掉注释
# ServerName www.example.com:80

Require all denied
# 改成
Require all granted

AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
# 两行下加入
AddType application/x-httpd-php .php    


DirectoryIndex index.html
# 改为
DirectoryIndex index.html index.php
```

> /usr/local/apache/bin/apachectl -t 检查配置文件语法错误
>
> /usr/local/apache/bin/apachectl graceful 加载配置文件
