#apache
| 代碼如下 |
複製代碼 |
./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite
make
make install
cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
cd /etc/rc.d/init.d
#vi httpd
#在檔案首部#!/bin/bash行下,加入以下幾行
# chkconfig: 2345 50 40
# description: This is a Internet www Server
#說明一下,直接調用chkconfig是不行的,必須加上以上兩行。
#description是描述這個服務用的,一定要寫上對服務的描述,而且不可以是中文的,
#chkconfig: 第一組數字是系統運行級2345表示的是將要設為啟動的系統運行層級
#第二個數字是優先順序,00優先順序最高,當然考慮到依賴性,你的服務的優先順序不宜過高
#如果,比自己依賴的服務的優先順序更高,那麼您的服務將無法正常啟動
#第三組數字就是殺死服務的優先順序
chkconfig --add httpd
|
#mysql
| 代碼如下 |
複製代碼 |
./configure --prefix=/usr/local/mysql --localstatedir=/mydata/web/mysql --with-charset=utf8 --with-extra-charsets=all
make
make install
cp support-files/my-medium.cnf /etc/my.cnf
#建立mysql使用者和使用者組
groupadd mysql
useradd -g mysql mysql
chown -R root /usr/local/mysql
chgrp -R mysql /usr/local/mysql
chown -R mysql /var/mysql
#初始化許可權資料庫,並不需要啟動mysql
scripts/mysql_install_db --user=mysql
#啟動mysql, "&"是後台運行
/usr/local/mysql/bin/mysqld_safe --user=mysql&
#更改root密碼
/usr/local/mysql/bin/mysqladmin -u root -p password "123456"
#設定為開機自啟動
cd /etc/rc.d/init.d
cp /usr/local/mysql/share/mysql/ mysql.server mysqld
chmod +x mysqld
chkconfig --add mysqld
|
#PHP
| 代碼如下 |
複製代碼 |
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-apxs2=/usr/local/apache/bin/apxs --with-gd --with-zlib --with-png --with-freetype-dir --with-config-file-path=/usr/local/php/etc --enable-gd-native-ttf --with-ttf --enable-memory-limit --enable-zend-multibyte --disable-ipv6 --disable-path-info-check --with-iconv --disable-debug --with-mail --enable-mbregex --with-curl --enable-mbstring=all --enable-zip --enable-exif --with-jpeg-dir=/usr/lib64/
make
make install
|
#配置apache
| 代碼如下 |
複製代碼 |
# vi /usr/local/apache/conf/httpd.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
|
#開放80連接埠
| 代碼如下 |
複製代碼 |
| #iptables -A INPUT -i eth0 -p TCP --dport 80 -j ACCEPT |
四 、整合apache 與php
| 代碼如下 |
複製代碼 |
# vi /usr/local/apache2/conf/httpd.conf
|
在最後一行加上:
| 代碼如下 |
複製代碼 |
| AddType application/x-httpd-php .php |
尋找:(設定 WEB 預設檔案)
| 代碼如下 |
複製代碼 |
DirectoryIndex index.html
|
替換為:
| 代碼如下 |
複製代碼 |
| DirectoryIndex index.php index.html index.htm //在 WEB 目錄不到預設檔案,httpd 就會執行 /var/www/error/noindex.html |
找到這一段:
| 代碼如下 |
複製代碼 |
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride none |
更改為AllowOverride all
允許apache rewrite
儲存httpd.conf,退出。
| 代碼如下 |
複製代碼 |
|
# /usr/local/apache2/bin/apachectl restart //重啟 Apache |
五、 測試
| 代碼如下 |
複製代碼 |
| vi /usr/local/apache2/htdocs/test.php |
新增加下面一行,並儲存。
| 代碼如下 |
複製代碼 |
|
<?php phpinfo(); ?>
# chmod 755 /usr/local/apache2/htdocs/phpinfo.php |
用瀏覽器開啟 http://locahost/test.php
或者 http://本機ip/test.php
(如ip為192.168.4.2 則 http://192.168.4.2/test.php)
當看到php頁面時表示成功!