php5.6 编译msyql,自己编写的:centos6.6上编译安装apache2.4+php5.6+mysql5.6【亲-站长资讯中心...

c4468b3f4df77e96b0a416fa2a870fba.png

在centos6.6上安装apache2.4+php5.6+mysql5.6

关于wget的安装

将之前装系统的.iso文件挂载到光驱

由于我在/home/jinnan/下建立了一个cdrom文件夹

Shell>#mount /dev/cdrom  /home/jinnan/cdrom

Shell># cd /home/jinnan/cdrom

Shell># ls

Shell># cd Packages

Shell>#ls | grep wget

Shell># rpm -ivh wget-1.12-5.el6.x86_64.rpm

测试wget能否下载文件

Shell># wget https://cmake.org/files/v2.8/cmake-2.8.2.tar.gz

依赖软件查询:http://rpmfind.net

关于lamp环境安装的需要软件的下载地址:

freetype:https://www.freetype.org/

libxml2:http://xmlsoft.org/sources/

jpegsrc:http://www.ijg.org

libpng:http://www.libpng.org/pub/png/libpng.html

zlib:http://zlib.net/

libgd:https://libgd.github.io/

php:http://php.net/downloads.php

apache:http://httpd.apache.org/download.cgi

apr / apr-util:http://apr.apache.org/download.cgi

pcre:http://www.pcre.org/

cmake:https://cmake.org/files/

mysql:国内镜像站下载:http://mirrors.sohu.com/mysql/

台湾镜像站: http://ftp.ntu.edu.tw/MySQL/Downloads/

官方下载:    http://www.mysql.com

怎样从Mysql官网下载mysql.tar.gz版本的安装包:http://blog.csdn.net/u012453843/article/details/52876462

【如果压缩包为.tar.bz2,那么解压命令为 tar jxvf  ****.tar.bz2】

安装gcc:

安装gcc的时候gcc的几个依赖关系如下,lib【是library的缩写】,比如libppl,ppl代表的是包名或软件名

gcc

cloog-ppl

ppl(libppl.so.7/libppl_c.so.2)

cpp

mpfr(libmpfr.so.1)

gcc-c++

libstdc++-devel

================================================================

apr安装【apr-1.6.2.tar.gz】

shell>#tar zxvf apr-1.6.2.tar.gz

shell>#cd apr-1.6.2

shell>#./configure --prefix=/usr/local/apr1.6

shell>#make && make install

安装apr-util:【 apr-util-1.5.4.tar.gz】

shell>#tar zxvf apr-util-1.5.4.tar.gz

shell>#cd apr-util-1.5.4

shell>#./configure --prefix=/usr/local/apr-util1.4 \

--with-apr=/usr/local/apr1.6/

shell>#make && make install

=============================================================

安装pcre:【 pcre-8.34.tar.gz】

shell>#./configure --prefix=/usr/local/pcre

shell>#make && make install

==========================================================

安装apache2.4【httpd-2.4.27.tar.gz】

shell>#tar zxvf httpd-2.4.27.tar.gz

shell>#cd httpd-2.4.27

shell>#./configure --prefix=/usr/local/apache2.4 \

--with-apr=/usr/local/apr1.6 \

--with-apr-util=/usr/local/apr-util1.4 \

--with-pcre=/usr/local/pcre \

--enable-modules=all \

--enable-mods-shared=all \

--enable-so \

--enable-rewrite

安装zlib【zlib-1.2.11.tar.gz】

shell>#tar zxvf zlib-1.2.11.tar.gz

shell>#cd zlib-1.2.11

shell>#./configure

shell>#make && make install

============================================================

安装libxml2【libxml2-2.7.3.tar.gz】

shell>#tar zxvf libxml2-2.7.3.tar.gz

shell>#cd libxml2-2.7.3

shell>#./configure --prefix=/usr/local/libxml2  \

--without-zlib

shell>#make && make install

=========================================================

安装jpeg【jpegsrc.v9b.tar.gz】

shell>#tar zxvf jpegsrc.v9b.tar.gz

shell>#cd jpegsrc.v9b

shell>#./configure --prefix=/usr/local/jpeg \

--enable-shared --enable-static

make && make install

==================================================

安装libpng【libpng-1.6.30.tar.gz】

shell>#tar zxvf libpng-1.6.30.tar.gz

