用configure配置lamp環境
一、編譯MYSQL
#tar -zxvf mysql-......
#cd mysql-......
#groupadd mysql
#useradd -g mysql mysql
#./configure --prefix=/usr/local/lamp/mysql 安裝路徑
--with-client-ldflags=-all-static 靜態化
--with-mysql-ldflags=-all-static
--enable-assembler 使用匯編模式
--with-unix-socket-path=/tmp/mysql.sock 使用unix socket
--with-extra-charsets=utf8,gbk,gb2312 支持字符集
--with-charset=utf8 默認字符集
#make;make instll
#cp support-files/my-medium.cnf /etc/my.cnf
#cd /usr/local/lamp/mysql
#bin/mysql_install_db 初始化數據庫
#chown -R root .
#chgrp -R mysql .
#chown -R mysql var
#/usr/local/lamp/mysql/bin/mysqld_safe & 啓動mysql
mysql>use mysql;
mysql>delete from user where user='';
mysql>grant all on *.* to steady@'%' identified by 'steady'
mysql>flush privileges;
二、編譯APACHE
1、編譯apache
#tar -zxvf httpd-......
#cd httpd-......
#groupadd apache
#useradd -g apache apache
#./configure --prefix=/usr/local/lamp/apache 指定安裝路徑
--enable-so 支持DSO
--enable-mods-shared=all 將所有模塊轉化爲動態的
--enable-proxy 將代理模塊作爲靜態的模塊
**************rhel5編譯apache出錯***********
checking whether to enable mod_substitute... shared (all)
checking whether to enable mod_charset_lite... no
checking whether to enable mod_deflate... checking dependencies
checking for zlib location... not found
checking whether to enable mod_deflate...
configure: error: mod_deflate has been requested but can not be built due to rerequisite failures
checking whether to enable mod_deflate... checking dependencies
checking for zlib location... not found
checking whether to enable mod_deflate...
configure: error: mod_deflate has been requested but can not be built due to rerequisite failures
解決方法:rpm -ivh openssl-devel-.......
2、設置開機自動啓動
#cd /usr/local/apache/bin
#cp apachectl /etc/rc.d/init.d/httpd
#chmod 700 /etc/rc.d/init.d/httpd
#vi /etc/rc.d/init.d/httpd
在-----------start configuration section--------------下面添加三行
#Comments to support chkconfig on RedHat Linux
#chkconfig:2345 90 90
#description:http server
注意:前面的#不能少,沒有這三行,在使用chkconfig時會提示你:service http does not support chkconfig
#chkconfig --add httpd
#chkconfig --level 345 httpd on
這樣,在運行級別345上httpd就可以自動啓動了
對於這個提示:
http:Could not determine the server's fully qualitied domain name,using 127.0.0.1 for ServerName
只需要編輯httpd.conf,找到ServerName****這一行,去掉前面的註釋即可。
三、在編譯之前安裝一些PHP需要的包
freetype libpng libjpeg gd libxml2 zlib 還有各自的鏈接庫包如:freetype-devel libpng-devel........。
還有三個包系統沒有帶的rpm包:libiconv libmcrypt mhash,需要在網上下載源包:download.chinaunix.net 或其他地方。、
編譯libiconv
#cd libiconv
#configure --prefix=/usr/local/libiconv
#make;make install
編譯libmcrypt mhash
#./configure
#make;make install
四、編譯PHP
#tar -zxvf php-....
#cd php-....
#./configure --prefix=/usr/local/lamp/php
--with-apxs2=/usr/local/lamp/apache/bin/apxs 指定apache的apxs工具位置
--with-mysql=/usr/local/lamp/mysql 指定mysql安裝路徑
--with-freetype-dir
--with-jpeg-dir
--with-png-dir
--with-zlib
--with-libxml-dir
--with-gd
--enable-xml
--disable-debug
--enable-gd-native-ttf
--with-iconv=/usr/local/libiconv libiconv裝在那裏就寫那裏路徑
**************rhel5編譯php出錯***********
checking for flex... lex
checking for yywrap in -ll... no
checking lex output file root... ./configure: line 3246: lex: command not found
configure: error: cannot find output from lex; giving up
解決方法:rpm -ivh flex-.....
checking for yywrap in -ll... no
checking lex output file root... ./configure: line 3246: lex: command not found
configure: error: cannot find output from lex; giving up
解決方法:rpm -ivh flex-.....
**************rhel5編譯php make時出錯*****
/home/admin/LAMP/php-5.1.4/ext/iconv/iconv.c:1152: undefined reference to `libiconv'
ext/iconv/.libs/iconv.o:/home/admin/LAMP/php-5.1.4/ext/iconv/iconv.c:1196: more
undefined references to `libiconv' follow
ext/iconv/.libs/iconv.o:/home/admin/LAMP/php-5.1.4/ext/iconv/iconv.c:1196: more
undefined references to `libiconv' follow
make: *** [sapi/cli/php] Error 1
解決方法:-----重新編譯libiconv這個包
解決方法:-----重新編譯libiconv這個包
#tar -zxvf libiconv-....
# cd libiconv-........
#./configure --prefix=/usr/local/libiconv
#make;make install
解決方法:
#wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
#tar -zxvf libiconv-1.13.1.tar.gz
#cd libiconv-1.13.1
# ./configure --prefix=/usr/local/libiconv
# make
# make install
再檢查php
#./configure --with-mysql=/backup/mysql --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-curl --with-gd --enable-gd-native-ttf --with-apxs2=/usr/local/apache/bin/apxs --enable-sockets --with-iconv=/usr/local/libiconv
#make
#make install
#wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
#tar -zxvf libiconv-1.13.1.tar.gz
#cd libiconv-1.13.1
# ./configure --prefix=/usr/local/libiconv
# make
# make install
再檢查php
#./configure --with-mysql=/backup/mysql --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-curl --with-gd --enable-gd-native-ttf --with-apxs2=/usr/local/apache/bin/apxs --enable-sockets --with-iconv=/usr/local/libiconv
#make
#make install
另一種解決方法爲去除iconv模塊也能正常編譯php,如下:(沒有實驗過)
編輯 Makefile 大約 77 行左右的地方:
EXTRA_LIBS = ..... -lcrypt
在最後加上 -liconv,例如:
EXTRA_LIBS = ..... -lcrypt -liconv
再運行make就可以了。
編輯 Makefile 大約 77 行左右的地方:
EXTRA_LIBS = ..... -lcrypt
在最後加上 -liconv,例如:
EXTRA_LIBS = ..... -lcrypt -liconv
再運行make就可以了。
最後一種方法:
#make ZEND_EXTRA_LIBS='-liconv'
#make install
#make install
**************rhel5編譯好php後,啓動apache出錯***********
httpd: Syntax error on line 110 of /usr/local/lamp/apache/conf/httpd.conf:
Cannot load /usr/local/lamp/apache/modules/libphp5.so into server: /usr/local/lamp/apache/modules/libphp5.so
: cannot restore segment prot after reloc: Permission denied
錯誤原因是selinux搞的鬼
解決方法:
#vi /etc/sysconfig/selinux
SELINUX=enforcing 註釋掉:#SELINUX=enforcing
SELINUX=disable
五、安裝Zend Optimization3.3.3