CentOS   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了CentOS 6.5安装LAMP+Redis+Security.so的整合大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

本章节中用到的所有软件下载链接: http://pan.baidu.com/s/1cFnyDS 密码: k2a7 1、安装编译工具: yum -y install glibc-devel-2.* gcc-4.* gcc-c++-4.* libaio-devel-0.* libstdc++-devel-4.* 2、检查并卸载默认的低版本环  rpm -qa |grep -i http rpm -qa

本章节中用到的所有软件下载链接: http://pan.baidu.com/s/1cFnyDS 密码: k2a7



1、安装编译工具:

yum -y install glibc-devel-2.* gcc-4.* gcc-c++-4.* libaio-devel-0.* libstdc++-devel-4.*

2、检查并卸载认的低版本环

rpm -qa |grep -i http

rpm -qa |grep -i MysqL

rpm -qa |grep -i PHP

rpm -e 软件包名 进行卸载。

【开始搭建LAMP环境】


搭建LAMP环境时,需要安装的所有软件都要按照一定的顺序安装,我们按照Apache->MysqL->PHP的顺序安装。但是在安 装PHP之前,应先安装PHP5需要的最新版本库文件,例如libxml2、libmcrypt,以及GD2库等文件。安装GD2库是为了让PHP5支持 GIF、PNG和JPEG图片格式,所以在安装GD2库之前还要先安装最新的zlib、libpng、freetype和jpegsrc等库文件。而且中 间还会穿插安装一些软件。


1、解压tar.gz为后缀的压缩包软件

LAMP环境搭建所需要的每个软件的源代码文件,都是以.tar.gz提供给我们的打包压缩文件,所以我们必须将其解压再解包。

批量解压命令:for i in `ls ./`;do tar -xf $i;done

在linux系统中源代码包安装过程

进行解压后的目录,LAMP环境搭建所需要的软件都使用C语言开发的,所以安装源代码文件最少需要配置(configurE)、编译(makE)、安装(make install)三个步骤。


2、安装libtools

./configure

make && make install && echo OK

3、安装libxml2最新库文

./configure --prefix=/usr/local/libxml2

make && make install && echo OK

