1.安裝mysql
cd /usr/src/
wget http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
tar zxvf /usr/src/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
mv mysql-5.1.40-linux-x86_64-icc-glibc23 /usr/local/mysql
cd /usr/local/mysql/
mkdir -p /data/mysql/ #建立mysql資料庫存放位置
chown -R mysql:mysql /data/mysql/ #修改屬主屬組
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ #初始化

出現這個錯誤 需要vim/etc/hosts 中添加 127.0.0.1 + 主機名
出現這個錯誤 需要安裝compat-linstdc++ (
Installing MySQL system tables...
OK
Filling help tables...
OK
cp support-files/mysql.server /etc/init.d/mysqld #mysq.server是啟動檔案
cp support-files/my-huge.cnf /etc/my.cnf
chmod 755 /etc/init.d/mysqld
vim /etc/init.d/mysqld #修改datadir[資料庫檔案路徑],basedir[mysql安裝路徑]
chkconfig --add mysqld
chkconfig mysqld on #開機啟動
啟動時出現此錯誤Starting MySQL.Manager of pid-file quit without updating fi[FAILED] 原因 是 /etc/my.conf 沒有指定datadir
2. 安裝apache
·/usr/local/apache2/bin/apachectl -M:檢視安裝了哪些子產品
·/usr/local/apache2/bin/apachectl -t:檢查文法錯誤
·/usr/local/apache2/bin/apachectl -l:檢視安裝的庫檔案
·/usr/local/apache2/bin/apachectl graceful:重新加載配置
·/usr/local/apache2/htcocs 首頁存放目錄
·/usr/local/apache2/bin/apachectl 啟動檔案目錄
·/usr/local/apache2/conf 配置檔案路徑
wget http://syslab.comsenz.com/downloads/linux/httpd-2.2.16.tar.gz
tar zxvf httpd-2.2.16.tar.gz
cd httpd-2.2.16
./configure prefix=/usr/local/apache2 --with-prce --enable-mods-shared=most
#pcre識别正規表達式,shared動态共享子產品
make && make install
httpd.conf中 :
Listen 80 #監聽80端口
ServerAdmin [email protected] #管理者郵箱
ServerName localhost:80 #主機名
DocumentRoot "/usr/local/apache2/htdocs" #首頁檔案放的位置
ErrorLog "logs/error_log" #定義錯誤日志
LogLevel warn #定義日志級别 warn的錯誤才記錄
AddType application/x-httpd-php .php #支援php
DirectoryIndex index.html index.php #自動尋找首頁檔案
3. 安裝php
wget http://cn2.php.net/distributions/php-5.3.28.tar.gz
tar zxvf php-5.3.28.tar.gz
cd php-5.3.28
./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
make && make install
4.配置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>
将該行改為:
DirectoryIndex index.html index.htm index.php
#ServerName www.example.com:80
修改為:
ServerName localhost:80
5. 測試解析php
vim /usr/local/apache2/htdocs/1.php
寫入:
<?php
echo "php解析正常";