• lamp 环境搭建


    1.安装libxml2库文件

    step1:进入下载的软件源码包所在目录/usr/local/src/下,解压软件包libxml2-2.9.0.tar.gz到当前目录libxml2-2.9.0下,并进入libxml2-2.9.0目录。命令如下行所示:
    [root@localhost   ~]# cd /usr/local/src  //进入软件源码包所在目录

    [root@localhost   src]# tar zxvf libxml2-2.9.0.tar.gz //解包解压

    [root@localhost   src]# cd libxml2-2.9.0  //进入解包解压后的目录

    step2:使用configure命令检查并配置安装需要的系统环境,并生成安装配置文件,命令行如下。

    [root@localhost   libxml2-2.9.0]# ./configure --prefix=/usr/local/libxml2
        //选项--prefix=/usr/local/libxml2作用,是在安装时将软件安装到/usr/local/libxml2 目录下。

    step3:使用make命令编译源代码文件并生成安装文件。命令行如下示。

    [root@localhost   libxml2-2.9.0]# make  //对软件源代码文件进行编译

    step4:使用make install命令安装编译过的文件。命令行如下。

    [root@localhost   libxml2-2.9.0]# make install  //开始安装libxml2库文件

    如果安装成功以后,在/usr/local/libxml2/目录下将生成bin,include,lib,share四个目录。在后面安装 PHP5源代码的配置时,会通过在configure命令的选项中加上"--with-libxml-dir=/usr/local/libxml2"选 项,用于指定安装libxml2库文件的位置。


    2.安装libmcrypt最新库文件
    安装方法与上面安装libxml2方法相同,./configure --prefix=/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,进入这个目录按照下面几个 命令配置、编译、安

    装就可以了。


    3.安装zlib最新库文件
        注意:不要指定安装路径
        ./configure
        make
        make install


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


    5.安装jpeg8库文件
         step1:安装GD2库前所需的jpeg8库文件,需要自己手动创建安装需要的目录,它们在安装时不能自动创建。命令行如下。

         mkdir /usr/local/jpeg8  //建立jpeg8软件安装目录
         mkdir /usr/local/jpeg8/bin //建立存放命令的目录
         mkdir /usr/local/jpeg8/lib  //创建jpeg8库文件所在目录
         mkdir /usr/local/jpeg8/include //建立存放头文件目录
         mkdir -p /usr/local/jpeg8/man/man1 //建立存放手册的目录
         ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
         make
         make install

    6.安装freetype最新库文件
        ./configure --prefix=/usr/local/freetype
        make
        make install

    7.安装atuoconf最新的库文件
        唯一注意的地方是configure时,不用指定路径。


    8.安装最新的GD库文件
         ./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg8/ --with-png=/usr/local/libpng/ --with-freetype=/usr/local/freetype/
        make
        make install

    注意:make的时候 有可能发生的错误

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



    9.安装httpd前需要安装的
        卸载apr、apr-util   yum remove 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
        
        unzip -o pcre-8.32.zip
         ./configure --prefix=/usr/local/pcre
        make
        make install

    10.安装httpd
        ./configure --prefix=/usr/local/apache --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-apr=/usr/local/apr-httpd/ --with-apr-util=/usr/local/apr-util-httpd/ --with-pcre=/usr/local/pcre/ --disable-userdir
        
        make
        make install
        安装完成后,进入/usr/local/apache243/目录下,检查是否有以下文件:
        bin  build  cgi-bin  error  htdocs  icons  include  logs  man  manual  modules

         启动Apache服务器,并查端口是否开启,启动Apache服务器的命令行如下:
        /usr/local/apache/bin/apachectl start

          提示信息:
        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
        把 ServerName localhost:80 前面的#号去掉 并修改成这样
        

        查看端口命令行如下: netstat -tnl|grep 80

        设置开机自动启动
        echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.d/rc.local

        查看浏览器 输入IP地址 显示 It works! 则表明Apache服务器可以使用。

    11.安装mysql前先安装 ncurses
        ./configure --with-shared --with-debug --without-ada --enable-overwrite
        make
        make install

    12.安装mysql5.5 以后的版本需要 cmake 编译器
        yum install cmake

    13.安装mysql5.5
        创建mysql安装目录及数据库存放文件
        命令如下:
        mkdir -p /usr/local/mysql
        mkdir -p /usr/local/mysql/data

        创建Mysql用户组 groupadd mysql
        添加用户到组 useradd -r -g mysql mysql

        tar -zxvf mysql-5.5.*.tar.gz
        cd mysql-5.5.x
        cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1
        make
        make install

    注意:重新编译时,需要清除旧的对象文件及缓存信息:

     make clean
    rm -f CMakeCache.txt
    rm -rf /etc/my.cnf

        设置目录权限
        进入安装文件夹:
        cd /usr/local/mysql
        chown -R root:mysql .
        chown -R mysql:mysql data

        复制配置文件:cp support-files/my-medium.cnf /etc/my.cnf
        创建MYSQL系统数据库的表
        cd /usr/local/mysql
        scripts/mysql_install_db --user=mysql

        设置环境变量
        cd ~  
        vi .bash_profile
        把PATH=$PATH:$HOME/bin替换为如下:

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

        然后保存退出 :wq
        退出后输入如下命令:
        source /root/.bash_profile

        添加mysql到系统服务中
        cd /usr/local/mysql
        cp support-files/mysql.server /etc/init.d/mysql

        服务启动与停止
        启动:service mysql start
        停止:service mysql stop  

        设置MySql自启动
        chkconfig --add mysql

        设置mysql root 密码
        mysql -u root -p
        默认为空密码,直接回车就可以了
        SET PASSWORD FOR 'root'@'localhost'=PASSWORD('123456');

    14.安装 php  (安装的是5.4.11)
        ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache/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-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets

    --disable-fileinfo
        make
        make install

         AddType application/x-compress .Z
        AddType application/x-gzip .gz .tgz
        AddType application/x-httpd-php .php .phtml

    编译php时候的问题

    configure能正常通过,make配置到最后报错:make: *** [ext/gd/gd.lo] Error 1
     据说这个错误是php5.4的bug:
    解决方法
    vim /usr/local/gd2/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);
     
      int (*seek) (struct gdIOCtx *, const int);
     
      long (*tell) (struct gdIOCtx *);
     
      void (*gd_free) (struct gdIOCtx *);
      void (*data);         //新增的内容
    }
    gdIOCtx;
    ==========================================================
    重新编译前最好执行如下:
     [root@localhost php-5.4.5]# make clean
    
    重新configure  、make 、make install 就可以了。 
    

      

  • 相关阅读:
    AT89C51单片机的主要组成结构
    Keil C51的库函数
    Keil C51程序设计
    bootchart 使用说明及代码分析
    [转]android下编译libusb和libhackrf
    [转]Android系统编译过程分析
    [转]Android U 盘功能实现和分析
    [转]深入理解Android之设备加密Device Encryption
    [转]Makefile 中:= ?= += =的区别
    [转]Makefile中常用的函数
  • 原文地址:https://www.cnblogs.com/mr-amazing/p/4092995.html
Copyright © 2020-2023  润新知