源码搭建LAMP服务器

简介:这是源码搭建LAMP服务器的详细页面,介绍了和php,有关的知识、技巧、经验,和一些php源码等。

class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=346421' scrolling='no'>

1. 安装Apache服务器

  wget http://apache.etoak.com//httpd/httpd-2.2.19.tar.gz
  tar -zxvf httpd-2.2.19.tar.gz
  cd httpd-2.2.19
  ./configure --prefix=PREFIX
  make
  make install
  apachectl -k start

  其中,PREFIX为apache的安装目录。安装完成后,打开http://localhost/ , 显示It works 。安装成功。
  注:编译Apache要求 apr/apr-util >= 1.2。认没有安装apr如果你的系统中默和apr-util则你需要安装它们。
  如果你的系统中已经安装了apr或apr-util的1.0或1.1版本,则必须将你的apr/apr-util升级到1.2版本。
  apr和apr-util已经包含在Apache httpd的发行源代码中,你可以通过以下命令安装:

  # 编译和安装 apr 1.2   
  cd srclib/apr
  ./configure --prefix=/usr/local/apr-httpd/
  make
  make install

  # 编译和安装 apr-util 1.2
  cd ../apr-util
  ./configure --prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr-httpd/
  make
  make install 

  # 配置 httpd  
  cd ../..  
  #用以下的./configure命令替换上面的./configure命令来配置httpd的编译。  
  ./configure --prefix=PREFIX --with-apr=/usr/local/apr-httpd/ --with-apr-util=/usr/local/apr-util-httpd/

2. 安装MySQL数据库

  #编译MySQL5.5.15,需要安装cmake
  wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
  tar -zxvf cmake-2.8.5.tar.gz
  cd  cmake-2.8.5
  ./configure
  make
  make install

  #编译安装MySQL需要ncurses库,所以你要编译安装ncurses
  wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz
  tar -zxvf ncurses-5.9.tar.gz
  cd ncurses-5.9
  ./configure
  make
  http://www.cnblogs.com/xiaobaicai/admin/EditPosts.aspxmake install

  #编译安装MySQL
  groupadd mysql
  useradd -r -g mysql mysql

  wget http://download.softagency.net/mysql/Downloads/MySQL-5.5/mysql-5.5.15.tar.gz
  tar -zxvf mysql-5.5.15.tar.gz
  cd mysql-5.5.15
  cmake .
  make
  make install

  cd /usr/local/mysql
  chown -R mysql .
  chgrp -R mysql .
  scripts/mysql_install_db --user=mysql
  chown -R root .
  chown -R mysql data
  cp support-files/my-medium.cnf /etc/my.cnf
  bin/mysqld_safe --user=mysql &
  cp support-files/mysql.server /etc/init.d/mysql.server

  #设置开机启动mysql服务
  ln -s /etc/init.d/mysql.server /etc/rc3.d/S99mysql
  ln -s /etc/init.d/mysql.server /etc/rc5.d/S99mysql
  ln -s /etc/init.d/mysql.server /etc/rc0.d/K01mysql

  #将mysql安装目录加入环境变量,在/etc/profile文件末尾中加入以下命令
  PATH=/usr/local/mysql/bin:$PATH
  export PATH

3. 安装PHP

#安装PHP5.3.7需要libxml2库
wget ftp://xmlsoft.org/libxml2/libxml2-2.7.8.tar.gz
tar -zxvf libxml2-2.7.8.tar.gz
cd libxml2-2.7.8
./configure
make
make install

#安装PHP5.3.7
wget http://219.239.26.12/download/18995384/25492638/6/gz/249/252/1313725835513_508/php-5.3.7.tar.gz
tar -zxvf php-5.3.7.tar.gz
cd php-5.3.7
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql
make
make install

#设置php.ini
cp php.ini-development /usr/local/php5/lib/php.ini

#编辑Apache httpd.conf 文件以调用 PHP 模块。
LoadModule php5_module modules/libphp5.so
#告知 Apache 将特定的扩展名解析成 PHP,例如,让 Apache 将扩展名 .php 解析成 PHP。
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

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

  注:如果启动Apache的过程中遇到如下错误:

  httpd: Syntax error on line 53 of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

#原因是Linux有一个SELinux保护模式引起的。

#解决办法
# 1关闭SELINUX的方法:
vi /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disabled  需要重启

# 2不关闭SELINUX的方法:
setenforce 0
chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache2/modules/libphp5.so
/usr/local/apache2/bin/apachectl restart
setenforce 1

爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具

http://biancheng.dnbcw.info/php/346421.html pageNo:4
原文地址:https://www.cnblogs.com/ooooo/p/2240591.html