centos6系统下LAMP环境搭建

以下安装包的原文件都放在/usr/local/src目录下。

 

1、安装libxml2

#cd /usr/local/src/libxml2-2.6.30

#./configure --prefix=/usr/local/libxml

#make && make install

2、安装libmcrypt

# cd /usr/local/src/libmcrypt-2.5.8
# ./configure --prefix=/usr/local/libmcrypt

出现错误

make[1]: Entering directory `/usr/local/src/libmcrypt-2.5.8'
Making all in modules
make[2]: Entering directory `/usr/local/src/libmcrypt-2.5.8/modules'
make[2]: *** 没有规则可以创建目标“all”。 停止。
make[2]: Leaving directory `/usr/local/src/libmcrypt-2.5.8/modules'
make[1]: *** [all-recursive] 错误 1
make[1]: Leaving directory `/usr/local/src/libmcrypt-2.5.8'
make: *** [all] 错误 2

出错原因是没有安装g++

安装g++  

yum -y install gcc-c++

重新configure

3、安装zlib

# cd /usr/local/src/zlib-1.2.3
# ./configure --prefix=usr/local/zlib
# make && make install

4、安装libpng

# cd /usr/local/src/libpng-1.2.31
# ./configure --prefix=/usr/local/libpng

出现错误

configure: error: zlib not installed

# make && make install

解决方案是:

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

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

3.编辑 && 安装;(make && make install)

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

5.编译 && 安装;

6.安装成功;

5、安装jpeg6

这个软件包安装有些特殊,其它软件包安装时如果目录不存在,会自动创建,但这个软件包安装时需要手动创建。

# mkdir /usr/local/jpeg6
# mkdir /usr/local/jpeg6/bin
# mkdir /usr/local/jpeg6/lib
# mkdir /usr/local/jpeg6/include
# mkdir -p /usr/local/jpeg6/man/man1

# cd /usr/local/src/jpeg-6b
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static


错误

checking host system type... Invalid configuration `x86_64-unknown-linux-gnu': machine `x86_64-unknown' not recognized


原因是我centos6为64位版本

 解决方法是:

把 /usr/share/libtool/config.guess 覆盖到相关软件自带的config.guess 
把 /usr/share/libtool/config.sub 覆盖到相关软件自带的config.sub

若在libtool中找不到两个文件,yum -y install libtool

再执行覆盖拷贝,完成后:

# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static

# make && make install


6、安装freetype

# cd /usr/local/src/freetype-2.3.5
# ./configure --prefix=/usr/local/freetype
# make
# make install

7、安装autoconf

# cd /usr/local/src/autoconf-2.61
# ./configure
# make && make install

8、安装GD库

# cd /usr/local/src/gd-2.0.35
# ./configure \
--prefix=/usr/local/gd2/ \
--enable-m4_pattern_allow \
--with-zlib=/usr/local/zlib/ \
--with-jpeg=/usr/local/jpeg6/ \
--with-png=/usr/local/libpng/ \
--with-freetype=/usr/local/freetype/

# make

出现错误:

