以下的文章主要介紹的是在linux操作系統之下對Mysql+php5+apache安裝手記的具體描述,我前兩天在相關網站看見Mysql+php5+apache安裝手記的資料,覺得挺好,於是就拿出來供大家分享。
下載官方推薦的穩定版本httpd-2.2.3.tar.gz,
安裝apache2
- #./configure –prefix=/usr/local/apache2 –enable-module=alias –enable-module=most \
- –enable-module=vhost_alias –enable-shared=vhost_alias –enable-module=so –enable-shared=max
- # make;make install
下載目前最新穩定版本mysql-standard-5.0.27-linux-i686-glibc23.tar.gz
無需安裝,解壓後移至/usr/local/mysql.
# groupadd mysql #建立mysql組
# useradd mysql -g mysql #建立mysql用戶並且加入到mysql組中
# cd /usr/local/mysql
然後設置權限
- # chown -R root . #設定root能訪問/usr/local/mysql
- # chown -R mysql data #設定mysql用戶能訪問/usr/local/mysql/data ,裡面存的是mysql的數據庫文件
- # chown -R mysql data/. #設定mysql用戶能訪問/usr/local/mysql/data下的所有文件
- # chown -R mysql data/mysql/. #設定mysql用戶能訪問/usr/local/mysql/data/mysql下的所有文件
- # chgrp -R mysql . #設定mysql組能夠訪問/usr/local/mysql
運行mysql:
- # /usr/local/mysql/bin/mysqld_safe –user=mysql &
修改root密碼,默認為空:
- /usr/local/mysql/bin/mysqladmin -u root password ‘newpassword’
MYSQL+php5+apache安裝完成
下載最新穩定版本php-5.1.6.tar.gz,
1. 安裝zlib (安裝libpng和gd前需要先安裝zlib),
- # tar zxvf zlib-1.2.3.tar.gz
- # cd zlib-1.2.3
- # ./configure
- # make;make install
2. 安裝libpng,
- # tar zxvf libpng-1.2.12.tar.gz
- # cd libpng-1.2.12
- # ./configure
- # make;make install
3. 安裝freetype,
- # tar zxvf freetype-2.2.1.tar.gz
- # cd freetype-2.1.10
- # ./configure –prefix=/usr/local/freetype
- # make;make install
4. 安裝jpeg,
- # tar zxvf jpegsrc.v6b.tar.gz
- # cd jpeg-6b
- # mkdir /usr/local/jpeg
- # mkdir /usr/local/jpeg/bin
- # mkdir /usr/local/jpeg/lib
- # mkdir /usr/local/jpeg/include
- # mkdir /usr/local/jpeg/man
- # mkdir /usr/local/jpeg/man/man1
- # ./configure –prefix=/usr/local/jpeg –enable-shared –enable-static
- # make;make install
5. 安裝gd,
- # tar zxvf gd-2.0.33.tar.gz
- # cd gd-2.0.33
- # ./configure –prefix=/usr/local/gd –with-jpeg=/usr/local/jpeg –with-freetype=/usr/local/freetype –with-png –with-zlib
Mysql+php5+apache編譯過程中會看到如下信息
** Configuration summary for gd 2.0.33:
- Support for PNG library: yes
- Support for JPEG library: yes
- Support for Freetype 2.x library: yes
- Support for Fontconfig library: no
- Support for Xpm library: no
- Support for pthreads: yes
可以看到png 、 jpeg 、 freetype都已經安裝上了
- # make
- # make install
6. 正式安裝php
- # tar zxvf php-5.1.6.tar.gz
- # cd php-5.1.6
- # ./configure –prefix=/usr/local/php5 –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql=
/usr/local/mysql –with-gd –with-zlib –with-png –with-jpeg –with-freetype
–enable-sockets –with-iconv –enable-mbstring –enable-track-vars –enable-force-cgi-redirect –with-config-file-path=/usr/local/php5/etc
7.整合php和apache
- cp php.ini-dist /usr/local/php5/etc/php.ini
- vi /usr/local/php5/etc/php.ini
將extension=php_mysql.dll前面的#去掉
8. 安裝ZendOptimizer,
- # tar zxvf ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz
- # cd ZendOptimizer-3.0.1-linux-glibc21-i386
- # ./install.sh
安裝操作: [ok] -> [EXIT] -> [YES] -> [/httpd/zend] -> [/httpd/apache/conf] -> [yes] -> [OK] -> [OK] -> [NO]
遇到的一些錯誤解決:
1.php5在configure時提示:configure: error: mysql configure failed.,只用–with-mysql參數提示:Cannot find MySQL header files under yes,去掉–with-mysql參數可以安裝,php5將無法連接mysql+php5+apache,頁面提示為:Fatal error: Call to undefined function mysql_connect()。
查閱了一下,發現是mysql5對應的版本不對導致的,換個版本就可以了。
我用mysql-standard-5.0.27-linux-i686.tar.gz時會提示,換了mysql-standard-5.0.27-linux-i686-glibc23.tar.gz後就正常了。
2.重裝mysql後啟動出錯,提示:
- Starting mysqld daemon with databases from /usr/local/mysql/data
- STOPPING server from pid file /usr/local/mysql/data/xmcncn.pid
- 061103 15:25:32 mysqld ended
請教高手gump,解決方法:
- touch /tmp/mysql.sock
- killall -9 mysqld
- /usr/local/mysql/bin/mysqld_safe -user=mysql &
成功啟動
PS:偶是新手,當初找齊這些軟件都化了一整天時間,特別是幾個小軟件比較難找,現在全部列出來了。測試裝的時候也遇到了不少問題,在gump同志的幫助下解決了不少。我站上本來轉載了好幾篇安裝的文章,有的版本較舊,有的不太全面,所以把這次安裝過程寫出來,以後安裝也就方便了:)希望也對一些新手有幫助。