Linux 搭建LAMP 源码编译详细文档

来源:互联网 发布:网络运营商有哪些 编辑:程序博客网 时间:2024/05/01 23:43

lamp安装顺序 mysql->apache->php   因为php编译时要指定mysql和apache的路径,apache和mysql的安装顺序可以互换

php在lamp中是作为apache的一个模块来调用的,并不会产生进程,要和lnmp里的php-fpm进程区分开来

再安装之前确保机器没装过mysql,httpd,php等,可以用rpm -qa | grep mysql 这样的形式去查找是否安装rpm包,还有netstat -lnp 和ps aux 等命令可以查看进程

安装流程:

1)mysql

下载mysql:

cd /usr/local/src ;

wget mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-x86_64-glibc23.tar.gz

tar -zxvf  mysql-5.1.73-linux-x86_64-glibc23.tar.gz    ##解压

cp -r  mysql-5.1.73-linux-x86_64-glibc23 /usr/local/mysql    ##移动到 /usr/local/mysql

useradd -s /sbin/nologin mysql     #创建用户

cp /usr/local/mysql/support-files/my-large.cnf     /etc/my.cnf  ##拷贝配置文件

mkdir -p /data/mysql      #作为datadir,存放数据库文件

chown -R mysql:mysql  /data/mysql

 /usr/local/mysql/scripts/mysql_install_db  --basedir=/usr/local/mysql  --datadir=/data/mysql         ##初始化mysql

vi /etc/init.d/mysqld ; 并修改basedir和datadir

chkconfig --add mysqld ; chkconfig mysqld on ; service mysqld start   ##开机启动

2)apache

cd /usr/local/src ; wget http://mirrors.sohu.com/apache/httpd-2.2.31.tar.bz2

cd httpd-2.2.31

./configure --prefix=/usr/local/apache2--with-included-apr  --with-pcre --enable-mods-shared=most
make && make install

error: mod_deflate has been requested but can not be built due to prerequisite failures

解决办法是:

yum install -y zlib-devel

为了避免在make的时候出现错误,所以最好是提前先安装好一些库文件:

yum install -y pcre pcre-devel apr apr-devel

3) apache

cd /usr/local/src

wget http://cn2.php.net/distributions/php-5.3.28.tar.gz

tar zxf php-5.3.28.tar.gz

cd php-5.3.28

./configure \--prefix=/usr/local/php \--with-apxs2=/usr/local/apache2/bin/apxs \--with-config-file-path=/usr/local/php/etc  \--with-mysql=/usr/local/mysql \--with-libxml-dir \--with-gd \--with-jpeg-dir \--with-png-dir \--with-freetype-dir \--with-iconv-dir \--with-zlib-dir \--with-bz2 \--with-openssl \--with-mcrypt \--enable-soap \--enable-gd-native-ttf \--enable-mbstring \--enable-sockets \--enable-exif \--disable-ipv6
这一步可能会遇到各种各样报错
建议先安装一些依赖包:
configure: error: xml2-config not found. Please check your libxml2 installation.

解决办法是:

yum install -y libxml2-devel

还有错误:

configure: error: Cannot find OpenSSL's <evp.h>

解决办法是:

yum install -y openssl openssl-devel

错误:

checking for BZip2 in default path... not foundconfigure: error: Please reinstall the BZip2 distribution

解决办法:

yum install -y bzip2 bzip2-devel

错误:

configure: error: png.h not found.

解决办法:

yum install -y libpng libpng-devel

错误:

configure: error: freetype.h not found.

解决办法:

yum install -y freetype freetype-devel

错误:

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解决办法:

rpm -ivh "http://www.aminglinux.com/bbs/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm"yum install -y  libmcrypt-devel

make && make install

到这一步为止,lamp就算安装完成了

4)apache+php
安装完之后还不行,apache不会自动识别php,接下来要修改一些配置,使apache和php合体

vi /usr/local/apache2/conf/httpd.conf  ; 修改以下2个地方
1.找到
 AddType application/x-compress .Z
 AddType application/x-gzip .gz .tgz
添加一行:
AddType application/x-httpd-php .php

2.找到
<IfModule dir_module>    DirectoryIndex index.html</IfModule>
改为
<IfModule dir_module>    DirectoryIndex index.html index.php index.htm</IfModule>

3.找到:

#ServerName www.example.com:80

修改为:

ServerName localhost:80
这一步如果不修改的话,启动apache的时候会报如下错误
httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
httpd not running, trying to start

还有几个地方需要说明lamp中php不用启动进程
apache的启动方法是:/usr/local/apache2/bin/apachectl start
apache配置语法检测:/usr/local/apache2/bin/apachectl -t
apache模块查看:/usr/localapache2/bin/apchectl -M










                                             
1 0
原创粉丝点击