shell>#cd libpng-1.6.30

shell>#./configure --prefix=/usr/local/png  \

--enable-shared --enable-static

shell>#make  && make install

==========================================================

安装字体库freetype【freetype-2.5.5.tar.gz】

shell>#tar zxvf freetype-2.5.5.tar.gz

shell>#cd freetype-2.5.5

shell>#./configure --prefix=/usr/local/freetype

shell>#make && make install

===============================================

安装libgd【libgd-2.1.1.tar.gz】

【本人安装php的时候出现一个错误,无法找到一个关于gd的一个文件】,因此在装gd的时候不要指定安装目录

shell>#tar zxvf libgd-2.1.1.tar.gz

shell>#cd libgd-2.1.1

shell>#./configure --with-jpeg=/usr/local/jpeg/ \

--with-png=/usr/local/png/ \

--with-zlib \

--with-freetype=/usr/local/freetype

shell>#make && make install

==========================================================

安装php5.6:【php-5.6.31.tar.gz】

shell>#tar zxvf php-5.6.31.tar.gz

shell>#cd php-5.6.31

shell>#./configure --prefix=/usr/local/php5.6 \

--with-apxs2=/usr/local/apache2.4/bin/apxs \

--with-mysql=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-mysqli=mysqlnd \

--with-freetype-dir=/usr/local/freetype \

--with-gd \

--with-zlib --with-libxml-dir=/usr/local/libxml2 \

--with-jpeg-dir=/usr/local/jpeg \

--with-png-dir=/usr/local/png \

--enable-mbstring=all \

--enable-mbregex \

--enable-shared

shell>#make  &&  make install

shell>#cp php.ini-development /usr/local/php5.6/lib/php.ini

=============================================

配置Apache使其支持php

vi /usr/local/apache2.4/conf/httpd.conf

1)      在httpd.conf(Apache主配置文件)中增加:

AddType application/x-httpd-php .php

2)      找到下面这段话:

DirectoryIndex index.html

在index.html 前面添加index.php

nginx 的安装

下载地址: http://nginx.org/download/nginx-1.4.2.tar.gz

安装准备: nginx依赖于pcre库,要先安装pcre

shell># yum install pcre pcre-devel

shell># cd /usr/local/src/

shell># wget http://nginx.org/download/nginx-1.4.2.tar.gz

shell># tar zxvf nginx-1.4.2.tar.gz

shell># cd nginx-1.4.2

shell># ./configure --prefix=/usr/local/nginx

shell># make && make install

nginx+php的编译

apache一般是把php当做自己的一个模块来启动的.

而nginx则是把http请求变量(如get,user_agent等)转发给 php进程,即php独立进程,与nginx进行通信. 称为 fastcgi运行方式.

因此,为apache所编译的php,是不能用于nginx的.

注意: 我们编译的PHP 要有如下功能:

连接mysql, gd, ttf, 以fpm(fascgi)方式运行

老师编译php的参数(未亲测):

shell># ./configure  --prefix=/usr/local/fastphp \

--with-mysql=mysqlnd \

--enable-mysqlnd \

--with-gd \

--enable-gd-native-ttf \

--enable-gd-jis-conv

--enable-fpm

自己编译php采用的是如下参数(亲测成功):

shell>#./configure --prefix=/usr/local/php5.6.nginx \

--with-mysql=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-mysqli=mysqlnd \

--with-freetype-dir=/usr/local/freetype \

--with-gd \

--with-zlib --with-libxml-dir=/usr/local/libxml2 \

--with-jpeg-dir=/usr/local/jpeg \

--with-png-dir=/usr/local/png \

--enable-mbstring=all \

--enable-mbregex \

--enable-shared \

--enable-fpm

shell># make && make install

编译安装完后

shell># cp /usr/local/fastphp/etc/php-fpm.conf.default  /usr/local/fastphp/etc/php-fpm.conf

shell># cd /home/jinnan/upload/php-5.6.31

shell>#cp php.ini-development  /usr/local/php5.6.nginx/lib/php.ini

编译完毕后:

1:

nginx+php的配置比较简单,核心就一句话----

把请求的信息转发给9000端口的PHP进程,

让PHP进程处理 指定目录下的PHP文件.

如下例子:

location ~ \.php$ {

root html;

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

include        fastcgi_params;

}

