centos 6.6 mysql 5.6_CentOS 6.6 编译安装 PHP5.6+MYSQL5.6+APACHE2.4

如果安装成功将会在/usr/local/libpng目录下生成bin,include,lib和share四个目录。在安装GD2库配置时,通过在configure命令选项中加上“--with-png=/usr/local/libpng”选项,指定libpng库文件的位置。

安装jpeg

注:安装GD2库前所需的jpeg8库文件,需要自己手动创建安装需要的目录,它们在安装时不能自动创建。

[root@centos6 LAMP]# cd /usr/local/LAMP

[root@centos6 LAMP]# tar -zxvf jpegsrc.v9a.tar.gz

[root@centos6 LAMP]# cd ./jpeg-9a/

[root@centos6 jpeg-9a]# mkdir /usr/local/jpeg/ (创建jpeg软件的安装目录)

[root@centos6 jpeg-9a]# mkdir /usr/local/jpeg/bin/ (创建存放命令的目录)

[root@centos6 jpeg-9a]# mkdir /usr/local/jpeg/lib/ (创建jpeg库文件所在目录)

[root@centos6 jpeg-9a]# mkdir /usr/local/jpeg/include/ (创建存放头文件目录)

[root@centos6 jpeg-9a]# mkdir -p /usr/local/jpeg/man/man1(建立存放手册的目录)

[root@centos6 jpeg-9a]# ./configure --prefix=/usr/local/jpeg/ --enable-shared --enable-static(建立共享库使用的GNU的libtool和静态库使用的GNU的libtool)

[root@centos6 jpeg-9a]# make && make install

在安装GD2库配置时,可以在configure命令的选项中加上“--with-jpeg=/usr/local/jpeg8”选项,指定jpeg8库文件的位置。安装PHP时也要指定该库文件的位置。

安装freetype

[root@centos6 LAMP]# cd /usr/local/LAMP

[root@centos6 LAMP]# tar -zxvf freetype-2.5.3.tar.gz

[root@centos6 LAMP]# cd ./freetype-2.5.3

[root@centos6 freetype-2.5.3]#./configure --prefix=/usr/local/freetype/ --enable-shared

[root@centos6 freetype-2.5.3]# make && make install

如果安装成功将会在/usr/local/freetype目录下存在bin,include,lib和share四个目录。并在安装GD2库时,通过configure命令选项中加上“--with-freetype=/usr/local/freetype/”选项,指定freetype库文件位置。

安装autoconf

[root@centos6 LAMP]# cd /usr/local/LAMP

[root@centos6 LAMP]# tar -zxvf autoconf-2.69.tar.gz

[root@centos6 LAMP]# cd ./autoconf-2.69

[root@centos6 autoconf-2.69]# ./configure

[root@centos6 autoconf-2.69]# make && make install

编译安装GD

[root@centos6 LAMP]# cd /usr/local/LAMP

[root@centos6 LAMP]# tar -zxvf libgd-2.1.0.tar.gz

[root@centos6 LAMP]# cd ./libgd-2.1.0

[root@centos6 libgd-2.1.0]# ./configure --prefix=/usr/local/gd?--with-jpeg=/usr/local/jpeg/?--with-png=/usr/local/libpng/?--with-zlib=/usr/local/zlib/?--with-freetype=/usr/local/freetype/

[root@centos6 libgd-2.1.0]# make && make instal

如果安装成功会在/usr/local/gd/目录下存在bin、include和lib这三个目录。在安装PHP5时,通过在configure命令选项中加上“--with-gd=/usr/local/gd”选项,指定GD库文件的位置。

如果报错:

gd_png.c 中

gdMalloc

函数的问题

make[2]: *** [gd_png.lo] Error 1

