apache與php安裝

來源:互聯網
上載者:User

標籤:pen   module   pad   unp   host   curses   htm   .so   tar   

安裝庫檔案

yum install -y pcre pcre-devel apr apr-deve

安裝apache

cd /usr/local/src/httpd-2.4.23

Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.

 

wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.5.2.tar.gz

wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.5.4.tar.gz

 

[[email protected] src]# tar -zxf apr-1.5.2.tar.gz -C httpd-2.4.23/srclib/
[[email protected] src]# tar -zxf apr-util-1.5.4.tar.gz -C httpd-2.4.23/srclib/

[[email protected] srclib]# mv apr-1.5.2/ apr
[[email protected] srclib]# mv apr-util-1.5.4/ apr-util

./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre

configure: error: in `/usr/local/src/httpd-2.4.23/srclib/apr‘:
configure: error: no acceptable C compiler found in $PATH

#安裝gcc

yum -y install gcc

#重新編譯

mod_deflate has been requested but can not be built due to prerequisite failures

#安裝

yum install  zlib-devel openssl-devel

#重新編譯,編譯通過

make && make install

##安裝php

wget http://cn2.php.net/get/php-5.6.28.tar.gz/from/this/mirror

#依賴包安裝,可以在apache安裝前進行安裝

yum  install  -y  gcc  gcc-c++    make  zlib  zlib-devel  pcre  pcre-devel    libjpeg  libjpeg-devel  libpng  libpng-devel  freetype  freetype-devel  libxml2  libxml2-devel  glibc  glibc-devel  glib2  glib2-devel  bzip2  bzip2-devel  ncurses  ncurses-devel  curl  curl-devel    openssl  openssl-devel gd gd-devel libicu libicu-devel autoconf libevent libevent-devel   libmcrypt libmcrypt-devel
#安裝
 

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc  --with-mysql=/usr/local/mysql --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 --disable-ipv6

 

configure: error: mcrypt.h not found. Please reinstall libmcrypt.
#安裝

wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

tar –xzf libmcrypt-2.5.8.tar.gz

[[email protected] libmcrypt-2.5.8]# ./configure

make && make install

#重新編譯php

error: Cannot find libmysqlclient_r under /usr/local/mysql.

ln -s libmysqlclient.so.20.3.3 libmysqlclient_r.so  (mysql5.7.16)

#編譯動過

make && make install

 

apache與php結合

vim /usr/local/apache2/conf/httpd.conf
#找到
AddType application/x-gzip .gz .tgz#在下面添加
AddType application/x-httpd-php .php

#找到

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>
#修改

<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php
</IfModule>

#

#ServerName www.example.com:80
#修改

#測試lamp是否安裝成

#檢驗設定檔是否正確

[[email protected] conf]# /usr/local/apache2/bin/apachectl -t
Syntax OK
#啟動apache

/usr/local/apache2/bin/apachectl  start

#查看是否啟動

[[email protected] conf]# netstat -lnp |grep httpd
tcp        0      0 :::80                       :::*                        LISTEN      80644/httpd 

[[email protected] conf]# curl localhost
<html><body><h1>It works!</h1></body></html>

#php測試

[[email protected] htdocs]# vim 1.php

<?php    echo "php解析正常";?>
 

[[email protected] htdocs]# curl localhost/1.php
php解析正常

apache與php安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.