设为首页 收藏本站
查看: 1291|回复: 0

centos6系统下LAMP环境搭建

[复制链接]

尚未签到

发表于 2015-11-15 15:28:40 | 显示全部楼层 |阅读模式
  以下安装包的原文件都放在/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

   DSC0000.jpg
  分析:这个问题是因为gd库中的gd_png.c这个源文件中包含png.h时,png.h没有找到导致的。
  解决:
  在编译文件里
  # vi gd_png.c
  将include “png.h” 改成 include “/usr/local/libpng/include/png.h”
   DSC0001.jpg
  其中/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: BundledAPR
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
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz  
  [iyunv@localhost src]# tar -zxvf cmake-2.8.4.tar.gz

[iyunv@localhost src]# cd cmake-2.8.4

[iyunv@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

[iyunv@lizhendong mysql-5.6.4-m7]# chmod +x /etc/init.d/mysqld

[iyunv@lizhendong mysql-5.6.4-m7]# chkconfig --add mysqld

[iyunv@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


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

    

2、安装Zend Guard



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

  3、配置Zend Guard

       编辑php配置文件,可以用find命令查找

       vi /etc/php.ini    #编辑文件

       在最后位置添加以下内容



  • [Zend Guard]
  • zend_extension=/usr/zend/ZendGuardLoader.so
  • zend_loader.enable=1
  • zend_loader.disable_licensing=0
  • zend_loader.obfuscation_level_support=3
  • 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方式登录。


版权声明:本文为博主原创文章,未经博主允许不得转载。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-139586-1-1.html 上篇帖子: 搭建LAMP 环境 细节:--- 安装apache 下篇帖子: 10亿量级LAMP架构分享
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表