1. 程式人生 > >linux 安裝apache 2.4.9+php 7.0.28

linux 安裝apache 2.4.9+php 7.0.28

apache apache 2.4.9 php php 7.0.28 安裝apache 2.4支持php7

安裝準備工作
yum install -y apr- gcc- libpcre- pcre- openssl-*
由於系統包中的curl版本低不支持,所以需要手動下載安裝
wget https://curl.haxx.se/download/curl-7.59.0.tar.gz
tar -xf curl-7.59.0.tar.gz
cd curl-7.59.0
./configure
make && make install
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.3.tar.gz
tar -xf libmcrypt-2.5.3.tar.gz
cd libmcrypt-2.5.3
./configure
make && make install

wget http://mirrors.shu.edu.cn/apache//apr/apr-1.6.3.tar.gz
mkdir /usr/local/apr
tar -xf apr-1.6.3.tar.gz
cd apr-1.6.3
./configure --prefix= /usr/local/apr
make && make install
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
mkdir /usr/local/apr-util

tar -xf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix= /usr/local/apr-util
make && make install

安裝apache
wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.29.tar.gz
tar -xf httpd-2.4.29.tar.gz
mv httpd-2.4.29 httpd
cd httpd
./configure --prefix=/usr/local/apache2/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --enable-so --enable-deflate --enable-expires --enable-headers --enable-ssl --enable-rewrite --enable-mpms-shared=all --with-mpm=prefork --enable-mods-shared=most

make && make install

安裝php

wget http://cn2.php.net/distributions/php-7.0.28.tar.gz
tar -xf php-7.0.28.tar.gz
mv php-7.0.28 php
cd php
./configure --prefix=/usr/local/php/ --with-apxs2=/usr/local/apache2/bin/apxs --enable-pdo --with-pdo-mysql --with-mysql-sock --enable-xml --with-libxml-dir --enable-sockets --with-curl --with-gd --enable-gd-native-ttf --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-mcrypt --with-openssl --with-mhash --enable-zip --enable-mbstring --enable-mbregex --with-iconv --enable-static

make && make install

修改配置:
修改apache httpd.conf
在195行去除“#” 修改為:ServerName localhost:80
在253行中添加index.php
DirectoryIndex index.php index.html
在390行後面添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

配置php 首頁index.php
在/usr/local/apache2/htdocs 中創建index.php
vim index.php
將以下內容輸入文件中
<?php
phpinfio();
?>
保存退出。
啟動httpd服務
/usr/local/apache2/bin/apachectl start

PHP就配置好了。

linux 安裝apache 2.4.9+php 7.0.28