libpng安裝時出現的問題

 

因爲安裝系統的時候是最小安裝,所以編譯服務的時候需要一些軟件支持,具體需要以下RPM包,這些都可以在CentOS安裝盤裏找到:
glibc-kernheaders-2.4-9.1.98.EL.x86_64.rpm(在第二張碟)
glibc-headers-2.3.4-2.19.x86_64.rpm(在第二張碟)
glibc-devel-2.3.4-2.19.x86_64.rpm(在第二張碟)
cpp-3.4.5-2.x86_64.rpm(在第一張碟)
gcc-3.4.5-2.x86_64.rpm(在第二張碟)
libstdc++-devel-3.4.5-2.x86_64.rpm(在第二張碟)
gcc-c++-3.4.5-2.x86_64.rpm(在第三張碟)
flex-2.5.4a-33.x86_64.rpm(在第二張碟)

增加一個用戶,以方便通過FTP上傳文件,命令如下:
useradd biaoest(增加一個名稱爲biaoest的用戶)
passwd biaoest(爲剛剛增加的用戶修改密碼)

上傳文件到biaoest的根目錄/home/biaoest,用軟件上傳的時候注意不要用被動模式,要不感覺會有點慢,把上面需要的文件全部上傳。

第二步:安裝APACHE2.2.2+MYSQL5.0.22+PHP5.1.4+GD2.0.33+ZENDOPTIMIZER3.0

安裝系統的時候特別爲服務相關的軟件準備了一個分區,下面爲分區server的相關分佈:
cd /server(服務根目錄)
mkdir /server/apache2(APACHE2根目錄)
mkdir /server/modlib(相關模塊根目錄)
mkdir /server/modlib/jpeg6(JPEG目錄)
mkdir /server/modlib/png(PNG目錄)
mkdir /server/modlib/gd2(GD目錄)
mkdir /server/modlib/xml2(XML目錄)
mkdir /server/mysql5(MYSQL5根目錄)
mkdir /server/php5(PHP5根目錄)
mkdir /server/php5/zend(ZENDOPTIMIZER3目錄)
mkdir /server/database(MYSQL數據庫目錄)
mkdir /server/webroot(網頁根目錄)

下面的安裝都是假設當前路徑爲剛剛上傳文件路徑/home/biaoest目錄。
 
安裝GCC編譯器及相關輔助軟件
rpm -Uvh glibc-kernheaders-2.4-9.1.98.EL.x86_64.rpm
rpm -Uvh glibc-headers-2.3.4-2.19.x86_64.rpm
rpm -Uvh glibc-devel-2.3.4-2.19.x86_64.rpm
rpm -Uvh cpp-3.4.5-2.x86_64.rpm
rpm -Uvh gcc-3.4.5-2.x86_64.rpm
rpm -Uvh libstdc++-devel-3.4.5-2.x86_64.rpm
rpm -Uvh gcc-c++-3.4.5-2.x86_64.rpm
####################################################
如果沒有安裝上面軟件,可能出現的錯誤提示:
checking for gcc... no
checking for cc... no
checking for cc... no
checking for cl... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
####################################################

rpm -Uvh flex-2.5.4a-33.x86_64.rpm
####################################################
如果沒有安裝上面軟件,可能出現的錯誤提示:
checking lex output file root... ./configure: line 3246: lex: command not found
configure: error: cannot find output from lex; giving up
####################################################

安裝MYSQL5.0.22到指定目錄/server/mysql5,數據保存在/server/database
mkdir /server/mysql5
mkdir /server/database
groupadd mysql
useradd -g mysql mysql
cd /home/biaoest
tar -zxvf mysql-5.0.22.tar.gz
cd mysql-5.0.22
./configure --prefix=/server/mysql5 --sysconfdir=/etc --localstatedir=/server/database
make
make install
cp /server/mysql5/support-files/my-medium.cnf /etc/my.cnf

在[mysqld]下加
set-variable = max_connections=1000

修改/server/database屬性
chown mysql.mysql /server/database

建立數據庫
/server/mysql5/bin/mysql_install_db --user=mysql

啓動數據庫
/server/mysql5/bin/mysqld_safe --user=mysql &

設置開機自動運行
cp /server/mysql5/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
cd /etc/rc.d/init.d
chkconfig --add mysqld