1:碰到php文件,

2: 把根目录定位到 html,

3: 把请求上下文转交给9000端口PHP进程,

4: 并告诉PHP进程,当前的脚本是 $document_root$fastcgi_scriptname

(注:PHP会去找这个脚本并处理,所以脚本的位置要指对)

=================================================

由于mysql使用更高级的cmake安装,在安装mysql前要先安装cmake

安装cmake:【cmake-3.8.2.tar.gz】

shell>#tar zxvf cmake-3.8.2.tar.gz

shell>#cd cmake-3.8.2

shell>#./bootstrap

shell>#make && make install

安装mysql5.6【mysql-5.6.37.tar.gz】

shell>#tar zxvf mysql-5.6.37.tar.gz

shell>#cd mysql-5.6.37

shell>#cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.6

\

-DMYSQL_DATADIR=/usr/local/mysql/data

\

-DDEFAULT_CHARSET=utf8

\

-DDEFAULT_COLLATION=utf8_general_ci

以上编译参数说明(准备安装到那里

数据存储目录

默认的字符集

校对字符集)

如果出现如下错误:(安装ncurses-devel)

安装(ncurses-devel):

将之前装系统的.iso文件挂载到光驱

由于我在/home/jinnan/下建立了一个cdrom文件夹

Shell>#mount /dev/cdrom  /home/jinnan/cdrom

Shell># cd /home/jinnan/cdrom

Shell># ls

Shell># cd Packages

Shell>#ls | grep ncurses-devel

Shell># rpm -ivh

ncurses-devel-5.7-3.20090208.el6.x86_64.rpm

重新进入到mysql解压后的目录

Shell>#cd mysql-5.6.37

一定要删除CMakeCache.txt,否则重新cmake会报错

Shell># rm -f

CMakeCache.txt    //删除该文件

重新cmake

Shell># cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.6

\

-DMYSQL_DATADIR=/usr/local/mysql/data

\

-DDEFAULT_CHARSET=utf8

\

-DDEFAULT_COLLATION=utf8_general_ci

Shell>#make && make install

复制配置文件

shell># cp support-files/my-default.cnf

/etc/my.cnf

配置并初始化MySQL

shell># useradd  mysql   (该mysql用户会存在于同名的组下)

shell># chmod +x /usr/local/mysql5.6

(数据库用户信息不小心删除光了,删除data目录,从此开始执行以下指令,直至结束)

shell># chown -R mysql.mysql

/usr/local/mysql5.6

初始化mysql数据库

shell># /usr/local/mysql5.6/scripts/mysql_install_db

\

--user=mysql

\

--basedir=/usr/local/mysql5.6

\

--datadir=/usr/local/mysql5.6/data

&

把mysql安装文件(除了data)的主人都改为root,避免数据库恢复为出厂设置。

shell># chown -R root /usr/local/mysql5.6

shell># chown -R mysql /usr/local/mysql5.6/data

& 后台运行mysql服务

shell>#

/usr/local/mysql5.6/bin/mysqld_safe --user=mysql &

//查看mysql是否有启动

shell>#

ps –A | grep mysql

测试数据库

shell># /usr/local/mysql5.6/bin/mysql

–u root

mysql> show databases;

接上步,修改mysql密码(可不做此步,默认无密码)

Mysql>use mysql

mysql> delete from

user where host != 'localhost';

mysql> delete from

user where user != 'root';

mysql> update user set

password=password('root') where user='root';

mysql> flush

privileges;

如果希望在任何一个目录下都可以进入mysql数据库,则需要在/root/.bash_profile中添加mysql命令的路径:/home/mysql/bin

如果要让所有用户都能够在所有目录下进入mysql数据库,那么修改环境变量 /etc/profile

配置开机自启动服务项

shell># cp 安装包解压目录/support-files/mysql.server

/etc/init.d/mysqld

shell># chmod +x /etc/init.d/mysqld

shell># chkconfig --add mysqld

shell># chkconfig mysqld on    //设置开机自启动

配置文件路径:

shell># vi /etc/rc.d/rc.local

在  文件中增加启动相关服务的命令如下:

/usr/local/apache2.4/bin/apachectl

start

/usr/local/mysql5.6/bin/mysqld_safe

--user=mysql &

service

vsftpd start

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com

特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值