Linux下Apache+PHP+MySql

LinuxApache+PHP+MySql
附加zlib+freetype+libpng+jpeg+GD安裝php

 

安裝順序:Apache—MySql—zlib—freetype—libpng—jpeg—zend—GD—PHPhtml

 

.  Apache安裝mysql


在以下頁面下載apachefor Linux 的源碼包
http://www.apache.org/dist/httpd/

tar –zxvf httpd-2.0.59.tar.gz                                           
linux

cd httpd-2.0.59sql

./configure --prefix=/php/apache2.0.59 --enable-module=so      shell

make數據庫

make installapache

 

安裝apache/php/apache2.0.59  並配置apache支持dso方式安全

配置httpd.conf
vi /php/apache2.0.59/conf/httpd.conf
app

 

DocumentRoot "/home/httpd/html/" 此處爲html文件主目錄

同上

Options FollowSymLinks MultiViews 爲安全起見,去掉"Indexes"

 

 DirectoryIndex default.php default.phtml default.php3 default.html default.htm

 

設置apache的默認文件名次序
 

AddType application/x-httpd-php .php .phtml .php3 .inc

AddType application/x-httpd-php-source .phps

設置php文件後綴

存盤退出


 
自動啓動apache
 vi /etc/rc.d/rc.local
 
在最後一行加入
  /php/apache2.0.59/bin/apachectl start

 

 

. Mysql安裝

.下載mysql5(從http://www.mysql.com下載二進制版的Mysql安裝包,這個MYSQL是二進制版的,不用編譯)

 在你須要安裝mysql的目錄下解壓此文件,此處安裝在/php目錄下

cd/php

chmod 755 mysql-5.0.45-linux-i686-tar.gz

tar xfz mysql-5.0.45-linux-i686-tar.gz         
 
groupadd mysql                 // 創建mysql

useradd mysql -g mysql                    //創建mysql用戶而且加入到mysql組中 

cp /php/php/mysql5.0.45/support-files/my-medium.cnf /etc/my.cnf
//目錄下有4個模版文件,咱們選擇其中一個座位Mysql的配置文件,覆蓋/etc/my.cnf(系統默認的配置,其中設置了性能參數和Mysql的一些路徑參數

 

cd /php/mysql5.0.45

./scripts/mysql_install_db --user=mysql
//初試化表而且規定用mysql用戶來訪問,初始化表之後就開始給mysqlroot用戶設定訪問權限

 

chown -R root .                   //設定root能訪問/php/mysql5.0.45  

chown -R mysql data
//設定mysql用戶能訪問/usr/local/mysql/data ,裏面存的是mysql的數據庫文件.這個目錄是在/etc/my.cnf中有配置,在mysql_install_db時產生。

 

chown -R mysql data/.           //設定mysql用戶能訪問/php/mysql5.0.45 /data/mysql下的全部文件 

 

chgrp -R mysql .                      //設定mysql組可以訪問/php/mysql5.0.45  

 

/php/mysql5.0.45/bin/mysqld_safe --user=mysql &

//運行mysql,若是沒有問題的話,應該會出現相似這樣的提示:[1] 42264
  # Starting mysqld daemon with databases from /usr/local/mysql/var
若是出現 mysql ended這樣的語句,表示Mysql沒有正常啓動,你能夠到log中查找問題,Log文件的一般在/etc/my.cnf中配置。大多數問題是權限設置不正確引發的。

 

/php/mysql5.0.45/bin/mysqladmin -u root password yourpassword
 // 用如上命令修改MYSQL密碼

 

 /bin/sh -c 'cd /php/mysql5.0.45/;./bin/safe_mysqld &'

  編輯/etc/rc.d/rc.local 在最後加入如上代碼,設置mysql可以自動啓動:

  bin/safe_mysqld                            //啓動mysqld服務
  netstat –atln                                  
//查看3306端口是否打開

 

  若是要重啓mysql
  pgrep –l mysqld                           
//查看mysql進程ID

  Kill   進程ID       
  bin/safe_mysqld                           
//從新啓動mysqld服務

3、GD庫類安裝

gd-2.0.33.tar.gz
http://www.boutell.com/gd/

jpegsrc.v6b.tar.gz
http://www.ijg.org/

libpng-1.2.7.tar.tar
http://sourceforge.net/projects/libpng/

zlib-1.2.2.tar.gz
http://sourceforge.net/projects/zlib/
http://www.winimage.com/zLibDll/

freetype-2.1.9.tar.gz
http://sourceforge.net/projects/freetype/

安裝步驟:
先安裝zlib,freetype,libpng,jpeg,再裝GD

1.
zlib
tar zxvf zlib- zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure  --prefix=/php/ zlib-1.2.3                         // zlib-1.2.3
安裝路徑      
make
make install

2.
安裝libpng
tar zxvf libpng-1.2.7.tar.tar
cd libpng-1.2.7
cd scripts/
mv makefile.linux ../makefile
cd ..
make
make install
注意,這裏的makefile不是用./configure生成,而是直接從scripts/裏拷一個

3.
安裝freetype
tar zxvf freetype-2.1.9.tar.gz
cd freetype-2.1.9
./configure --prefix=/php/freetype-2.3.5                        //freetype
安裝路徑          
make
make install

4.
安裝Jpeg
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b/
./configure ?enable-shared
make
make test
make install
注意,這裏configure必定要帶?enable-shared參數,否則,不會生成共享庫

編譯jpeg時報錯

/usr/bin/install -c -m 644 ./cjpeg.1
/usr/local/man/man1/cjpeg.1
/usr/bin/install: cannot create regular file
`/usr/local/man/man1/cjpeg.1': No such file or directory

缺乏/usr/local/man目錄及man1子目錄,新建後從新編譯。

shell> mkdir /usr/local/man
shell> mkdir /usr/local/man/man1

5.安裝GD
tar zxvf gd-2.0.35.tar.gz
cd  gd-2.0.35                                                   
./configure --with-png --with-freetype --with-jpeg --prefix=/php/ gd-2.0.35  // gd
安裝路徑
make insta

 

 

 

 

.PHP安裝


在以下頁面下載phpfor Linux 的源碼包
http://www.php.net/downloads.php ;
存至/home/wj目錄
命令列表:
cd /php
tar -zxvf php-5.0.4.tar.gz

       ./configure --prefix=/php/php-5.2.3                                        //php安裝路徑

       --with-apxs2=/php/apache2.0.59/bin/apxs                            //Apache安裝路徑

       --with-config-file-path=/usr/local/bin

       --with-mysql=/php/mysql5.0.45                                             //mysql安裝路徑

          --with-freetype-dir=/php/freetype-2.3.5                                 //freetype安裝路徑

          --with-png --with-zlib=/php/zlib-1.2.3                                    //zlib安裝路徑

          --with-gd=/php/gd-2.0.35                                                     //gd安裝路徑

          --with-png-dir=/usr

       --with-jpeg-dir=/usr
       --with-xml

       --enable-track-vars
       --enable-mbstring=all

       --enable-gd-native-ttf

       --enable-calendar

       make
make install

cp php.ini-dist /usr/local/lib/php.ini

全部安裝完後,從新啓動Apache

/bin/php5.0.2.3/bin/safe_mysqld

相關文章
相關標籤/搜索