make[2]: *** [gd_png.lo] Error 1
make[2]: Leaving directory `/usr/local/src/gd-2.0.35'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/gd-2.0.35'
make: *** [all] Error 2

分析:这个问题是因为gd库中的gd_png.c这个源文件中包含png.h时,png.h没有找到导致的。

解决:

在编译文件里

# vi gd_png.c

将include “png.h” 改成 include “/usr/local/libpng/include/png.h”

其中/usr/local/libpng/为libpng安装路径。

# make install

9、安装Apache

# cd /usr/local/src/httpd-2.2.9
# ./configure \
--prefix=/usr/local/apache2 \
--sysconfdir=/etc/httpd \
--with-z=/usr/local/zlib \
--with-included-apr \
--enable-so \
--enable-deflate=shared \
--enable-expires=shared \
--enable-rewrite=shared \
--enable-static-support


缺失 APR  APR-util
configure: error: Bundled APR requested but not found at ./srclib/.Download and unpack the corresponding apr and apr-util packages to ./srclib/.

解决办法:
APRAPR-util源码下载,解压放到httpd-2.4.3/srclib里面,并去除版本号
cp -r apr-1.4.6 httpd-2.4.3/srclib/apr
cp -r apr-util-1.4.1 httpd-2.4.3/srclib/apr-util

完成后configure

出现错误

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
下载pcre  安装,目录为:/usr/local/pcre

# ./configure \
--prefix=/usr/local/apache2 \
--sysconfdir=/etc/httpd \
--with-z=/usr/local/zlib \
--with-included-apr \
--enable-so \
--enable-deflate=shared \
--enable-expires=shared \
--enable-rewrite=shared \
--enable-static-support

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

make && make install

启动服务器

启动Apache
# /usr/local/apache2/bin/apachectl start

出现错误

AH00557: httpd: apr_sockaddr_info_get() failed for linux.64.114
AH00558: httpd: Could not reliably determine the server's fully qualified domain

name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this

这个问题应该是没有在 /etc/httpd/httpd.conf 中设定 ServerName。所以apache会用主机上的名称来取代,首先会去找 /etc/hosts 中有没有主机的定义。

所以要解决这个问题可以设定httpd.conf文件中的 ServerName,如下:

   (1) ServerName localhost:80                        

   或者在 /etc/hosts 中填入自己的主机名称 ex,如下

   (2)127.0.0.1 ex


建议使用第一种方法,第二种方法只能解决当前的问题。


(关闭Apache
# /usr/local/apache2/bin/apachectl stop)

查看80端口是否开启
# netstat -tnl|grep 80

访问Apache服务器

在浏览器中输入http://localhost/

页面中显示It works!证明安装成功。

添加开机自启动
# echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.local

安装oracle

MySQL 5.6.4-m7

1. 安装mysql(mysql 5.5.x 不再用 configure,而用cmake

[root@localhost src]# tar -zxvf cmake-2.8.4.tar.gz
[root@localhost src]# cd cmake-2.8.4
[root@localhost src]# ./configure && make && make install

安装Mysql

添加一个mysql标准组
# groupadd mysql

添加mysql用户并加到mysql组中
# useradd -g mysql mysql

# cd /usr/local/src/MySQL 5.6.4-m7

# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
        -DMYSQL_DATADIR=/usr/local/mysql/data \
        -DWITH_MYISAM_STORAGE_ENGINE=1 \
        -DWITH_INNOBASE_STORAGE_ENGINE=1 \
        -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
        -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
        -DENABLED_LOCAL_INFILE=1 \
        -DDEFAULT_CHARSET=utf8 \
        -DDEFAULT_COLLATION=utf8_general_ci \
        -DEXTRA_CHARSETS=all \
        -DMYSQL_TCP_PORT=3306 \
        -DMYSQL_USER=mysql

出现错误

-- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:83 (MESSAGE):
  Curses library not found.  Please install appropriate package,

分析:缺少ncurses安装包

解决:

# yum install ncurses-devel

再删除刚才编译生成的 CMakeCache.txt 文件
rm CMakeCache.txt
再次执行一次cmake ... 

创建MySQL数据库服务器的配置文件
# cp support-files/my-medium.cnf /etc/my.cnf

用mysql用户创建授权表,创建成功后,会在/usr/local/mysql目录下生成一个var目录
# /usr/local/mysql/scripts目录下

 ./mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ --user=mysql

安装完后有这么一段提示

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h lizhendong password 'new-password'

Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/mysql/scripts/mysqlbug script!

# cp support-files/mysql.server /etc/init.d/mysqld
[root@lizhendong mysql-5.6.4-m7]# chmod +x /etc/init.d/mysqld
[root@lizhendong mysql-5.6.4-m7]# chkconfig --add mysqld
[root@lizhendong mysql-5.6.4-m7]# chkconfig --level 35 mysqld on

13、Mysql安全性设置

没有密码可以直接登录本机服务器
# /usr/local/mysql/bin/mysql -u root

查看mysql用户权限信息
mysql> select * from mysql.user;


删除非localhost的主机
mysql> DELETE FROM mysql.user WHERE Host='localhost' AND User='';


刷新授权表
mysql> FLUSH PRIVILEGES;


为root用户添加密码
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('Apple123');

退出客户端

mysql>exit

再次进入Mysql客户端
# /usr/local/mysql/bin/mysql -u root -h localhost -p


关闭MySQL数据库
# /usr/local/mysql/bin/mysqladmin -u root -p shutdown


14、安装PHP

# cd /usr/local/src/php-5.2.6
# ./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/jpeg6/ \
--with-freetype-dir=/usr/local/freetype/ \
--with-gd=/usr/local/gd2/ \
--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


出现错误

n file included from/usr/local/src/php-5.4.6/ext/gd/gd.c:103:

/usr/local/src/php-5.4.6/ext/gd/gd_ctx.c:在函数‘_php_image_stream_putc’中:
/usr/local/src/php-5.4.6/ext/gd/gd_ctx.c:51:错误:‘struct gdIOCtx’没有名为‘data’的成员
。。。

修改gd安装目录下的include/gd_io.h文件。
修改为文件中的结构体为

 typedef structgdIOCtx

{

  int (*getC)(struct gdIOCtx *);

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

 

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

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

 

 

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

 

  long (*tell)(struct gdIOCtx *);

 

  void (*gd_free)(struct gdIOCtx *);

  void (*data);

}

gdIOCtx;

其中红色的部分为添加的修改,其他部分无修改。

15、配置PHP

创建配置文件
# cp php.ini-development /usr/local/php/etc/php.ini

使用vi编辑apache配置文件
# vi /etc/httpd/httpd.conf

添加这一条代码
Addtype application/x-httpd-php .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.phtml

重启Apache
# /usr/local/apache2/bin/apachectl restart

写一段测试代码:
在/usr/local/apache2/htdocs目录下建立文件test.php
<?php
phpinfo();
?>
当出现一个php的版本信息页面时证明LAMP环境配置成功!


PHP5.3以上的版本不再支持Zend Optimizer,已经被全新的 Zend Guard Loader 取代,下面是安装Zend Guard具体步骤,以下操作均在终端命令行执行

 

1、下载Zend Guardcd /home

  
  
  1. wget http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz    #32位 
  2. wget http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz  #64位  

  
2、安装Zend Guard

  
  
  1. mkdir /usr/local/zend       #建立Zend Guard安装目录 
  2. tar xvfz ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz    #解压安装文件 
  3. cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so     /usr/local/zend/   #拷贝文件到安装目录 
  4. rm -rf /home/ZendGuardLoader-php-5.3-linux-glibc23-i386*   #删除安装包  

3、配置Zend Guard
       编辑php配置文件,可以用find命令查找
       vi /etc/php.ini    #编辑文件
       在最后位置添加以下内容

  
  
  1. [Zend Guard] 
  2. zend_extension=/usr/zend/ZendGuardLoader.so 
  3. zend_loader.enable=1 
  4. zend_loader.disable_licensing=0 
  5. zend_loader.obfuscation_level_support=3 
  6. zend_loader.license_path=  
4、重启web服务器

用测试网页测试,输出php信息时在最下面会有Zend加速器信息。


17、安装phpMyAdmin

拷贝目录到指定位置并改名为phpmyadmin
# cp -a  phpMyAdmin-3.0.0-rc1-all-languages /usr/local/apache2/htdocs/phpmyadmin
# cd /usr/local/apache2/htdocs/phpmyadmin/
# cp config.sample.inc.php config.inc.php

18、配置phpMyAdmin

# vi /usr/local/apache2/htdocs/phpmyadmin/config.inc.php
将auth_type 改为http
$cfg['Servers'][$i]['auth_type'] = 'http';
也可以默认为cookie方式登录。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值