Red Hat 9.0 下安裝 LAMP+Python+GD庫

Red Hat 9.0 下安裝 Apache 2.0.52 + Php 4.3.9 + MySQL 4.0.12 + Python 2.3.4 + Mysql-python 1.0.0 + GD庫
爲人民服務,分享安裝經驗! 
說明:
    安裝順序:
        MySQL 4.0.12
        GD庫的所有軟件
        Apache 2.0.52
        Php 4.3.9
        Python 2.3.4
        Mysql-python 1.0.1
一.    安裝MySQL
說明:爲了保證能順利安裝MySQL,本文采用的RPM包的形式來安裝MySQL。(也是爲了減少安裝的複雜性)
所需軟件:
MySQL-server-4.0.12-0.i386.rpm
MySQL-client-4.0.12-0.i386.rpm
MySQL-devel-4.0.12-0.i386.rpm
MySQL-shared-4.0.12-0.i386.rpm
    安裝過程:
            [test@redhat9]#rpm –ihv MySQL-server-4.0.12-0.i386.rpm
            [test@redhat9]#rpm –ihv MySQL-client-4.0.12-0.i386.rpm
            [test@redhat9]#rpm –ihv MySQL-devel-4.0.12-0.i386.rpm
            [test@redhat9]#rpm –ihv MySQL-shared-4.0.12-0.i386.rpm
            或者用一個命令同時安裝這4個rpm包,如下:(每個包名之間用空格相隔)
            [test@redhat9]#rpm –ihv MySQL-server-4.0.12-0.i386.rpm MySQL-client-4.0.12-0.i386.rpm MySQL-devel-4.0.12-0.i386.rpm MySQL-shared-4.0.12-0.i386.rpm
            用些方法安裝mysql後,數據庫文件默認的位置是 /var/lib/mysql ,可通過更改 mysql的配置文件來改變這個位置

    測試:
        安裝成功之後會在 /etc/init.d/ 這個目錄下有個mysql的啓動控制腳本 mysql,用這個腳本可以控制mysql服務器的啓動和停止 如 ./mysql start或 ./mysql stop。下面看看mysql運行是否正常
        [test@redhat9]#mysql
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 116 to server version: 4.0.12
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql>

    如果出現以上信息,說明mysql運行正常。可以對其進行操作了。關於詳細的mysql使用方法,請參考MySQL的中文使用手冊

    附:源代碼安裝(不做詳細說明)
#源代碼安裝
./configure --prefix=/usr/local/mysql --with-pthread
make
make install
scripts/mysql_install_db
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld
cd /usr/local
chmod 750 mysql -R
chgrp mysql mysql -R
chown mysql mysql/var -R
cd /usr/local/mysql/libexec
cp mysqld mysqld.old
strip mysqld
/sbin/chkconfig --add mysqld
/sbin/chkconfig --level 345 mysqld on
/sbin/service mysqld start
netstat -atln
ln -s /usr/local/mysql/bin/mysql /sbin/mysql
ln -s /usr/local/mysql/bin/mysqladmin /sbin/mysqladmin
mysqladmin -u root password "12345678"
mysql -u root -p
mysql>use mysql;
mysql>delete from user where password="";
mysql>flush privileges;
mysql>quit;

#可能會用到下列操作
#echo /usr/local/mysql/lib/mysql >> /etc/ld.so.conf
#ldconfig -v | grep libmysqlclient
#/etc/ld-elf.so.conf
# ldconfig

二.    安裝GD庫

所需軟件:
gd-2.0.28.tar.gz
gd-devel-1.8.4-11.i386.rpm(gd-devel-2.0.28-1 RPM for i386  De Fedora Core Development - i386)
freetype-2.1.3-6.i386.rpm
freetype-devel-2.1.3-6.i386.rpm
libpng-1.2.2-16.i386.rpm
libpng-devel-1.2.2-16.i386.rpm
zlib-1.1.4-8.i386.rpm
zlib-devel-1.1.4-8.i386.rpm
jpegsrc.v6b.tar.gz
如果你係統中已有上述軟件的一個或多個,則不用再裝安裝,查看方法(限RPM包),例:
[test@redhat9]#rpm –qa |grep zlib
以上用RPM包安裝的軟件也可用源代碼形式安裝,效果相同。

安裝過程:
第一步:安裝GD庫基本包
[test@redhat9]#rpm -ivh gd-devel-1.8.4-11.i386.rpm

第二:安裝zlib
    [test@redhat9]#rpm –ihv zlib-1.1.4-8.i386.rpm zlib-devel-1.1.4-8.i386.rpm

第三:安裝 libpng
[test@redhat9]#rpm –ihv zlib-1.1.4-8.i386.rpm libpng-1.2.2-16.i386.rpm zlib-devel-1.1.4-8.i386.rpm

第四:安裝freetype
[test@redhat9]#rpm –ihv freetype-2.1.3-6.i386.rpm libpng-devel-1.2.2-16.i386.rpm

第五步:安裝 jpegsrc(源代碼安裝)
    [test@redhat9]#tar zxvf jpegsrc.v6b.tar.gz
    [test@redhat9]#cd jpeg-6b
    [test@redhat9]#./configure
    [test@redhat9]#make
    [test@redhat9]#make install-headers
    [test@redhat9]#make install-lib
    [test@redhat9]#make install

第六步:安裝GD庫
[test@redhat9]#tar zxvf gd-2.0.28.tar.gz
[test@redhat9]#cd gd-2.0.28
[test@redhat9]#./configure --with-png=/usr/local --with-jpeg=/usr/local
[test@redhat9]#make
[test@redhat9]#make install

