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>
將該行改爲:
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
找到:
#ServerName www.example.com:80
修改爲:
ServerName localhost:80
5. 測試解析php
vim /usr/local/apache2/htdocs/1.php
寫入:
<?php
echo "php解析正常";
?>
保存後,繼續測試: