centos最近发布了5.5版本,但AMP软件包并没有升级(Apache2.2.3/php5.1.6/mysql.5.0.40);所以为了能使用最新稳定版,需要自己编译安装。下面是具体的安装步骤,对于优化细节暂不做多的考虑。
1.准备相应的软件包。
下载相应的软件包放在/usr/local/src目录下。
查看源代码打印帮助1 cd /usr/local/src
2
3 wget http://labs.renren.com/apache-mirror/httpd/httpd-2.2.15.tar.gz
4
5 wget http://mirrors.sohu.com/php/php-5.2.13.tar.gz
6
7 wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.48.tar.gz
2.安装mysql
在编译安装mysql之前。需先装ncurses;
查看源代码打印帮助01 wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.7.tar.gz
02
03 chmod +x ncurses-5.7.tar.gz
04
05 tar xzvf ncurses-5.7.tar.gz
06
07 ./configure --with-shared --with-normal --with-debug --enable-overwrite
08
09 make
10
11 make install
编译安装mysql。注意–with-innodb是安装innodb引擎。
查看源代码打印帮助01 tar xzvf mysql-5.1.48.tar.gz
02
03 cd mysql-5.1.48
04
05 groupadd db
06
07 useradd -g db mysql
08
09 passwd mysql
10
11 ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock --with-mysqld-user=mysql --with-innodb
12
13 make
14
15 make install
16
17 cd /usr/local/mysql
18
19 cp share/mysql/my-medium.cnf /etc/my.cnf
20
21 cp /usr/local/src/mysql-5.1.43/support-files/mysql.server /etc/init.d/mysqld
22
23 ./bin/mysql_install_db
24
25 ./bin/mysqld_safe &
可能出现的问题,在启动/etc/init.d/mysqld start出现MySQL manager or server PID file could not be found! [FAILED]
解决办法:打开vi /etc/my.cnf文件,在[mysqld]下面加入如下配置
查看源代码打印帮助1 basedir = /usr/local/mysql
2
3 datadir = /usr/local/mysql/data
4
5 log-error = /usr/local/mysql/log/alert.log
6
7 log_slow_queries = /usr/local/mysql/log/slow.log
3 安装Apache
查看源代码打印帮助1 tar xzvf httpd-2.2.15.tar.gz
2
3 cd httpd-2.2.15
4
5 ./configure --prefix=/usr/local/apache2/
4安装PHP
在安装PHP之前,需要先安装libxml2软件包,不然在编译过程中会出现configure: error: xml2-config not found. Please check your libxml2 installation。
查看源代码打印帮助1 yum install libxml2-devel
下面是编译安装php的具体过程
查看源代码打印帮助01 tar xzvf php-5.2.13.tar.gz
02
03 cd php-5.2.13
04
05 ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config
06
07 make
08
09 make test
10
11 make install
12
13 cp php-dist /usr/local/php/lib/php.ini
5安装完毕后,需要配置 php.ini和httpd.conf
打开vi /etc/local/php/lib/php.ini,查找”include_path” 加入路径”/usr/local/php/lib”;
打开vi /usr/local/apache2/conf/http.conf。加入如下指令
查看源代码打印帮助01 </pre>
02 AddType application/x-httpd-php .php
03
04 AddType application/x-httpd-php-source .phps
05
06 <IfModule dir_module>
07
08 DirectoryIndex index.php index.html
09
10 </IfModule>
11
12 keepAlive Off
13
14 <IfModule prefork.c>
15
16 StartServers 5
17
18 MinSpareServers 5
19
20 MaxSpareServers 10
21
22 MaxClients 255
23
24 MaxRequestsPerchild 10
25
26 </IfModule>
27 <pre>
6 使用apxs安装编译过程中没有安装的Apache模块
如果在编译Apache的过程中,没有使用–with-rewrite选项。则需要增加mod_rewrite模块。以下是安装过程
查看源代码打印帮助1 </pre>
2 cd /usr/local/apach2/modules/mappers
3
4 /usr/local/apache2/bin/apxs -i -a -c mod_rewrite.c
5 <pre>
在httpd.conf中查看LoadModule rewrite_module modules/mod_rewrite.so是否开启。AllowOverride 改为All
7 使用php-config安装编译过程中没有安装的PHP模块
安装gettext
查看源代码打印帮助01 </pre>
02 cd /usr/local/src/php-5.1.13/etc
03
04 cd ./gettext
05
06 /usr/local/php/bin/phpize
07
08 ./configure --with-php-config=/usr/local/php/bin/php-config
09
10 make
11
12 make install
13 <pre>
安装gd
查看源代码打印帮助01 </pre>
02 yum install libpng-devel
03
04 yum install libjepg-devel
05
06 yim install freetype-devel
07
08 cd /usr/local/src/php-5.1.13/etc/gd
09
10 /usr/local/php/bin/phpize
11
12 ./configure --with-php-config=/usr/local/php/bin/php-config
13
14 make
15
16 make install
17 <pre>
安装完毕后gettext.so和gd.so写到php.ini文件中.(extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
gettext.so)
同理。安装mcrypt。在安装mcrypt之前注意先安装yum install libmcrypt libmcrypt-devel
出现的问题:
问题一:PHP安装GD库后发现无法处理JPEG,JPG类型的图片;
解决办法:首先查看系统GD库文件存在哪些.输入命令:gdlib-config –all 结果如下:
includedir: /usr/include
cflags: -I/usr/include
ldflags: -L/usr/lib
libs: -lXpm -lX11 -ljpeg -lfontconfig -lfreetype -lpng12 -lz -lm
libdir: /usr/lib
features: GD_XPM GD_JPEG GD_FONTCONFIG GD_FREETYPE GD_PNG GD_GIF
有GD_JPEG说明libjpeg.so动态库在/usr/lib目录下。出现问题的原因应该是编译安装GD库是没有指名JPEG的路径。所以,重新编译下GD库。方法如下
cd /usr/local/src/php-5.2.13/ext/gd
./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg-dir=/usr/lib
make
make install
/etc/init.d/apache restart
问题解决。
来源:http://www.cardii.net/centos5-5-compile-installed-amp-environment/
1.准备相应的软件包。
下载相应的软件包放在/usr/local/src目录下。
查看源代码打印帮助1 cd /usr/local/src
2
3 wget http://labs.renren.com/apache-mirror/httpd/httpd-2.2.15.tar.gz
4
5 wget http://mirrors.sohu.com/php/php-5.2.13.tar.gz
6
7 wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.48.tar.gz
2.安装mysql
在编译安装mysql之前。需先装ncurses;
查看源代码打印帮助01 wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.7.tar.gz
02
03 chmod +x ncurses-5.7.tar.gz
04
05 tar xzvf ncurses-5.7.tar.gz
06
07 ./configure --with-shared --with-normal --with-debug --enable-overwrite
08
09 make
10
11 make install
编译安装mysql。注意–with-innodb是安装innodb引擎。
查看源代码打印帮助01 tar xzvf mysql-5.1.48.tar.gz
02
03 cd mysql-5.1.48
04
05 groupadd db
06
07 useradd -g db mysql
08
09 passwd mysql
10
11 ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock --with-mysqld-user=mysql --with-innodb
12
13 make
14
15 make install
16
17 cd /usr/local/mysql
18
19 cp share/mysql/my-medium.cnf /etc/my.cnf
20
21 cp /usr/local/src/mysql-5.1.43/support-files/mysql.server /etc/init.d/mysqld
22
23 ./bin/mysql_install_db
24
25 ./bin/mysqld_safe &
可能出现的问题,在启动/etc/init.d/mysqld start出现MySQL manager or server PID file could not be found! [FAILED]
解决办法:打开vi /etc/my.cnf文件,在[mysqld]下面加入如下配置
查看源代码打印帮助1 basedir = /usr/local/mysql
2
3 datadir = /usr/local/mysql/data
4
5 log-error = /usr/local/mysql/log/alert.log
6
7 log_slow_queries = /usr/local/mysql/log/slow.log
3 安装Apache
查看源代码打印帮助1 tar xzvf httpd-2.2.15.tar.gz
2
3 cd httpd-2.2.15
4
5 ./configure --prefix=/usr/local/apache2/
4安装PHP
在安装PHP之前,需要先安装libxml2软件包,不然在编译过程中会出现configure: error: xml2-config not found. Please check your libxml2 installation。
查看源代码打印帮助1 yum install libxml2-devel
下面是编译安装php的具体过程
查看源代码打印帮助01 tar xzvf php-5.2.13.tar.gz
02
03 cd php-5.2.13
04
05 ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config
06
07 make
08
09 make test
10
11 make install
12
13 cp php-dist /usr/local/php/lib/php.ini
5安装完毕后,需要配置 php.ini和httpd.conf
打开vi /etc/local/php/lib/php.ini,查找”include_path” 加入路径”/usr/local/php/lib”;
打开vi /usr/local/apache2/conf/http.conf。加入如下指令
查看源代码打印帮助01 </pre>
02 AddType application/x-httpd-php .php
03
04 AddType application/x-httpd-php-source .phps
05
06 <IfModule dir_module>
07
08 DirectoryIndex index.php index.html
09
10 </IfModule>
11
12 keepAlive Off
13
14 <IfModule prefork.c>
15
16 StartServers 5
17
18 MinSpareServers 5
19
20 MaxSpareServers 10
21
22 MaxClients 255
23
24 MaxRequestsPerchild 10
25
26 </IfModule>
27 <pre>
6 使用apxs安装编译过程中没有安装的Apache模块
如果在编译Apache的过程中,没有使用–with-rewrite选项。则需要增加mod_rewrite模块。以下是安装过程
查看源代码打印帮助1 </pre>
2 cd /usr/local/apach2/modules/mappers
3
4 /usr/local/apache2/bin/apxs -i -a -c mod_rewrite.c
5 <pre>
在httpd.conf中查看LoadModule rewrite_module modules/mod_rewrite.so是否开启。AllowOverride 改为All
7 使用php-config安装编译过程中没有安装的PHP模块
安装gettext
查看源代码打印帮助01 </pre>
02 cd /usr/local/src/php-5.1.13/etc
03
04 cd ./gettext
05
06 /usr/local/php/bin/phpize
07
08 ./configure --with-php-config=/usr/local/php/bin/php-config
09
10 make
11
12 make install
13 <pre>
安装gd
查看源代码打印帮助01 </pre>
02 yum install libpng-devel
03
04 yum install libjepg-devel
05
06 yim install freetype-devel
07
08 cd /usr/local/src/php-5.1.13/etc/gd
09
10 /usr/local/php/bin/phpize
11
12 ./configure --with-php-config=/usr/local/php/bin/php-config
13
14 make
15
16 make install
17 <pre>
安装完毕后gettext.so和gd.so写到php.ini文件中.(extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
gettext.so)
同理。安装mcrypt。在安装mcrypt之前注意先安装yum install libmcrypt libmcrypt-devel
出现的问题:
问题一:PHP安装GD库后发现无法处理JPEG,JPG类型的图片;
解决办法:首先查看系统GD库文件存在哪些.输入命令:gdlib-config –all 结果如下:
includedir: /usr/include
cflags: -I/usr/include
ldflags: -L/usr/lib
libs: -lXpm -lX11 -ljpeg -lfontconfig -lfreetype -lpng12 -lz -lm
libdir: /usr/lib
features: GD_XPM GD_JPEG GD_FONTCONFIG GD_FREETYPE GD_PNG GD_GIF
有GD_JPEG说明libjpeg.so动态库在/usr/lib目录下。出现问题的原因应该是编译安装GD库是没有指名JPEG的路径。所以,重新编译下GD库。方法如下
cd /usr/local/src/php-5.2.13/ext/gd
./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg-dir=/usr/lib
make
make install
/etc/init.d/apache restart
问题解决。
来源:http://www.cardii.net/centos5-5-compile-installed-amp-environment/
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/3596/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
评论列表