Linux+Apache+MySQL+php (LAMP)安装配置

来源:互联网 发布:软件测试兼职平台 编辑:程序博客网 时间:2024/05/18 02:55

LAMP安装(系统:redhat6)

首先检查下面的元是否已安装:(用rpm -qa ***检查)

zlib-devel
libjpeg-devel
libpng-devel
libtiff-devel
freetype-devel
openssl-devel
libxml2-devel
gettext-devel


1.安装GD2

#tar xzvf gd-2.0.35.tar.gz  //解压软件包
#cd gd-2.0.35
./configure --prefix=/web/gd   //配置


#make //是用来编译的,它从Makefile中读取指令,然后编译
#make install   //是用来安装的


2.安装apache

#tar zxvf httpd-2.2.6.tar.gz
#cd httpd-2.2.6
./configure --prefix=/web/apache

#make
#make install


将apache设置成开机自启动的两种方法:
(1)在/etc/rc.d/rc.local 文件中加入一行
     /web/apache/bin/apachectl start

(2)将apache安装成为系统服务
     #cp /web/apache/bin/apachectl  /etc/rc.d/init.d/httpd
     然后vi /etc/rc.d/init.d/httpd 打开文件
     再按i或a 进入编辑
     在#!/bin/sh下面加入如下两行:
       #chkconfig: 2345 10 90
       #description: Activates/Deactivates Apache Web Server
     按Esc,再输入 :wq 退回终端

     #chkconfig --add httpd
     #chkconfig httpd on
                
 


3.安装MYSQL5


#tar zxvf mysql-5.0.46.tar.gz
#cd mysql-5.0.46

./configure --prefix=/web/mysql

#groupadd mysql
#useradd -g mysql mysql
#make
#make install
#cd /web/mysql
#chown -R mysql .  //--后面的点不能少
#chgrp -R mysql .  //--后面的点不能少
#bin/mysql_install_db --user=mysql    //--生成mysql用户数据库和表文件
#chown -R root .   //--后面的点不能少

#chown -R mysql  var
#cp share/mysql/my-medium.cnf /etc/my.cnf
#cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld
#chmod 755 /etc/rc.d/init.d/mysqld
#chkconfig --add mysqld
#chkconfig --level 3 mysqld on
#/etc/rc.d/init.d/mysqld start

#bin/mysqladmin -u root password 123456    //创建、修改密码

 

4.安装php5

#tar zxvf php-5.2.5.tar.gz
#cd php-5.2.5
./configure --prefix=/web/php

#make
#make install
#cp php.ini-recommended  /etc/php.ini

 

5.整合apache与php

#vi /web/apache/conf/httpd.conf
找到并改为(把它变成自己的服务目录):DocumentRoot "/web/www"  //www还需自己新建于web
            <Directory "/web/www">

找到AddType application/x-gzip  .gz.tgz在其下加上如下内容:
AddType application/x-httpd-php  .php

设置WEB默认文件:查找到DirectoryIndex index.html并改为:DirectoryIndex index.php index.html index.htm

找到这一段:
#AllowOverride controls what dirctives may be placed in .htaccess files.
#It can be "ALL","None",or any combination of the deywords:
#Options Filelnfo AuthConfig Limit
#
AllowOveride none
更改为:AllowOverride all

按Esc,再输入 :wq 退回终端


Httpd-增加访问路径和目录(服务器):

    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all
</Directory>


#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.php index.html index.htm
</IfModule>

之间加入
Alias /bbs "/web/bbs"  //前面的“bbs"为访问目录,后面的引号内的为中路径
<Directory "/web/fms/webroot">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow From all
</Directory>

 

如果上面过程有错误的地方,欢迎指正。

原创粉丝点击