make[2]: Leaving directory `/tmp/gd-2.0.35'

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/tmp/gd-2.0.35'

make: *** [all] Error 2

解决方案:

vi gd_png.c

找到

#include "png.h"

改成

#include "/usr/local/libpng/include/png.h"

如果报错:

unrecognized option –with-zlib

解决方案:

重装zlib

./configure 之前要先 make clean

或者把解压包删掉,重新解压

另附安装参数:

./configure //配置命令

> --prefix=/usr/local/gd //指定安装软件的位置

> --with-jpeg=/usr/local/jpeg/ //指定去哪找jpeg库文件

> --with-png=/usr/local/libpng/ //指定去哪找png库文件

> --with-zlib=/usr/local/zlib/ //指定去哪找zlib库文件

> --with-freetype=/usr/local/freetype/ //指定去哪找freetype 2.x字体库的位置

安装apache

卸载apr和apr-util

[root@centos6 LAMP]# yum remove apr apr-util

安装apr-1.5.2

[root@centos6 LAMP]# tar zxvf apr-1.5.2.tar.gz

[root@centos6 LAMP]# cd apr-1.5.2

[root@centos6 apr-1.5.2]# ./configure --prefix=/usr/local/apr-httpd/ && make && make install

安装 apr-util-1.5.4

[root@centos6 LAMP]# tar zxvf apr-util-1.5.4.tar.gz

[root@centos6 LAMP]# cd apr-util-1.5.4

[root@centos6 apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr-httpd/ && make && make install

安装pcre-8.34

[root@centos6 LAMP]# tar zxvf pcre-8.34.tar.gz

[root@centos6 LAMP]# cd pcre-8.34

[root@centos6 pcre-8.34]# ./configure --prefix=/usr/local/pcre

[root@centos6 pcre-8.34]# make

[root@centos6 pcre-8.34]# make install

安装apache

[root@centos6 LAMP]# tar zxvf httpd-2.4.18.tar.gz

[root@centos6 LAMP]# cd httpd-2.4.18

[root@centos6 httpd-2.4.18]# ./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-deflate --enable-speling--enable-cache --enable-file-cache --enable-disk-cache --enable-mem-cache --enable-so --enable-expires=shared --enable-rewrite=shared --enable-static-support --sysconfdir=/etc/httpd --with-z=/usr/local/zlib/ --with-apr=/usr/local/apr-httpd/ --with-apr-util=/usr/local/apr-util-httpd/ --with-pcre=/usr/local/pcre/ --disable-userdir

[root@centos6 httpd-2.4.18]# make && make install

安装完成后,进入/usr/local/apache2/目录下,检查是否有以下文件:

bin build cgi-bin error htdocs icons include

logs man manual modules

启动Apache服务器,并查端口是否开启,启动Apache服务器的命令行如下:

[root@centos6 httpd-2.4.18]# /usr/local/apache2/bin/apachectl start

添加到快速启动:

[root@centos6 httpd-2.4.18]#cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd

以后就可以这样了:

/etc/init.d httpd stop

/etc/init.d httpd start

/etc/init.d httpd restart

如果不能启动,提示信息:

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message

解决方案:

[root@centos6 httpd-2.4.18]# vim /etc/httpd/httpd.conf

写入:

ServerName localhost:80

重启apache

service httpd stop

service httpd start

查看端口号,应该是这样的:

netstat -tnl|grep 80

tcp 0 0 0.0.0.0:80 0.0.0.0:* LIST

测试,浏览器输入你的IP地址,出现It works!安装成功

设置开机启动:

vim /etc/rc.local

添加:

/usr/local/apache/bin/apachectl start

:wq保存退出

安装MYSQL

安装所需工具和库

yum install gcc gcc-c++ ncurses-devel perl libncurses5-dev

yum install gnu make

安装cmake

[root@centos6 ~]# cd /usr/local/LAMP

[root@centos6 LAMP]# tar zxvf cmake-3.0.2.tar.gz

[root@centos6 LAMP]# cd cmake-3.0.2

[root@centos6 cmake-3.0.2.tar.gz]# ./bootstrap

[root@centos6 cmake-3.0.2.tar.gz]# gmake

[root@centos6 cmake-3.0.2.tar.gz]# gmake install

如果报错:提示/usr/bin/cmake 文件不存在

解决办法:

找到 `cmake`的可执行文件路径,应该是在`/usr/local/bin/cmake`

创建个软连接:

[root@centos6 ~]# ln -s /usr/local/bin/cmake /usr/bin/cmake

设置用户,组和目录

[root@centos6 ~]# groupadd mysql //创建组

[root@centos6 ~]# useradd mysql -r -g mysql //给mysql用户分组

[root@centos6 ~]# mkdir /usr/local/mysql //安装目录

[root@centos6 ~]# mkdir /usr/local/mysql/data //数据仓库目录

[root@centos6 ~]# chown -R mysql.mysql /usr/local/mysql/ //分配权限

安装MYSQL

[root@centos6 ~]# cd /usr/local/LAMP

[root@centos6 LAMP]# tar zxvf mysql-5.6.13.tar.gz

[root@centos6 LAMP]# cd mysql-5.6.13

[root@centos6 mysql-5.6.13]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1

[root@centos6 mysql-5.6.13]# make

[root@centos6 mysql-5.6.13]# make install

注意:如果安装出错,需要重新配置的话,要删除/usr/local/LAMP/mysql-5.6.13目录下的 CMakeCache.txt文件

rm -r CMakeCache.txt

另附参数说明:

-DCMAKE_INSTALL_PREFIX= 数据库程序安装路径;

-DMYSQL_DATADIR= 数据库文件存放路径(不配置的话会默认创建$PREFIX_DIR/data)

-DMYSQL_UNIX_ADDR= 默认位置是/var/lib/mysql/mysql.sock,如果指定其他路径,需要做一个软链接,或者在配置文件my.cnf中进行设置。

-DDEFAULT_CHARSET= 默认数据库编码

-DDEFAULT_COLLATION= 默认数据库整理编码

-DWITH_EXTRA_CHARSETS= 扩展支持编码(all | utf8,gbk,gb2312 | none)

-DWITH_MYISAM_STORAGE_ENGINE= MYISAM引擎支持(1|0)

-DWITH_INNOBASE_STORAGE_ENGINE= innoDB引擎支持(1|0)

-DWITH_MEMORY_STORAGE_ENGINE= MEMORY引擎支持(1|0)

修改mysql目录所有者和组

cd /usr/local/mysql

chown -R mysql:mysql .

cd /usr/local/mysql/data

chown -R mysql:mysql .

初始化数据库

cd /usr/local/mysql

scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data

复制mysql配置文件

cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

注:如果有,请覆盖

复制mysql启动脚本加入PATH路径

cd /usr/local/mysql

cp support-files/mysql.server /etc/init.d/mysql

vim /etc/profile

到文档最后,添加:

PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH

export PATH

保存退出

source /etc/profile //刷新profile

启动mysql服务并加入开机自启动

service mysql start

chkconfig --level 35 mysql on

检查mysql是否启动

netstat -tulnp | grep 3306

结果应该是mysql占用了端口

登录一下试试

mysql -u root -p

错误处理

出现 ERROR 1045 (28000): Access denied for user'root'@'localhost' (using password: YES(NO)) 这种情况

解决:

[root@centos6 ~]# /etc/init.d/mysql stop

[root@centos6 ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

[root@centos6 ~]# /usr/local/mysql/bin/mysql -u root mysql

mysql> UPDATE user SET Password=PASSWORD('123456') where User='root';

mysql> FLUSH PRIVILEGES;

mysql> quit;

出现ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

解决:

ln -s /usr/local/mysql/mysql.sock /tmp/mysql.sock

/usr/local/mysql/bin/mysql -u root -S /usr/local/mysql/mysql.sock

出现Starting MySQL..The server quit without updating PID file ([FAILED]/mysql/Server03.mylinux.com.pid).

解决:

修改/etc/my.cnf 中datadir,指向正确的mysql数据库文件目录

提示:

[root@centos6 ~]# ps aux | grep mysql //查看PID路径

配置文件中/etc/my.cnf中配置的路径一定要和这个路径相同

pid-file= 刚刚查到的pid-file

PHP安装

先安装libXpm-devel

不然PHP或报错: make: * [ext/gd/gd.lo] Error 1

安装:

[root@centos6 ~]# yum -y install libXpm-devel

找出文件位置:

rpm -ql libXpm-devel

应该是这个位置,记住它,后面安装PHP要配置 --with-xpm-dir=/usr/lib64

/usr/lib64/libXpm.so

前面这么多操作是不是很麻烦,还有一个简单方法:

cp -frp /usr/lib64/libltdl.so* /usr/lib/

cp -frp /usr/lib64/libXpm.so* /usr/lib/

安装PHP

[root@centos6 LAMP]# cd /usr/local/LAMP

[root@centos6 LAMP]# tar -zxvf php-5.6.13.tar.gz

[root@centos6 LAMP]# cd ./php-5.6.13

[root@centos6 php-5.6.13]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir=/usr/local/libxml2 --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-gd=/usr/local/gd --with-zlib-dir=/usr/local/zlib --with-mcrypt=/usr/local/libmcrypt --with-xpm-dir=/usr/lib64 --enable-soap --enable-mbstring=all --enable-sockets

[root@centos6 php-5.6.13]# make

[root@centos6 php-5.6.13]# make install

另附参数说明:

./configure

> --prefix=/usr/local/php

>

> --with-config-file-path=/usr/local/php/etc //配置文件路径,指定php.ini位置

> --with-apxs2=/usr/local/apache249/bin/apxs // apxs功能是使用mod_so中的//LoadModule指令,加载指定模块到apache,要求apache 要打开SO模块

> --with-mysql=/usr/local/mysql //mysql安装目录,对mysql的支持

> --with-mysqli=/usr/local/mysql/bin/mysql_config //mysqli文件目录,优化支持

> --with-libxml-dir=/usr/local/libxml2 //打开libxml2库的支持

> --with-png-dir=/usr/local/libpng //打开对png图片的支持

> --with-jpeg-dir=/usr/local/jpeg //打开对jpeg图片的支持

> --with-freetype-dir=/usr/local/freetype //打开对freetype字体库的支持

> --with-gd=/usr/local/gd //打开gd库的支持

> --with-zlib-dir=/usr/local/zlib //打开zlib库的支持

> --with-mcrypt=/usr/local/libmcrypt //打开libmcrypt库的支持

> --with-xpm-dir=/usr/lib64 //打开libXpm库的支持

> --enable-soap

> --enable-mbstring=all //多字节,字符串的支持

> --enable-sockets //打开sockets 支持

复制配置文件

[root@localhost php-5.6.13]# cp php.ini-development /usr/local/php/etc/php.ini

更改Apache文件,解析PHP

vim /etc/httpd/httpd.conf

在LoadModule模块中添加(如果存在请跳过)

LoadModule php5_module modules/libphp5.so

检查文件是否存在

cd /usr/local/apache2/modules

ls -al

看看有没有这个文件

libphp5.so

编辑apache配置文件

vim /etc/httpd/httpd.conf

找到

AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

在下面添加

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

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

找到

DirectoryIndex index.html

修改为

DirectoryIndex index.php index.html index.htm

重启apache

service httpd stop

service httpd start

验证

apache服务器的网站根目录为 /usr/local/apache2/htdocs/

vim /usr/local/apache2/htdocs/index.php

写入

:wq 保存退出

浏览器访问

date模块下可能会出现:

It is not safe to rely on the system’s timezon....

解决:

vim /usr/local/php/etc/php.ini

找到:

;date.timezone =

改成:

date.timezone = "Asia/Shanghai"

重启apache:

service httpd restart

安装完成

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值