注:解析报错信息为:/bin/rm: cAnnot remove `libtoolT': No such file or directory

解决方法:这时直接打开 configure,把 $RM “$cfgfile” 那行删除掉,重新再运行 ./configure 就可以了。


4、安装libmcrypt最新库文件

安装方法与上面安装libxml2方法相同,注意configure时的路径/usr/local/libmcrypt

如果安装成功就会在/usr/local/libmcrypt/目录下生成bin,include,lib,man,share五个目录。然后在安 装PHP5源代码包的配置时,就可以通过configure命令加上“--with-mcrypt-dir=/usr/local/libmcrypt” 选项,指定这个libmcrypt库文件的位置。


如./configure时报错:configure: error: C++ compiler cAnnot create executables 。

解决方案:

运行下面命令,然后重新configure(配置)

yum install gcc gcc-c++ gcc-g77

安装完成libmcrypt库以后,不同的linux系统版本有可能还要安装一下libltdl库。安装方法和前面的步骤相同,可以进入到解压缩的 目录/usr/local/src/libmcrypt-2.5.8下,找到libltdl库源代码所在的目录libltdl,进入这个目录按照下面几个 命令配置、编译、安装就可以了。

a.先安装libltdl

/usr/local/src/libmcrypt-2.5.8/libltdl

./configure --enable-ltdl-install

make && make install && echo OK

b、安装libmcrypt

./configure --prefix=/usr/local/libmcrypt

make && make install && echo OK


5、安装zlib最新库文件

./configure --prefix=/usr/local/zlib

make && make install && echo OK


6、安装libpng最新库文件

./configure --prefix=/usr/local/libpng

make && make install && echo OK

注:如果提示:configure: error: ZLib not installed

解决方法如下:

1.进入zlib的源文件目录,执行命令 make clean,清除zlib;

2.重新配置 ./configure,后面不要接--prefix参数;


3.make && make install;

4.进入libpng目录,执行命令 ./configure --prefix=/usr/local/libpng;

5.make && make install;

6.安装成功.



7、安装jpeg8最新库文件

mkdir -p mkdir /usr/local/jpeg8/{Bin,man/man1}

./configure --prefix=/usr/local/jpeg8 --enable-share --enable-static

@H_210_26@make && make install && echo OK


8、安装freetype最新库文件

cd /usr/local/src/freetype-2.6.3/builds/unix

./configure --prefix=/usr/local/freetype

cd -

make && make install && echo OK


9、安装autoconf最新的库文件

./configure --prefix=/usr/local/autoconf

make && make install && echo OK


10、安装最新的GD库文件

./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg8/ --with-png=/usr/local/libpng/ --with-freetype=/usr/local/freetype/ --with-zlib=/usr/local/zlib/

make && make install && echo OK

如果报错:

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"


11、安装新版本的apache服务器

a.卸载系统自带的apr、apr-util

yum remove apr apr-util -y

b. 安装apr 、apr-util

./configure --prefix=/usr/local/apr-httpd/ && make && make install

./configure --prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr-httpd/ && make && make install

c、安装pcre

./configure --prefix=/usr/local/pcre

@H_210_26@make && make install && echo OK

d、安装apache

./configure --prefix=/usr/local/apache243 --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--with-mpm=prefork

@H_210_26@make && make install && echo OK

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

bin build cgi-bin error htdocs icons include logs man manual modules

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

#/usr/local/apache243/bin/apachectl start

# httpd -l

Compiled in modules:

core.c

prefork.c

http_core.c

mod_so.c


提示信息:

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

解决方案:

vi /etc/httpd/httpd.conf

加上下面一行,重启apache

ServerName localhost:80


设置开机启动httpd:

echo "/usr/local/apache243/bin/apachectl start" >> /etc/rc.d/rc.local


12、安装MysqL数据库管理系统

a、增加用户名用户

#groupadd MysqL

#useradd -g MysqL MysqL -m /sbin/nologin

b、安装MysqL

注:checking for termcap functions library... configure: error: No curses/termcap library found解决

yum -y install ncurses-devel

./configure --prefix=/usr/local/MysqL --enable-thread-safe-client --with-extra-charsets=all

make && make install && echo OK

(选:

创建MysqL数据库服务器的配置文件,可以使用源码包support-files目录中的my-medium.cnf文件作为模板,将其复制到/etc/目录下,命名为my.cnf文件即可。

[root@localhost MysqL-5.0.18]# cp support-files/my-medium.cnf /etc/my.cnf


1、如果还没安装过MysqL,必须创建MysqL授权表。进入到安装目录/usr/local/MysqL下,执行bin目录下的MysqL_install_db脚本,用来初始化MysqL数据库的授权表,其中存储了服务器访问允许。


[root@localhost MysqL-5.0.18]#cd /usr/local/MysqL

[root@localhost MysqL]# bin/MysqL_install_db --user=MysqL @R_197_9789@授权表


如果使用root用户运行上面的命令,应当使用--user选项,选项的值应当与你在第一步为运行服务器所创建的登录账户(MysqL用户)相同。 如果用MysqL用户登录来运行上面的命令,可以省略--user选项。用MysqL_install_db创建MysqL授权表后,需要手动重新启动服 务器。


2、将程序二进制的所有权改为root用户,数据目录的所有权改为运行MysqLd程序的MysqL用户。如果现在位于安装目录(/usr/local/MysqL)下,命令行如下:

[root@localhost MysqL]# chown -R root .(注意有点) //将文件的所有属性改为root用户

[root@localhost MysqL]# chown -R MysqL var //将数据目录的所有属性改为MysqL用户

[root@localhost MysqL]# chgrp -R MysqL . //将组属性改为MysqL

[root@localhost MysqL]# ls -l

@R_798_10586@l 40

drwxr-xr-x. 2 root MysqL 4096 Feb 7 20:50 bin

drwxr-xr-x. 3 root MysqL 4096 Feb 7 20:50 include

drwxr-xr-x. 2 root MysqL 4096 Feb 7 20:50 info

drwxr-xr-x. 3 root MysqL 4096 Feb 7 20:50 lib

drwxr-xr-x. 2 root MysqL 4096 Feb 7 20:50 libexec

drwxr-xr-x. 3 root MysqL 4096 Feb 7 20:50 man

drwxr-xr-x. 7 root MysqL 4096 Feb 7 20:50 MysqL-test

drwxr-xr-x. 3 root MysqL 4096 Feb 7 20:50 share

drwxr-xr-x. 5 root MysqL 4096 Feb 7 20:50 sql-bench

drwx------. 4 MysqL MysqL 4096 Feb 7 20:53 var


3、在所需要的东西被安装完成后,应当使用下面的命令启动MysqL服务了,命令行如下:

[root@localhost MysqL]#/usr/local/MysqL/bin/MysqLd_safe --user=MysqL &

报告信息(不理会):

[root@localhost MysqL]# /usr/local/MysqL/bin/MysqLd_safe --user=MysqL &

[1] 4720

[root@localhost MysqL]# nohup: ignoring input and redirecTing stderr to stdout

StarTing MysqLd daemon with databases from /usr/local/MysqL/var

4、MysqL数据库服务器启动之后,查看一下它的端口3306是否打开,如果看到以下结果表明MysqL服务启动成功。命令行如下

[root@localhost MysqL]# netstat -tnl|grep 3306

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN

5、使用MysqLadmin验证服务器在运行中。以下命令提供了简单的测试,可检查服务器是否已经开启并能响应连接。命令行如下:

[root@localhost MysqL]# bin/MysqLadmin version

Enter password:

bin/MysqLadmin Ver 8.41 DiStrib 5.0.18,for pc-linux-gnu on i686

Copyright (C) 2000 MysqL AB & MysqL Finland AB & TCX DataKonsult AB

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL license

Server version 5.0.18-log

Protocol version 10

Connection Localhost via UNIX socket

UNIX socket /tmp/MysqL.sock

Uptime: 18 min 59 sec

Threads: 1 Questions: 3 Slow queries: 0 Opens: 0 Flush tables: 1 Open tables: 6 Queries per second avg: 0.003

[root@localhost MysqL]# bin/MysqLadmin variables //查看所有MysqL参数

6、设置访问权限,在MysqL@R_969_9382@,使用MysqL_install_db程序安装了MysqL数据库授权表,表定义了初始MysqL用户 账户和访问权限,所有初始化账户均没有密码。这些账户为超用户账户,可以执行任何操作。初始root账户的密码为空,因此任何人可以用root账户不用任 何密码来连接MysqL服务器,并具有所有权限,这意味着MysqL安装未受保护。如果你想要防止客户端不使用密码用匿名用户来连接,你应当为匿名账户指 定密码或删掉匿名帐户,应当为MysqL root账户指定密码。使用MysqL -u root启动MysqL客户端控制台,连接MysqL服务器。命 令行如下:

[root@localhost MysqL]# bin/MysqL -u root //没有密码可直接登录本机服务器

Welcome to the MysqL monitor. Commands end with ; or \g.

Your MysqL connection id is 5 to server version: 5.0.18-log

Type 'Help;' or '\h' for Help. Type '\c' to clear the buffer.

如果有匿名账户存在,它拥有全部的权限,因此删掉它可以提高安全,在MysqL客户端执行sql语如下:

MysqL> delete from MysqL.user where host='localhost' and user='';

Query OK,1 row affected (0.01 seC)

MysqL> flush privileges;

Query OK,0 rows affected (0.00 seC)

7、可以用几种方法为root账户指定密码,我们选择用其中的一种。在MysqL客户端命令行上使用set password指定密码,一定要使 password()函数来加密密码。例如下面设置localhost域的密码为ios100。其他域可以使用同样的语句,使用的sql语句如下。

MysqL> set password for 'root'@'localhost'=password('ios100');

Query OK,0 rows affected (0.00 seC)

8、如果想退出MysqL客户端,可以在MysqL客户端提示符下输入命令exit或者quit,还可以按键盘ctrl+c组合键,都可以从 MysqL客户端退出。因为已经给MysqL服务器的root账号设置了密码,所以再次登录MysqL客户端就要提供密码才能进入。退出MysqL客户端 和重新启动MysqL客户端的控制台命令如下。

MysqL> exit

Bye

[root@localhost MysqL]# bin/MysqL -u root -h localhost -p

Enter password:

Welcome to the MysqL monitor. Commands end with ; or \g.

Your MysqL connection id is 6 to server version: 5.0.18-log

Type 'Help;' or '\h' for Help. Type '\c' to clear the buffer.

如果想关闭MysqL服务器,在命令行使用MysqL服务器的MysqLadmin命令,通过-u参数给出MysqL数据库@R_419_2484@用户名root和通过-p参数给出密码,即可关闭MysqL服务器。如下示:

[root@localhost MysqL]# bin/MysqLadmin -u root -p shutdown

Enter password:

STOPPING server from pid file /usr/local/MysqL/var/localhosT.PID

130207 21:27:05 MysqLd ended

[1]+ Done /usr/local/MysqL/bin/MysqLd_safe --user=MysqL

9、MysqL服务器和apache服务器一样也有必要设置为开机自动运行,设置方法进入到MysqL代码目录/usr/local/src /MysqL-5.0.18,将子目录support-files下的MysqL.server文件复制到/etc/rc.d/init.d目录中,并重 命名为MysqLd,命令行如下。

[root@localhost MysqL]# cd /usr/local/src/MysqL-5.0.18

[root@localhost MysqL-5.0.18]# cp support-files/MysqL.server /etc/rc.d/init.d/MysqLd

修改一下权限

[root@localhost MysqL-5.0.18]# chown root.root /etc/rc.d/init.d/MysqLd

[root@localhost MysqL-5.0.18]# chmod 755 /etc/rc.d/init.d/MysqLd

MysqLd添加到chkconfig

[root@localhost MysqL-5.0.18]# chkconfig --add MysqLd

在图形和字符集界面下自动启动MysqLd

[root@localhost MysqL-5.0.18]# chkconfig --level 3 MysqLd on

[root@localhost MysqL-5.0.18]# chkconfig --level 5 MysqLd on

再使用chkconfig --list命令检查设置

[root@localhost MysqL-5.0.18]# chkconfig --list MysqLd

MysqLd 0:off 1:off 2:on 3:on 4:off 5:on 6:off

)

13、安装最新版的PHP模块


./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-libxml-dir=/usr/local/libxml2 --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg8 --with-freetype-dir=/usr/local/freetype --with-gd=/usr/local/gd --with-zlib-dir=/usr/local/zlib --with-mcrypt=/usr/local/libmcrypt --with-MysqLi=/usr/local/MysqL/bin/MysqL_config --enable-soap --enable-mbString=all --enable-sockets--disable-maintainer-zts


ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/

@H_210_26@make ZEND_EXTRA_LIBS='-liconv'

注:报错信息:

If configure fails try --with-vpx-dir=<DIR> configure: error: jpeglib.h not found.


解决方法

yum -y install libjpeg-devel

重新./configure

@H_210_26@make(配置)

提示信息:

Build complete.

Don't forget to run 'make test'.

解决方案:

不要make test 直接make install

配置时可能会出现下面的错误:

checking for MysqL support... yes

checking for specified LOCATIOn of the MysqL UNIX socket... no

checking for MysqL UNIX socket LOCATIOn... no

configure: error: CAnnot find libMysqLclient_r under /usr/local/MysqL. Note that the MysqL client library is not bundled anymore!

其实这跟PHP没有关系,那是因为在编译APACHE的时候,使用--with-mpm模块,所以就必须在编译MysqL的时候加上 --enable-thread-safe-client.参数

这是PHP5.2的一个改进,在PHP5.2.0之前的版本都不需要MysqL启用安全线程。关于--enable-thread-safe- client项的官方介绍如下:如何生成线程式客户端库总是线程安全的。最大的问题在于从套接字读取的net.c中的子程序并不是中断安全的。或许你可能 希望用自己的告警中断对服务器的长时间读取,以此来解决问题。如果为SIGPIPE中断安装了中断处理程序,套接字处理功能应是线程安全的。 SupeSite/X-为了避免连接中断时放弃程序,MysqL将在首次调用MysqL_server_init()、MysqL_init()或 MysqL_connect()时屏蔽SIGPIPE。如果你打算使用自己的SIGPIPE处理程序,首先应调用 MysqL_server_init(),然后安装你的处理程序.

还有第二种解决方法比较方便 :编译之前,先处理一下MysqL的库,认查找libMysqLclient_r.so,可是MysqL认为libMysqLclient.so内容完全一样,做个链接即可


# cd /usr/local/MysqL/lib/MysqL/

# ln -s libMysqLclient.so.15.0.0 libMysqLclient_r.so

(以上解决方法来自互联网!)

还会报make: *** [ext/gd/gd.lo] error

解决方法如下:

好像说这个错误算是PHP5.4的bug,下面对应的两篇文章有对应的说明:

https://bugs.PHP.net/bug.PHP?id=55224

https://bugs.PHP.net/bug.PHP?id=60108

解决方法

vi <gd_dir>/include/gd_io.h

gdioCtx结构中增加void *data;

格式如下

typedef struct gdioCtx

{

int (*getC) (struct gdioCtx *);

int (*getBuf) (struct gdioCtx *,void *,int);

void (*putC) (struct gdioCtx *,int);

int (*putBuf) (struct gdioCtx *,const void *,int);

/* seek must return 1 on succesS,0 on FAILURE. Unlike fseek! */

int (*seek) (struct gdioCtx *,const int);

long (*tell) (struct gdioCtx *);

void (*gd_freE) (struct gdioCtx *);

void (*data);

}

gdioCtx;

我的GD安装在/usr/local/gd2目录下,所以是#vi vi /usr/local/gd/include/gd_io.h

libltdl.so.3: cAnnot open shared object file: No such file or directory

make: *** [ext/phar/phar.PHP] Error 127

解决方法

ln -s /usr/local/lib/libltdl.so.3 /usr/lib/libltdl.so.3

[root@localhost ~]# cd /usr/local/libpng/lib/

[root@localhost lib]# ls

libpng15.a libpng15.so libpng15.so.15.10.0 libpng.la pkgconfig

libpng15.la libpng15.so.15 libpng.a libpng.so

可以看到libpng15.so.15

然后修改/etc/ld.so.conf 文件:vi /etc/ld.so.conf

在第一行下面追加/usr/local/libpng/lib这个路径。

然后重新编译安装即可。

提示信息:

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

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

WARNED TEST SUM@R_197_11035@

---------------------------------------------------------------------

Bug #52062 (large timestamps with datetiR_651_11845@e::gettimestamp and datetiR_651_11845@e::settimestamp) (32 bit) [ext/date/tests/bug52062.PHPt] (warn: XFAIL section but test passes)

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

You may have found a problem in PHP.

This report can be automatically sent to the PHP QA team at

http://qa.PHP.net/reports and http://news.PHP.net/PHP.qa.reports

This gives us a better understanding of PHP's behavior.

If you don't want to send the report immediately you can choose

option "s" to save it. You can then email it to qa-reports@lists.PHP.net later.

Do you want to send this report Now? [Yns]:

解决方案:

不要make test 直接make install

安装完成后,需要建立PHP配置文件


使用COnfigure命令安装配置时使用“--with-config-file-path=/usr /local/PHP/etc/”选项,指定了配置文件的位置。


将源码包下面的PHP.ini-development 文件复制到/usr/local /PHP/etc/中,并改名为PHP.ini即可,如下示:


[root@localhost PHP-5.4.11]# cp PHP.ini-development /usr/local/PHP/etc/PHP.ini

修改PHP.ini 把;date.timezone 前面的分号去掉,改成date.timezone ="PRC"

整合Apache与PHP,上面编译之前,我们使用COnfigure命令安装配置时,使用--with-apxs2=/usr/local /apache242/bin/apxs选项以使Apache

PHP作为功能模块使用。但我们还要修改Apahce配置文件添加PHP支持,告 诉Apache将哪些后缀作为PHP解析。例如,让Apache把.PHP或.phtml后缀名解析为PHP.使用vi打开Apache的配置文件 /etc/httpd/httpd.conf,找到AddType application/x-gzip .gz .tgz指令选项,并在其下方添加一 条指令AddType application/x-httpd-PHP .PHP .phtml。也可以将任何后缀的文件解析为PHP,只要在添加的语 句中加入并用空格分开,这里以多添加一个.phtml来示例,

如下示:

# If the AddEncoding directives above are commented-out,then you

# probably should define those extensions to inDicate media types:

#

AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

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

注:PHP-redis的整合请参http://code.js-code.com/article/p-vbeoqzxa-ty.html


修改完成后必须重启Apache服务器,才能重新加载配置文件使修改生效。

[root@localhost PHP-5.4.11]#/usr/local/apache243/bin/apachectl stop

[root@localhost PHP-5.4.11]#/usr/local/apache243/bin/apachectl start

[root@localhost]# PHP -m

[root@localhost ~]# /usr/local/PHP/bin/PHP -m

[PHP Modules]

bcmath

bz2

Core

ctype

curl

date

dom

ereg

fileinfo

filter

gd

gettext

hash

iconv

json

libxml

@H_386_14@mbString

@H_386_14@mcrypt

MysqLi

MysqLnd

openssl

pcre

PDO

pdo_sqlite

Phar

posix

redis

Reflection

security

session

SimpleXML

sockets

SPL

sqlite3

standard

tokenizer

xml

xmlreader

xmlwriter

zip

zlib


看到以上标红的两个模块后证明你的PHP成功整合了redis和security的模块;


测试PHP环境是否可以正常运行,在/usr/local/apache243/htdocs目录下建一个test.PHP或test.phtml的文件内容如下示:

<?PHP

PHPinfo();

?>


打开浏览器,在地址栏输入@L_366_450@


CentOS 6.5安装LAMP+Redis+Security.so的整合

大佬总结

以上是大佬教程为你收集整理的CentOS 6.5安装LAMP+Redis+Security.so的整合全部内容,希望文章能够帮你解决CentOS 6.5安装LAMP+Redis+Security.so的整合所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。