安裝apache2.2.2
cd /home/biaoest
tar -zxvf httpd-2.2.2.tar.gz
cd httpd-2.2.2
修改默認連接數vi server/mpm/prefork/prefork.c,查找256,把它修改爲2048

./configure --prefix=/server/apache2 --enable-module=so --enable-module=rewrite --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --with-mpm=prefork
make
make install

啓動apache2
/server/apache2/bin/apachectl start

設置開機自動啓動
從/usr/local/apache/bin/apachectl 到 /etc/rc.d/init.d/httpd 建立一個符號連接:
# ln -s /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd

然後在此文件總添加以下幾行(大概在文件頂部,約第二行的地方):

# chkconfig: 2345 10 90
# description: Activates/Deactivates Apache Web Server

最後,運行chkconfig把Apache添加到系統的啓動服務組裏面:

# /sbin/chkconfig --del httpd
# /sbin/chkconfig --add httpd


編輯/etc/rc.d/rc.local
把/server/apache2/bin/apachectl start 加入進去


安裝GD-2.0.33

安裝ZLIB2
cd /home/biaoest
tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
#################################################
不要用--prefix自定義安裝目錄,否則可能會影響後面安裝,可能出現的錯誤:
configure: error: zlib not installed
#################################################

#################################################
如果你的機器是64位,並且在安裝png時候出現下面錯誤:
/usr/bin/ld: /usr/local/lib/libz.a(compress.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libz.a: could not read symbols: Bad value
collect2: ld returned 1 exit status

修補辦法(接上面步驟):
vi Makefile
找到 CFLAGS=-O3 -DUSE_MMAP
在後面加入-fPIC,即變成CFLAGS=-O3 -DUSE_MMAP -fPIC
接下面步驟
#################################################
make
make install


安裝JPEG6
#################################################
先建立目錄,否則可能會出現類型下面錯誤:
/usr/bin/install -c cjpeg /server/apache2/modlib/jpeg6/bin/cjpeg
/usr/bin/install: cannot create regular file `/server/apache2/modlib/jpeg6/bin/cjpeg': No such file or directory
make: *** [install] Error 1

解決辦法:
mkdir /server/apache2/modlib
mkdir /server/apache2/modlib/jpeg6 
mkdir /server/apache2/modlib/jpeg6/bin 
mkdir /server/apache2/modlib/jpeg6/lib 
mkdir /server/apache2/modlib/jpeg6/include 
mkdir /server/apache2/modlib/jpeg6/man 
mkdir /server/apache2/modlib/jpeg6/man/man1 
#################################################
cd /home/biaoest
tar -zxvf jpegsrc.v6b.tar.gz
cd jpegsrc.v6b.
./configure --prefix=/server/apache2/modlib/jpeg6

#################################################
如果你的機器是64位,並且在安裝gd時候出現下面錯誤:
/usr/bin/ld: /server/apache2/modlib/jpeg6//lib/libjpeg.a(compress.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC
/server/apache2/modlib/jpeg6//lib/libjpeg.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libgd.la] Error 1

修補辦法(接上面步驟):
vi Makefile
找到 CFLAGS= -O2 -I$(srcdir) 
在後面加入-fPIC,即變成CFLAGS= -O2 -I$(srcdir) -fPIC
接下面步驟
#################################################
make
make install-lib
#################################################
特別注意,要不下面會出現錯誤:
configure: error: libjpeg.(a|so) not found.
#################################################
make install

安裝PNG
cd /home/biaoest
tar -zxvf libpng-1.2.10.tar.gz
cd libpng-1.2.10
./configure --prefix=/server/apache2/modlib/png
make
################################################
如果出現下面錯誤:
configure: error: zlib not installed
請回到zlib,重新安裝一次,最好先make clean
################################################
make install

安裝freetype
cd /home/biaoest
tar -zxvf freetype-2.2.1.tar.gz
cd freetype-2.2.1
./configure --prefix=/server/apache2/modlib/freetype
make
make install


安裝GD
cd /home/biaoest
tar -zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/server/apache2/modlib/gd2 --with-jpeg=/server/apache2/modlib/jpeg6/ --with-png=/server/apache2/modlib/png/ --with-zlib --with-freetype=/server/apache2/modlib/freetype/
make
#################################################
如果出現下面錯誤:
gd_png.c:825: warning: data definition has no type or storage class
make[2]: *** [gd_png.lo] Error 1

修復方法:
找到CPPFLAGS = -I/server/apache2/modlib/freetype/include/freetype2 -I/server/apache2/modlib/freetyp
e/include -I/server/apache2/modlib/freetype//include  -I/server/apache2/modlib/jpeg6//include
原來是少了png的支持了,把它改爲

CPPFLAGS = -I/server/apache2/modlib/freetype/include/freetype2 -I/server/apache2/modlib/freetyp
e/include -I/server/apache2/modlib/png/include  -I/server/apache2/modlib/jpeg6/include
#################################################
make install


安裝LIBXML2
mkdir /server/apache2/modlib
tar -zxvf libxml2-2.6.26.tar.gz
cd libxml2-2.6.26
./configure --prefix=/server/apache2/modlib/xml2
make 
make install

安裝PHP5.1.4
cd /home/biaoest
tar -zxvf php-5.1.4.tar.gz
cd php-5.1.4
./configure --prefix=/server/php5 /
--with-mysql=/server/mysql5 /
--with-apxs2=/server/apache2/bin/apxs /
--with-libxml-dir=/server/apache2/modlib/xml2 /
--with-gd=/server/apache2/modlib/gd2 /
--with-jpeg-dir=/server/apache2/modlib/jpeg6 /
--with-zlib /
--with-png-dir=/server/apache2/modlib/png /
--with-freetype-dir=/server/apache2/modlib/freetype /
--enable-experimental-zts /
#################################################
如果出現錯誤:
checking lex output file root... ./configure: line 3246: lex: command not found
configure: error: cannot find output from lex; giving up

修補方法,安裝FLEX:
rpm -Uvh flex-2.5.4a-33.x86_64.rpm
################################################
如果又出現下面錯誤:
configure: error: libjpeg.(a|so) not found.

修補方法:
原來在安裝jpeg的時候,執行了make install,應該執行make install-lib才能生成libjpeg.a文件
################################################
make
make install

複製配置文件到相應的目錄
cp php.ini-dict /server/php5/lib/php.ini

配置/server/apache2/conf/httpd.conf
找到DocumentRoot "/server/apache2/htdocs" ,修改爲DocumentRoot "/server/webroot"
找到<Directory "/server/apache2/htdocs"> ,修改爲<Directory "/server/webroot">

找到DirectoryIndex index.html,增加index.php等等,變成DirectoryIndex index.html index.htm index.php index.phtml index.phps

加載php模塊,去掉註釋“#”,如沒有此行,請加上。
LoadModule php5_module        modules/libphp5.so
加上此兩行
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
set-variable = max_connections=100


安裝ZendOptimizer-3.0.0
cd /home/biaoest
tar -zxvf ZendOptimizer-3.0.0-linux-glibc23-x86_64.tar.gz
cd ZendOptimizer-3.0.0-linux-glibc23-x86_64
./install
然後就按照提示給出相應的路徑即可


安裝MEMCACHED

tar -xzf libevent-1.1a.tar.gz
cd libevent-1.1a
./configure --prefix=/usr
make
make install
cd ..
tar -xzf memcached-1.1.12.tar.gz
cd memcached-1.1.12
./configure --prefix=/usr
make
make install

啓動MEMCHED
/usr/bin/memcached -d -m 128 -p 11211 -u nobody

########################################################################
/usr/bin/memcached: error while loading shared libraries: libevent-1.1a.so.1: cannot open shared object file: No such file or directory

cp /usr/lib/libevent* /usr/lib64/ -R 
#########################################################################
安裝memcache PHP模塊

tar vxzf memcache-2.0.4.tgz
cd memcache-2.0.4
/server/php5/bin/phpize
./configure --enable-memcache --with-php-config=/server/php5/bin/php-config --with-zlib-dir
make
make install

安裝完後會有類似這樣的提示:

Installing shared extensions: /server/php5/lib/php/extensions/no-debug-non-zts-20050922/

把這個記住,然後修改php.ini,把

extension_dir = "./"

修改爲

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20050922/"

並添加一行


extension=memcache.so


安裝完畢,該測試了,建立一個專門的web用戶,用於上傳網頁吧。
useradd -d /server/webroot web
passwd web
chown web /server/webroot

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