linux LAMP和LNMP

    源码包安装LAMP

      配置环境:

        操作系统Red hat Linux 2.6.25.19  

                            apache:httpd-2.2.19.tar.bz2

                Php: php-5.3.7.tar.bz2  

           mysql: mysql-5.5.15-linux2.6-i686.tar.gz

    1.安装mysql mysql为绿色版 不需编码配置完即可直接使用

      (1) 解压缩:tar -zxvf  mysql-5.5.15-linux2.6-i686.tar.gz  -C  /usr/local

        cd  /usr/local/mysql-5.5.15-linux2.6-i686 

        ln -s mysql-5.5.15-linux2.6-i686 mysql  做一个链接

   可以看到一个叫INSTALL-BINARY的文件 打开 less INSTALL-BINARY文件可以   看到具体的安装步骤:

 内容如下:

  To install and use a MySQL binary distribution, the basic command

      sequence looks like this:

shell> groupadd mysql

shell> useradd -r -g mysql mysql

shell> cd /usr/local

shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz

shell> ln -s full-path-to-mysql-VERSION-OS mysql

shell> cd mysql

shell> chown -R mysql .

shell> chgrp  -R mysql .

shell> scripts/mysql_install_db --user=mysql

shell> chown -R root .

shell> chown -R mysql data

# Next command is optional

shell> cp support-files/my-medium.cnf /etc/my.cnf

shell> bin/mysqld_safe --user=mysql &

# Next command is optional

shell> cp support-files/mysql.server /etc/init.d/mysql.server

   具体操作步骤:

   cd mysql

     groupadd mysql

       useradd -r -g mysql 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

      cp support-files/mysql.server /etc/init.d/mysqld

   (2)修改环境变量:vim / etc/profile

         

1

   修改完之后重新读取:. /etc/profile

显示:echo $PATH  

    (3)将mysqld服务加入chkconfig中

    Chkconfig --add mysqld

   检查是否加入:

  Chkconfig --list | grep mysql

   可以使用service指令来管理mysql服务

    如:service mysqld  start

    (4)对/usr/local/mysql/include做链接

    ln -s  /usr/local/mysql /include   /usr/include/mysql

    (5)mysql库文件:

  cd  /etc/ld.so.conf.d

  创建一个mysqld.conf 的文件

   Vim mysqld.conf

  把mysql下的lib路径写入文件中

  /usr/local/mysql/ lib即可

 

 

这样就完成了绿色软件mysql 的安装配置

 

 

 

 2.安装apache源码包

  (1) 解压缩:

       Tar  -jxvf  httpd-2.2.19.tar.bz2 -C  /usr/local/src

       cd 到 /usr/local.src 可以看到有一个httpd-2.2.19的文件夹

       cd到httpd-2.2.19 然后ls 显示所有文件 可以看到一个configure 的文件 

   (2)对apache经行配置:

     ./configure  --prefix=/usr/local/apache --sysconfdir=/etc/httpd  --enable-so --enable-ssl --with-z

   Enter开始执行,如果没有错误,开始编译make 编译无误,开始安装 make install

需要一点时间 请耐心等待

全部安装完成后 可以在/etc/httpd 文件夹中看到一个httpd.conf 的文件

 (3)开启achape   cd到 /usr/local/apache

   bin/apachectl  start  即可

    查看80端口是否打开:

    netstat -tupln | grep http

    增加apache环境变量:

    Vim /etc/profile

    在上次的PATH的后面再增加一条apache的路径

   

11

    重新读取一下文件:. /etc/profile

 

    显示: echo $PATH

  (4)配置头文件和库文件:类似与mysql的方法

     Vim /httpd.conf

    添加这样一条: /usr/local/apache/lib

    重新加载:

    ldconfig   -v 

ln -s /usr/local/apache/include /usr/include/httpd

 

完成以上步骤即完成了apache的安装和配置

 

 3.php源码包安装

   (1)解压缩:tar -jxvf  php-5.3.7.tar.bz2 -C /usr/local/src

  配置:

 ./configure  --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs  --with-mysql=/usr/local/mysql  --with-mysqli=/usr/local/mysql/bin/mysql_config  --enable-mbstring=all

 Enter开始执行,如果没有出现错误 开始编译make ,然后安装make install 

 此过程需要点时间 ,请耐心等待

    (2)整合apache和php

         vim /etc/httpd/httpd.conf

            

11

    重启服务:

   apachectl stop

   apachectl start

   (3)编辑/etc/httpd/httpd.conf

    添加一条指令:

    AddType application/x-httpd-php .php

    重启服务 

  (4)编辑index.html

       cd /usr/local/apache/htdocs

       mv index.html index.php

      vim index.php

          <?php

          info()

           ?>

     在浏览器中输入192.168.101.112/index.php

  (5)与mysql的连接

        编辑index.php

  

11

 在浏览器中输入192.168.101.112/index.php 如果显示ok 即为成功

 

本文出自 “猫窝” 博客,转载请与作者联系!

你可能感兴趣的:(linux,职场,lamp,LNMP,休闲)