安裝完成,如果安裝過程出現錯誤,可能是缺少某個軟件包,安裝上相應的軟件包即可

三.    安裝Apache
所需軟件:
    httpd-2.0.52.tar.gz

安裝過程:
        [test@redhat9]#tar zxvf httpd-2.0.52.tar.gz
[test@redhat9]#cd httpd-2.0.52
[test@redhat9]#./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=most
[test@redhat9]#make
[test@redhat9]#make install
        /*---配置Apache---*/
[test@redhat9]#vi /usr/local/apache2/conf/httpd.conf
(1)尋找Add Type application/x-tar .tgz 在下面添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
(2)顯示中文,修改: AddDefaultCharset gb2312
(3)修改ServerAdmin [email protected]
(4)改變HTML文件主目錄:DocumentRoot "/home/httpd/html/"
(5)Options FollowSymLinks MultiViews 爲安全起見,去掉"Indexes"
(6)修改Apache主機地址:ServerName localhost
(7)設置apache的默認文件名次序DirectoryIndex default.php default.phtml default.php3 default.html default.htm
(8)設置php文件後綴
AddType application/x-httpd-php .cgis .php .phtml .php3 .inc
AddType application/x-httpd-php-source .phps
        (9)重新啓動Apache:
    [test@redhat9]#/usr/local/apache2/bin/apachectl restart
(10)將Aapche添加到系統服務中
    a.查看apache服務是否已在系統中
        [test@redhat9]#/sbin/chkconfig –list |grep httpd
        如果出現以下信息,則說明此Apache已被添加到服務服務中了,可略過此步聚
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
            b.添加Aapche到系統啓動菜單
                [test@redhat9]#cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
                [test@redhat9]#vi /etc/rc.d/init.d/httpd
在httpd文件的第三行,插入以下兩句話(要有#號):
# chkconfig: 2345 77 19
# description: Starts and stops the Apache HTTP Server.
確保httpd爲可執行文件:
[test@redhat9]#chmod +x /etc/rc.d/init.d/httpd
將httpd添加到系統服務中:
[test@redhat9]#chkconfig --add httpd
查看apache服務是否已在系統中
[test@redhat9]#chkconfig --list
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
c.說明:
httpd在運行級 2, 3, 4, 5 啓動,啓動優先權爲77,停止優先權爲19。
四.    安裝PHP
所需軟件:
php-4.3.7.tar.gz
安裝過程:
[test@redhat9]#tar -zxvf php-4.3.9.tar.gz
[test@redhat9]#cd php-4.3.9
[test@redhat9]#./configure    --prefix=/usr/local/php /
    --with-apxs2=/usr/local/apache2/bin/apxs /
--with-config-file-path=/usr/local/lib /
--with-jpeg-dir=/usr/local /
--with-png-dir=/usr/local /
--with-gd=/usr/local /
--with-zlib-dir=/usr/local /
--with-ttf /
--with-curl
--with-xml /
--with-mysql /
--enable-ftp /
--enable-memory-limit /
--enable-sockets /
--enable-debug=no
--enable-trace-vars /
    [test@redhat9]#make
    [test@redhat9]#make install
    [test@redhat9]#cp php.ini-dist /usr/local/lib/php.ini
    [test@redhat9]#vi /usr/local/lib/php.ini
                        把 #register-globals = Off
                        改爲 register-globals = On
    錯誤處理:
a.    如果連接mysql出現:mysql.sock 這樣的錯誤,那麼請修改:php.ini文件:
mysql.default_socket = /var/lib/mysql/mysql.sock
        b.    如果出現如下字樣的錯誤,請修改 gd.c 文件,然後重新編譯
In function `zm_deactivate_gd':
ext/gd/gd.c:385: undefined reference to `gdFreeFontCache'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php]Error 1
            gd.c文件在php解壓目錄下
            [test@redhat9]#vi ext/gd/gd.c
            要修改的原代碼:
/* {{{ PHP_RSHUTDOWN_FUNCTION
*/
#if HAVE_LIBGD20 && HAVE_GD_STRINGFT
PHP_RSHUTDOWN_FUNCTION(gd)
{
#if defined(HAVE_GD_THREAD_SAFE) || defined(HAVE_GD_BUNDLED)
gdFontCacheShutdown();
#else
gdFreeFontCache();
#endif
return SUCCESS;
}
#endif
/* }}} */
            將:    gdFreeFontCache();
            修改爲:/* gdFreeFontCache(); */

五.    安裝Python
所需軟件:
Python-2.3.4.tgz
安裝過程:
[test@redhat9]#./configure
[test@redhat9]#make
[test@redhat9]#./python
[test@redhat9]#make install
[test@redhat9]#cp /usr/local/bin/python /usr/bin/python

六.    Mysql-python
所需軟件:
MySQL-python-1.0.0.tar.gz
安裝過程:
[test@redhat9]#tar xfz MySQL-python-1.0.0.tar.gz
[test@redhat9]#cd MySQL-python-1.0.0
[test@redhat9]#export mysqlversion="4.0.12"
[test@redhat9]#export mysqlclient="mysqlclient_r"
[test@redhat9]#export mysqloptlibs="ssl crypto"
[test@redhat9]#python setup.py build
[test@redhat9]#python setup.py install

---注意--如果出現以下錯誤,則請安裝 openssl
gcc -pthread -shared build/temp.linux-i686-2.3/_mysql.o -L/usr/lib/mysql -L/usr/local/lib/mysql -L/usr/local/mysql/lib - L/usr/local/mysql/lib/mysql -lmysqlclient_r -lssl -lcrypto -lz -lcrypt -o build/lib.linux-i686-2.3/_mysql.so
/usr/bin/ld: cannot find -lssl

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章