首页 > 其他 > 详细

LAMP配置

时间:2014-04-17 14:26:14      阅读:613      评论:0      收藏:0      [点我收藏+]

1、什么是LAMP

LAMP=linux+apache+mysql+php

Apache是一种web服务器。mysql是一种小型数据库。php是一种语言,可以写网站程序。

静态网页和动态网页的区别是否涉及数据库。

rpm包类似于windows的.exe程序,依赖平台redhat、centos。源码包大多是C语言写的,是看得见的、可以更改,且不依赖于平台。

2、安装mysql(按顺序安装)

(1)下载mysql-5.1.40-linux-i686-icc-glibc23.tar.gz 二进制免编译包

[root@localhost ~]# cd /usr/local/src/     //默认将安装包放在此目录
[root@localhost src]# wget http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz     //下载32位mysql免编译包
--2014-04-16 09:13:27--  http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
Resolving syslab.comsenz.com... 180.153.5.50
Connecting to syslab.comsenz.com|180.153.5.50|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 123633020 (118M) [application/octet-stream]
Saving to: “mysql-5.1.40-linux-i686-icc-glibc23.tar.gz”
100%[======================================>] 123,633,020  190K/s   in 12m 44s
2014-04-16 09:26:21 (158 KB/s) - “mysql-5.1.40-linux-i686-icc-glibc23.tar.gz” saved [123633020/123633020]

(2)解压mysql免编译包

[root@localhost src]# tar zxvf mysql-5.1.40-linux-i686-icc-glibc23.tar.gz

(3)将解压目录移到并改名为/usr/local/mysql

[root@localhost src]# mv mysql-5.1.40-linux-i686-icc-glibc23 /usr/local/mysql

(4)创建mysql用户,不能登录

[root@localhost src]# useradd -s /sbin/nologin mysql

(5)创建存放数据的目录/data/mysql

[root@localhost src]# cd /usr/local/mysql/
[root@localhost mysql]# mkdir -p /data/mysql

(6)更改/data/mysql属性

[root@localhost mysql]# chown -R mysql:mysql /data/mysql

(7)初始化数据库

