安裝準備:
http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz 下載apr-utilphp
注意事項:wget vim gcc gcc-c++ cmake 這幾個也是安裝 Apache 所須要的小環境 。
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel curl-devel libxslt-devel
yum install gcc-c++ gcc
首先安裝apr
先解壓(略)
./configure --prefix=/usr/local/apr/
make && make install
安裝apr-util (PS:注意前後順序)
先解壓(略)
./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/
make && make install
安裝pcre
先解壓(略)
./configure --prefix=/usr/local/pcre/
make && make install
而後安裝apache
先解壓(略)html
./configure --prefix=/usr/local/apache/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
make && make install
安裝完成 測試apache
cd /usr/local/apache/bin/
./apachectl start 啓動apache
成功顯示 It Works!就表明 服務器已成功!
添加Apache到Linux服務
cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/mysql
mv /etc/rc.d/init.d/apachectl /etc/rc.d/init.d/httpdc++
chkconfig --add httpd #全部開機模式下自啓動sql
chkconfig httpd on #345開機模式下自啓動apache
安裝php7
先解壓(略)
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
出現「/replace/with/path/to/perl/interpreter: bad interpreter: No such file or
#vi /usr/local/apache/bin/apxsvim
第一行的#!/replace/with/path/to/perl/interpreter -w,找到你perl的安裝位置,若是不清楚,能夠用which perl找到,通常在/usr/bin/perl ,因而將第一行改成:#!/usr/bin/perl -w. 再運行php的configure, 一切正常!服務器
make && make install
安裝完成後打開httpd.conf 查找php7
看是否搜索到:LoadModule php7_module modules/libphp7.sophp7
若是沒有搜索到(通常都是能夠搜索到的),就將這段指令添加到httpd.conf配置文件中,使apache能夠加載libphp7.so模塊,並進行php文件的解析。app
在httpd.conf配置文件中再添加一段指令:
<FilesMatch "\.ph(p[2-6]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
這段指令告訴apache,碰到文件名以
.php, .php2, .php3, .php4, .php5, .php6或phtml結尾的文件使用
libphp7.so模塊進行解析
:wq
進行保存退出。
cd /usr/local/apache/htdocs
按 i 鍵進入編輯模式,添加:
<?php
phpinfo();
?>
按Esc鍵回到命令模式,保存退出:
:wq

