講解關於centos配置apache+php安裝

來源:互聯網
上載者:User

centos配置apache+php檔案是常用系統檔案,於是我研究了一下關於apache+php的centos配置安裝,這裡我發表一下centos配置安裝個人理解。

centos配置apache+php

首先;

下載軟體;

apachehttp://apache.mirror.phpchina.com/httpd/httpd-2.2.9.tar.gz

php:http://cn.php.net/distributions/php-5.2.6.tar.gz

mysql:http://mysql.ntu.edu.tw/Downloads/MySQL-5.0/mysql-5.0.51a-linux-i686-glibc23.tar.gz

首先

[root@localhost ]# wget http://apache.mirror.phpchina.com/httpd/httpd-2.2.9.tar.gz

--00:47:30--  http://apache.mirror.phpchina.com/httpd/httpd-2.2.9.tar.gz

Resolving apache.mirror.phpchina.com... 221.194.139.225

Connecting to apache.mirror.phpchina.com|221.194.139.225|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 6396996 (6.1M) [application/x-gzip]

Saving to: `httpd-2.2.9.tar.gz.1'

0% [] 36,300    41.3K/s

[root@localhost ]tar zxvf httpd-2.2.9.tar.gz

下邊解壓

httpd-2.2.9/srclib/apr-util/test/abts_tests.h

httpd-2.2.9/srclib/apr-util/test/data/

httpd-2.2.9/srclib/apr-util/test/dbd.c

httpd-2.2.9/srclib/apr-util/test/Makefile.in

httpd-2.2.9/srclib/apr-util/test/Makefile.win

httpd-2.2.9/srclib/apr-util/test/nw_misc.c

httpd-2.2.9/srclib/apr-util/test/nwgnuaputest

此處省略N字.

接著進入

[root@localhost ~]cd httpd-2.2.9下邊編譯apache

[root@localhost httpd-2.2.9]./configure --prefix=/usr/local/apache --enable-track-vars --enable-cgi --with-config-file-path=/usr/local/apache/conf

下邊編譯centos配置這個需要一點時間的。

下邊簡單說說編譯centos配置的這些的意思,

prefix=//usr/local/mysql/apache 指定把apahce安裝到//usr/local/mysql/apache目錄中;

enable-cgi 支援CGI;

with-config-file-path=//usr/local/mysql/apache/conf 指定把apache的配製檔案放在//usr/local/mysql/apache/conf中;比如httpd.confcentos設定檔就在這個目錄中;

enable-track-vars 為啟動cookie的get/post等追蹤功能

差不多編譯好了。會提示apache安裝成功,

[root@localhost ]make; make install //接著輸入編譯這個命令很簡單就是make;make install即可!

接著輸入開啟apache服務。

[root@localhost ] server httpd restart

到此處apache安裝成功

刪除預設頁

rm -f /usr/local/apache/conf.d/welcome.conf即可看到可愛的403錯誤!

centos配置安裝php;
[root@localhost ~]# tar zxvf php-5.2.6.tar.gz //解壓php檔案

[root@localhost ~]# cd php-5.2.6 //進去php安裝目錄

[root@localhost php-5.2.6]#]#./configure --prefix=//usr/local/mysql/php --with-mysql=//usr/local/mysql/mysql --with-apxs2=//usr/local/mysql/apache/bin/apxs --enable-track-vars --enable-force-cgi-redirect --with-config-file-path=//usr/local/mysql/php/etc   //編譯php

安裝:[root@localhost php-5.2.6]#make

[root@localhost php-5.2.6]#make install 

複製php.ini-dist為php.ini,並存放到/usr/local/php目錄下!

[root@localhost php-5.2.6]# cp php.ini-dist /usr/local/php/php.ini

編輯/usr/local/php/php.ini檔案,找到如下的一行

;default_charset = "iso-8859-1"

在這行下面加一行

default_charset = "gb2312

//下邊組合apache+php

找到#AddType application/x-tar .tgz 這行,在下面加一行。前面不要加#號。

AddType application/x-httpd-php .php

找到下面一行在後面加上index.php,這表示網站的預設頁也能夠為index.php 

DirectoryIndex index.html index.html.var index.php 

讓後我們順手下個測試php的頁面吧

編輯vi /usr/www/html/test.php寫入

echo >> <?phpinfo();?> /usr/www/html/test.php即可,到此處php+apache安裝成功

以上介紹centos配置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.