[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
Installing MySQL system tables...
ERROR: 1004  Can‘t create file ‘/tmp/#sql52f_1_0.frm‘ (errno: 13)
#出现这种问题,解决方法如下:
[root@localhost mysql]# chmod -R 777 /tmp
再重新初始化
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
Installing MySQL system tables...
OK
Filling help tables...
OK      //出现两个ok就是初始化成功

(8)定义配置文件

[root@localhost support-files]# ls     //配置文件模板
binary-configure   my-huge.cnf             mysqld_multi.server
config.huge.ini    my-innodb-heavy-4G.cnf  mysql-log-rotate
config.medium.ini  my-large.cnf            mysql.server
config.small.ini   my-medium.cnf           ndb-config-2-node.ini
magic              my-small.cnf
[root@localhost support-files]# cp my-huge.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf‘? y 
//mysql配置文件默认放在/etc/my.cnf

(9)修改配置文件

[root@localhost support-files]# vim /etc/my.cnf
key_buffer_size = 128M  //128M实验环境足够用了
#log-bin=mysql-bin  //主生成二进制文件,从读取二进制文件

(10)定义启动脚本并添加到服务

[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
//拷贝文件到/etc/init.d目录下
[root@localhost support-files]# chmod 755 /etc/init.d/mysqld  //修改权限
[root@localhost support-files]# chkconfig --add mysqld   //添加服务
[root@localhost support-files]# chkconfig --list |grep mysqld
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
//查看服务,0-6表示运行级别,off和on表示所在的运行级别此服务的开启还是关闭。

(11)指定datadir

[root@localhost support-files]# vim /etc/init.d/mysqld
datadir=/data/mysql

(12)启动mysql

[root@localhost mysql]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!   //启动成功

(13)mysql日志

[root@localhost mysql]# cd /data/mysql/
[root@localhost mysql]# ls
ibdata1      ib_logfile1                localhost.localdomain.pid  test
ib_logfile0  localhost.localdomain.err  mysql

3、安装Apache

(1)下载httpd-2.2.16.tar.gz源码包

[root@localhost src]# wget http://syslab.comsenz.com/downloads/linux/httpd-2.2.16.tar.gz

(2)校验源码包

[root@localhost src]# md5sum httpd-2.2.16.tar.gz
7f33f2c8b213ad758c009ae46d2795ed  httpd-2.2.16.tar.gz

(3)解压源码包

[root@localhost src]# tar zxvf httpd-2.2.16.tar.gz

(4)编译安装

[root@localhost httpd-2.2.16]# ./configure --prefix=/usr/local/apache2 --with-included-apr --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre
#报错1;checking for zlib location... not found
checking whether to enable mod_deflate... configure: error: mod_deflate has been            requested but can not be built due to prerequisite failures
#解决方法:
[root@localhost httpd-2.2.16]# yum list |grep zlib
zlib.i686                                  1.2.3-29.el6                  @anaconda-CentOS-201303020136.i386/6.4
jzlib.i686                                 1.0.7-7.5.el6                 base
jzlib-demo.i686                            1.0.7-7.5.el6                 base
jzlib-javadoc.i686                         1.0.7-7.5.el6                 base
zlib-devel.i686                            1.2.3-29.el6                  base
zlib-static.i686                           1.2.3-29.el6                  base
[root@localhost httpd-2.2.16]# yum -y install zlib-devel
[root@localhost httpd-2.2.16]# ./configure --prefix=/usr/local/apache2 --with-included-apr --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre  
//再配置
[root@localhost httpd-2.2.16]# make && make install    //编译安装

最好去官网下载指定的包

(5)启动apache

[root@localhost ~]# /usr/local/apache2/bin/apachectl start
httpd: Could not reliably determine the server‘s fully qualified domain name, using localhost.localdomain for ServerName
解决方法:
[root@localhost ~]# vim /usr/local/apache2/conf/httpd.conf
ServerName localhost
[root@localhost ~]# netstat -anpt |grep httpd
tcp        0      0 :::80                       :::*                        LISTEN      7521/httpd

4、安装php

(1)下源码包php-5.3.27.tar.gz

[root@client src]# wget http://am1.php.net/distributions/php-5.3.27.tar.gz

(2)解压php

[root@localhost src]# tar zxvf php-5.3.27.tar.gz

(3)配置php

[root@localhost src]# cd php-5.3.27
[root@localhost php-5.3.27]# ./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

报错1:

configure: error: xml2-config not found. Please check your libxml2 installation.

解决1:

[root@localhost php-5.3.27]# yum list |grep libxml2
libxml2.i686                               2.7.6-8.el6_3.4               @anaconda-CentOS-201303020136.i386/6.4
libxml2.i686                               2.7.6-14.el6                  base
libxml2-devel.i686                         2.7.6-14.el6                  base
libxml2-python.i686                        2.7.6-14.el6                  base
libxml2-static.i686                        2.7.6-14.el6                  base
[root@localhost php-5.3.27]# yum install -y libxml2-devel

报错2:

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

解决2:

[root@localhost php-5.3.27]# yum list |grep openssl
openssl.i686                               1.0.1e-16.el6_5.7             @updates
krb5-pkinit-openssl.i686                   1.10.3-15.el6_5.1             updates
openssl-devel.i686                         1.0.1e-16.el6_5.7             updates
openssl-perl.i686                          1.0.1e-16.el6_5.7             updates
openssl-static.i686                        1.0.1e-16.el6_5.7             updates
openssl098e.i686                           0.9.8e-17.el6.centos.2        base
[root@localhost php-5.3.27]# yum install -y openssl-devel

报错3:

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

解决3:

[root@localhost php-5.3.27]# yum list |grep bzip2
bzip2.i686                                 1.0.5-7.el6_0                 @anaconda-CentOS-201303020136.i386/6.4
bzip2-libs.i686                            1.0.5-7.el6_0                 @anaconda-CentOS-201303020136.i386/6.4
bzip2-devel.i686                           1.0.5-7.el6_0                 base
[root@localhost php-5.3.27]# yum install -y bzip2-devel

报错4:

configure: error: jpeglib.h not found.

解决4:

[root@localhost php-5.3.27]# yum list |grep jpeg
libjpeg-turbo.i686                         1.2.1-3.el6_5                 updates
libjpeg-turbo-devel.i686                   1.2.1-3.el6_5                 updates
libjpeg-turbo-static.i686                  1.2.1-3.el6_5                 updates
openjpeg.i686                              1.3-10.el6_5                  updates
openjpeg-devel.i686                        1.3-10.el6_5                  updates
openjpeg-libs.i686                         1.3-10.el6_5                  updates
[root@localhost php-5.3.27]# yum install -y libjpeg-turbo-devel

报错5:

configure: error: png.h not found.

解决5:

[root@localhost php-5.3.27]# yum list |grep png
dvipng.i686                               1.11-3.2.el6                  base
libpng.i686                               2:1.2.49-1.el6_2              base
libpng-devel.i686                         2:1.2.49-1.el6_2              base
libpng-static.i686                        2:1.2.49-1.el6_2              base
[root@localhost php-5.3.27]# yum install -y libpng-devel

报错6:

configure: error: freetype.h not found.

解决6:

[root@localhost php-5.3.27]# yum list |grep freetype
freetype.i686                             2.3.11-14.el6_3.1             base
freetype-demos.i686                       2.3.11-14.el6_3.1             base
freetype-devel.i686                       2.3.11-14.el6_3.1             base
[root@localhost php-5.3.27]# yum install -y freetype-devel

报错7:

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

解决7:

[root@localhost php-5.3.27]# rpm -ivh "http://www.lishiming.net/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm"
Retrieving http://www.lishiming.net/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm
warning: /var/tmp/rpm-tmp.CBYMdI: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
[root@localhost php-5.3.27]# yum install -y  libmcrypt-devel

(4)编译安装

[root@localhost php-5.3.27]# make && make install

5、apache支持php配置

(1)添加配置

[root@localhost ~]# vim /usr/local/apache2/conf/httpd.conf
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
    AddType application/x-httpd-php .php

(2)检测配置文件是否有错

[root@localhost ~]# /usr/local/apache2/bin/apachectl -t
Syntax OK

(3)编辑测试页

[root@localhost ~]# vim /usr/local/apache2/htdocs/1.php
<?php
 Echo "wellcome to php !";
?>

(4)测试

[root@localhost php-5.3.27]# curl localhost/1.php
wellcome to php ![root@localhost php-5.3.27]#

扩展学习

1、什么是扩展模块

2、添加扩展模块

3、常用技巧

本文出自 “linux成长之路” 博客,请务必保留此出处http://linuxlovers.blog.51cto.com/6787002/1396242

LAMP配置,布布扣,bubuko.com

LAMP配置

原文:http://linuxlovers.blog.51cto.com/6787002/1396242

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!