loip 发表于 2015-8-19 10:11:57

编译安装LAMP小结

  选取Debian为环境。
  1. apache2
  如果要让apache完全在root用户下运行
  #vi ~/.bashrc
  export CFLAGS='-Wall -DBIG_SECURITY_HOLE'。
  并且安装完后要修改apache配置文件
  #vi /usr/local/apache2/conf/httpd.conf
  修改User和Group为root。
  
  安装apr:
  #tar xvf httpd-2.2.15.tar.gz
  #cd httpd-2.2.15
  #cd srclib/apr
  #./configure --prefix=/usr/local/apr
  #make
  #make install
  #make clean
  #make distclean
  
  安装apr-util:
  #cd ../apr-util
  #./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
  #make
  #make install
  #make clean
  #make distclean
  
  安装apache:
  最后安装apache
  #./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-static-support --enable-static-htpasswd --enable-static-htdigest --enable-static-rotatelogs --enable-static-logresolve --enable-static-htdbm --enable-static-ab --enable-static-checkgid --disable-cgi --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-dav --enable-so
  如果提示apr-util版本过低,那么可能是你的Linux发行版内置了apr库,所以将自己安装的apr和apr-util库卸载,并且将apache的配置参数中的--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util,修改为--with-included-apr和--with-included-apr-util。
  如果编译的时候zlib有问题,安装zlib,而且要按照默认路径/usr/local安装。
  Ubuntu用sudo apt-get install zlib1g-dev
  #make
  #make install
  #make clean
  #make distclean
  #vi /etc/rc.local
  在exit 0之前添加:/usr/local/apache2/bin/apachectl start
  
  如出现错误:
  /usr/lib/libexpat.so: could not read symbols: File in wrong format
  解决方法:
  编译时增加编译参数 --with-expat=builtin 好像在64位服务器下编译脚本在定位系统expat支持时有些问题。通过指定expat,用系统自带的expat来编译就不存在这个问题了。
  测试
  
  /usr/local/apache2/bin/apachectl start如果出现错误。
  httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.1.201 for ServerName
  修改apache配置文件
  # vi /usr/local/apache2/conf/httpd.conf
  找到ServerName localhost:80,将注释取消掉。
  -------------------------------------------------------------------------------apache安装完毕------------------------------------------------------------------------------
  2.安装MySQL
  #tar -zxvf mysql-5.1.30.tar.gz
  #cd mysql-5.1.30
  #groupadd -r mysql //添加mysql用户组
  #useradd -m -r -g mysql -d /var/lib/mysql -s /bin/bash -c "MySQL Server" mysql//添加mysql用户
  #./configure --prefix=/usr/local/mysql --sysconfdir=/etc --localstatedir=/var/lib/mysql --enable-local-infile
  debian如果出现checking for termcap functions library... configure: error: No curses/termcap library found
  #apt-get install libncurses5-dev安装之。
  #make
  如果出现do_abi_check error,
  #vi Makefile 将do_abi_check以后的语句都注释掉即可,再次make
  #make
  #make install
  #make clean
  #make distclean
  #cd /usr/local/mysql
  #/bin/mysql_install_db //初始化系统数据库
  #ls /var/lib/mysql //查看存放数据库中的目录内容
  #chown -R mysql:mysql /var/lib/mysql//修改数据库目录所有者
  #cp /usr/local/mysql/share/mysql/my-large.cnf /etc/my.cnf //一般正常安装之后已经有该文件,可以不用拷贝
  #cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql复制生成Linux Mysql服务器的自动与停止脚本
  #chkconfig --list | grep mysql //查询当前是否有mysql服务
  #chkconfig --add mysql //添加mysql服务到服务器管理中
  如果出现insserv: FATAL: service network is missed in the runlevels XXX to use service
  根据Google的结果是:
  Actual Results:
  In default configuration, mysql cannot be enabled as a service to start at boot
  Expected Results:
  Should be able to enable mysql service
  所以采用以下办法:
  # vi /etc/init.d/mysql
  将Default-Start反注释掉。
  然后再
  #chkconfig --add mysql
  #chkconfig --list | grep mysql //查询此时mysql服务器的启动状态
  #chkconfig --level 35 mysql on //设置在3、5运行级别也自启动
  #service mysql start 或 /etc/init.d/mysql start
  如果mysql命令不能正常使用的话
  #vi ~/.bashrc
  添加一句alias mysql='/usr/local/mysql/bin/mysql'
  
  在编译PHP源码时,会使用到部分MySQL的库文件和头文件,若服务器还需提供PHP动态网页服务,会导致找不到相应的文件,解决办法是为目录创建一个符号连接,其实现的操作命令如下:
  
  #ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
  
  #ln -s /usr/local/mysql/include/mysql /usr/include/mysql
  

  Starting MySQL.Manager of pid-file quit without updating fi解决办法只要将/etc/my.cnf里面的 skip federated注释掉即可。
  -------------------------------------------------------------------------------apache安装完毕------------------------------------------------------------------------------
  3.安装PHP
  安装jpeg8库
  #tar -xvf jpegsrc.v8b.tar.gz
  #cd jpeg-8b
  #./configure --prefix=/usr/local/jpeg8/ --enable-shared --enable-static
  #make
  #make install
  #make clean
  #make disclean
  

  安装libpng库
  #tar -xvf libpng-1.2.42.tar.gz
  #cd libpng-1.2.42
  #./configure
  #make
  #make install
  #make clean
  #make distclean
  

  安装freetype库
  #tar -xvf freetype-2.3.12.tar.gz
  #cd freetype-2.3.12
  #./configure --prefix=/usr/local/freetype
  #make
  #make install
  #make clean
  #make distclean
  

  安装gd库
  #tar -xvf gd-2.0.35.tar.gz
  #cd gd-2.0.35
  #./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg8/ --with-png --with-zlib --with-freetype=/usr/local/freetype/
  #make
  #make install
  #make clean
  #make distclean
  

  安装php
  #tar -xvf php-5.2.13.tar.gz
  #cd php-5.2.13
  安装unixODBC到/usr/local/unixODBC#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-pear=/usr/share/php --with-zlib-dir --with-bz2 --with-libxml-dir --with-gd=/usr/local/gd2 --enable-gd-native-ttf --enable-gd-jis-conv --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/jpeg8 --with-png-dir --enable-mbstring --with-unixODBC=/usr/local/unixODBC --with-config-file-path=/etc --with-iconv --disable-ipv6 --enable-static --enable-maintainer-zts --enable-zend-multibyte --enable-inline-optimization --enable-zend-multibyte --enable-sockets --enable-soap --mysql-with=/usr/local/mysql
  如果提示BZip2有问题,重新编译默认安装bzip2。
  # make
  # make install
  修改php配置
  # vim php.ini-recommended
  找到register_globals = Off,修改为:register_globals = On
  找到short_open_tag = Off,修改为:short_open_tag = On
  找到error_reporting = E_ALL,修改为:error_reporting = E_ALL & ~E_NOTICE
  找到date.timezone = ,加上 Asia/Chongqing
  最后把php.ini-recommanded拷贝到/etc/php.ini去
  如果安装的版本是5.3.X,除了上面的目录名变为php-5.3.X,php配置文件也变成php.ini-development
  

  如果php make时出现错误:libbz2.a需要重新加参数-fPIC来编译
  #tar -xvf bzip2-1.0.5.tar.gz
  #cd bzip2-1.0.5
  #make clean
  #vim Makefile
  找到CFLAGS 在最后加入 -fPIC
  #make
  #make install
  

  整合apache 与php
  #vi /usr/local/apache2/conf/httpd.conf
  在最后一行加上:
  AddType application/x-httpd-php .php
  查找:(设置 WEB 默认文件)
  DirectoryIndex index.html
  替换为:
  DirectoryIndex index.php index.html index.htm //在 WEB 目录不到默认文件,httpd 就会执行 /var/www/error/noindex.html
  找到这一段:
  #AllowOverride controls what directives may be placed in .htaccess files.
  #It can be "All", "None", or any combination of the keywords:
  #Options FileInfo AuthConfig Limit
  #
  AllowOverride none
  更改为AllowOverride all(允许apache rewrite)
  保存httpd.conf,退出。
  #/usr/local/apache2/bin/apachectl restart //重启 Apache
  

  

  
页: [1]
查看完整版本: 编译安装LAMP小结