一,安裝apache:
# mkdir /vegas # cd /vegas # wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.2.24.tar.gz # tar zxvf httpd-2.2.24.tar.gz /vegas //以上下載解壓apache # cd httpd-2.2.24 # ./configure --prefix=/usr/local/apache --enable-so # make # make install //以上安裝apache # cd /usr/local/apache/conf # cp –a httpd.conf httpd.conf.bak //備份配置文件 # service httpd status //查看自帶httpd服務(wù)狀態(tài) # service httpd stop //停止自帶httpd服務(wù) # /usr/local/apache/bin/apachectl -k graceful //啟動(dòng)httpd服務(wù) # ps -ef | grep httpd //linux下查看apache進(jìn)程 # cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/apache //拷貝apache啟動(dòng)腳本 # vi /etc/sysconfig/iptables //修改防火墻,打開(kāi)80端口,添加到默認(rèn)的22端口這條規(guī)則的下面 -A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT(允許80端口通過(guò)防火墻) # /etc/init.d/iptables restart //重啟防火墻服務(wù)
測(cè)試一下,看出現(xiàn)了it works這幾個(gè)字了不。
二,安裝php:
# cd vegas # wget http://www.php.net/get/php-5.4.13.tar.gz/from/cn2.php.net/mirror # tar zxvf php-5.4.13.tar.gz # cd php-5.4.13 # ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/lib --enable-track-vars --with-xml --with-MySQL # make # make install
三,配置 httpd.conf 讓apache支持PHP:
# vi /usr/local/apache/conf/httpd.conf
找到 AddType application/x-gzip .gz .tgz 在其下添加如下內(nèi)容
AddType application/x-httpd-php .php (.前面有空格)
AddType application/x-httpd-php-source .phps (.前面有空格)
# cp php.ini-development /usr/local/php5/lib/php.ini //copy php配置文件
# /usr/local/apache/bin/apachectl -k graceful //重啟httpd服務(wù)
寫(xiě)一個(gè)php測(cè)試頁(yè)info.php,放到apache/htdocs中。
<?php phpinfo(); ?>;
聯(lián)系客服