最近,部门有些系统需要迁移到新的机器上,因此需要在新的机器上安装lamp和lnmp的环境,因此在这里总结一下:

一. 安装lamp环境的步骤:

   (1).因为是新的机器,因此需要安装gcc的各种环境:

  1.  yum -y install gcc gcc-c++ libxml2 libxml2-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel glibc glibc-devel glib2 glib2-d evel

   (2).安装MySQL:

   1).编译安装MySQL: 

  1. +-------------------------------------------------------------------------------+
  2. | 操作 | 作用 |
  3. +-------------------------------------------------------------------------------+
  4. |shell> cd /usr/local/src | 进入软件包所在目录(不要照抄) |
  5. |-------------------------------------------------------------------------------|
  6. |shell> groupadd mysql | 增加mysql组(如果有就不用加了) |
  7. |-------------------------------------------------------------------------------|
  8. |shell> useradd mysql -g mysql | 增加mysql用户,并属于mysql |
  9. |-------------------------------------------------------------------------------|
  10. |shell> tar -xzvf mysql-5.1..tar.gz | 解压mysql源码包 |
  11. |-------------------------------------------------------------------------------|
  12. |shell> cd mysql-5.1. | 进入源码包 |
  13. |-------------------------------------------------------------------------------|
  14. |shell> ./configure --prefix=/usr/local/mysql \ | 配置mysql编译选项, |
  15. | --with-charset=utf8 \ | 指定安装路径及支持的字符集 |
  16. | --with-extra-charsets=gbk,gb2312,binary \
  17. | |
  18. |-------------------------------------------------------------------------------|
  19. |shell> make | 编译 |
  20. |-------------------------------------------------------------------------------|
  21. |shell> make install | 安装 |
  22. +-------------------------------------------------------------------------------+

  2).配置并初始化MySQL

  1. +---------------------------------------------------------------------------------------+
  2. | 操作 | 作用 |
  3. +---------------------------------------------------------------------------------------+
  4. |shell> cp support-files/my-medium.cnf /etc/my.cnf | MySQL配置文件复制到/etc |
  5. |---------------------------------------------------------------------------------------|
  6. |shell> vi /etc/my.cnf 'skip_federated'前加'#' | 注释掉这个错误的启动项,这是一个比较新式的存储引擎|
  7. |---------------------------------------------------------------------------------------|
  8. |shell> cd /usr/local/mysql | 进入mysql的安装目录 |
  9. |---------------------------------------------------------------------------------------|
  10. |shell> chown -R mysql.mysql . | 修改属主属组为mysql,才能完成 |
  11. | | 下一步的初始化数据库工作 |
  12. |---------------------------------------------------------------------------------------|
  13. |shell> bin/mysql_install_db --user=mysql \ | 初始化数据数据库 |
  14. | --datadir=/usr/local/mysql/var | |
  15. |---------------------------------------------------------------------------------------|
  16. |shell> chown -R root . | var目录修改为mysql用户所有 |
  17. |shell> chown -R mysql var | 其他文件修改为root所有,保证安全|
  18. |---------------------------------------------------------------------------------------|
  19. |shell> bin/mysqld_safe --user=mysql & | 启动mysql |
  20. +---------------------------------------------------------------------------------------+

  3).测试数据库

  1. +-------------------------------------------------+-------------------------------------+
  2. | 操作 | 作用 |
  3. +-------------------------------------------------+-------------------------------------+
  4. |shell> bin/mysql -uroot | root用户连mysql,无密码 |
  5. |---------------------------------------------------------------------------------------|
  6. |mysql> show databases; | 显示数据库 |
  7. |---------------------------------------------------------------------------------------|
  8. | +--------------------+ | |
  9. | | Database | | |
  10. | +--------------------+ | 看到左面的信息,数据库就安装 |
  11. | | information_schema | | 并启动成功了! |
  12. | | mysql | | |
  13. | | test | | |
  14. | +--------------------+ | |
  15. +---------------------------------------------------------------------------------------+

  4).接上步,修改mysql密码(可不做此步,默认无密码)

  1. +-------------------------------------------------------------------------------+
  2. | 操作 | 作用 |
  3. +-------------------------------------------------------------------------------+
  4. |mysql>UPDATE user SET | |
  5. | password=PASSWORD('new_password') | 修改root用户的密码 |
  6. | WHERE user='root'; | |
  7. |-------------------------------------------------------------------------------+
  8. |mysql>flush privileges; | 清空权限缓存 |
  9. +-------------------------------------------------------------------------------+

二.安装 apache2

  1) 安装zlib压缩库

  1. shell> cd /usr/local/src
  2. shell> tar -zxvf zlib-1.2..tar.gz
  3. shell> cd zlib-1.2.
  4. shell>./configure //这个配置编译命令不要加目录参数
  5. shell> make && make install

2)安装apache:

  1. shell> cd /usr/local/src
  2. shell> tar -zxvf httpd-2.2..tar.gz
  3. shell> cd httpd-2.2.
  4. shell>./configure --prefix=/usr/local/http2 \
  5. --enable-modules=most \
  6. --enable-rewrite \
  7. --enable-ssl \ #支持https的访问
  8. --enable-so
  9.  
  10. shell> make && make install
  11.  
  12. #启动Apache
  13. /usr/local/http2/bin/apachectl start
  14.  
  15. #测试apache
  16. 浏览器打开: http://虚拟机IP
  17. 如果没有成功的话,可能是防火墙的问题 这时需要我们去设置防火墙 打开80端口
  18.  
  19. 看到 "it works!",即为成功

三.安装图形库,为编译php做准备:

  

  1. libxml2
  2. shell> cd /usr/local/src
  3. shell> tar -zxvf libxml2-2.6..tar.gz
  4. shell> cd libxml2-2.6.
  5. shell>./configure --prefix=/usr/local/libxml2
  6. shell> make && make install
  7.  
  8. jpeg6
  9. #安装出现错误 提示无关键目录无法继续
  10. #手动建立如下目录 ,注意 man1是数字1,不是字母L
  11. shell> mkdir -p /usr/local/jpeg6
  12. shell> mkdir -p /usr/local/jpeg6/bin
  13. shell> mkdir -p /usr/local/jpeg6/lib
  14. shell> mkdir -p /usr/local/jpeg6/include
  15. shell> mkdir -p /usr/local/jpeg6/man
  16. shell> mkdir -p /usr/local/jpeg6/man1
  17. shell> mkdir -p /usr/local/jpeg6/man/man1
  18.  
  19. shell> cd /usr/local/src
  20. shell> tar -zxvf jpegsrc.v6b.tar.gz
  21. shell> cd jpeg-6b
  22. shell>./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
  23. shell> make && make install
  24.  
  25. libpng
  26. shell> cd /usr/local/src
  27. shell> tar -zvxf libpng-1.2..tar.gz
  28. shell> cd libpng-1.2.
  29. shell>./configure #和zlib一样不要带参数,让它默认安装到相应目录
  30. shell> make && make install
  31.  
  32. freetype
  33. shell> cd /usr/local/src
  34. shell> tar -zvxf freetype-2.3..tar.gz
  35. shell> cd freetype-2.3.
  36. shell> mkdir -p /usr/local/freetype
  37. shell>./configure --prefix=/usr/local/freetype
  38. shell> make && make install
  39.  
  40. GD
  41. shell> cd /usr/local/src
  42. shell> tar -zvxf gd-2.0..tar.gz
  43. shell> mkdir -p /usr/local/gd
  44. shell> cd gd-2.0.
  45. shell>./configure --prefix=/usr/local/gd \
  46. --with-jpeg=/usr/local/jpeg6/ \
  47. --with-png --with-zlib \
  48. --with-freetype=/usr/local/freetype
  49. shell> make && make instal

4).安装php:

  1. shell> cd /usr/local/src
  2. shell> tar -zxvf php-5.3..tar.gz
  3. shell> cd php-5.3. (必须使用php 5.3 不然的话 就会出现 配置选项不正确)
  4. shell>./configure --prefix=/usr/local/php \
  5. --with-apxs2=/usr/local/http2/bin/apxs \
  6. --with-mysql=mysqlnd \
  7. --with-pdo-mysql=mysqlnd \
  8. --with-mysqli=mysqlnd \
  9. --with-freetype-dir=/usr/local/freetype \
  10. --with-gd=/usr/local/gd \
  11. --with-zlib --with-libxml-dir=/usr/local/libxml2 \
  12. --with-jpeg-dir=/usr/local/jpeg6 \
  13. --with-png-dir \
  14. --enable-mbstring=all \
  15. --enable-mbregex \
  16. --enable-shared
  17. shell> make && make install
  18. shell> cp php.ini-dist /usr/local/php/lib/php.ini

五. 配置apache,使其支持PHP

  1. vi /usr/local/http2/conf/httpd.conf
  2. ):在httpd.conf(Apache主配置文件)中增加:
  3. AddType application/x-httpd-php .php
  4.  
  5. ):找到下面这段话:
  6. <IfModule dir_module>
  7. DirectoryIndex index.html
  8. </IfModule>
  9.  
  10. index.html 前面添加index.php
  11.  
  12. ):建立php测试网页
  13. vi /usr/local/http2/htdocs/index.php
  14. 输入如下内容:
  15. <?php
  16. phpinfo();
  17. ?>
  18.  
  19. ): 重启apache
  20. shell> /usr/local/http2/bin/apachectl restart
  21.  
  22. ):再次浏览器查看http://虚拟机IP
  23. 如果看到php信息,工作就完成了!

六 配置虚拟主机:

  

  1. )配置host文件
  2. 打开C:/windows/system32/drivers/etc/hosts 文件
  3. 增加域名记录
  4. 如:
  5. 192.168.1.246 www.ec1.com
  6. 192.168.1.246 www.ec2.com
  7.  
  8. ) 增加虚拟主机
  9. vi /usr/local/http2/conf/httpd.conf
  10. 取消#Include conf/extra/httpd-vhosts.conf
  11. 这一行前面的#号
  12. 保存退出
  13.  
  14. vi /usr/local/http2/conf/extra/httpd-vhosts.conf
  15. 增加虚拟主机记录
  16.  
  17. <VirtualHost *:>
  18. ServerAdmin webmaster@dummy-host.example.com
  19. DocumentRoot "/usr/local/http2/htdocs/ec1"
  20. ServerName www.ec1.com
  21. ServerAlias www.dummy-host.example.com
  22. ErrorLog "logs/dummy-host.example.com-error_log"
  23. CustomLog "logs/dummy-host.example.com-access_log" common
  24. </VirtualHost>
  25.  
  26. <VirtualHost *:>
  27. ServerAdmin webmaster@dummy-host2.example.com
  28. DocumentRoot "/usr/local/http2/htdocs/ec2"
  29. ServerName www.ec2.com
  30. ErrorLog "logs/dummy-host2.example.com-error_log"
  31. CustomLog "logs/dummy-host2.example.com-access_log" common
  32. </VirtualHost>
  33.  
  34. )
  35. shell> cd /usr/local/http2/htdocs
  36. shell> mkdir ec1 ec2
  37. shell> echo this is ec1.com > ec1/index.html
  38. shell> echo this is ec2.com > ec2/index.html
  39.  
  40. )重启apache
  41. /usr/local/http2/bin/apachectl restart
  42.  
  43. )浏览器打开www.ec1.com,和www.ec2.com
  44. 看到不同的网站内容,虚拟主机创建完毕!

以上就是整个配置流程,当然这个是源码编译的,你也可以使用yum进行安装!

lamp环境的搭建和安装的更多相关文章

  1. linux之lamp环境的搭建

    linux之lamp环境的搭建 1.安装lamp环境的安装工具 我们的lamp环境都是采用源码包进行编译安装: 编译安装需要工具gcc gcc-c++. 建议在线联网安装:yum  -install ...

  2. LAMP环境的搭建

    [一些前言废话]一名web开发尤其是后端不懂LAMP环境的搭建,那就摊上事了,有些人说他一直用win下的wampServer这种傻瓜式环境搭建,用的挺好的,也有人说他用云服务器,搭配“一键搭建LAMP ...

  3. Linux:LAMP环境的搭建

    LAMP环境的搭建 安装DNS服务器 安装DNS服务 yum install bind -y DNS的配置 创建正向解析 以创建一个名为"lsy.com"的正向查找区域为例: 第一 ...

  4. LAMP环境源码编译安装过程

    LAMP环境源码编译安装过程 一.Apache的安装 1.1.apache软件包及依赖包准备 httpd-2.4.29.tar.bz2       apr-1.6.3.tar.gz      apr- ...

  5. LAMP环境 源码包安装

    linux的学习很早就开始了,大学的时候的时候有有学过unix,后来每年都有去看看linux,因为在小城市的缘故,很少会实际工作中用到,基本都是智慧云之类的,同事也说,你学起来也用不上,IT生态不好, ...

  6. LAMP环境的搭建(四)----Apache下部署项目

    根据前文完成了LAMP基本环境的安装,那么接下来就是部署线上的环境了. yum 安装的apache 目录存在于  /etc/httpd apache最重要的文件就是 httpd.conf.  目录再 ...

  7. PHP学习记录第一篇:Ubuntu14.04下LAMP环境的搭建

    最近一段时间会学习一下PHP全栈开发,将会写一系列的文章来总结学习的过程,以自勉. 第一篇记录一下LAMP环境的安装 0. 安装Apache Web服务器 安装之前先更新一下系统 sudo apt-g ...

  8. LAMP环境的搭建(三)----PHP7的安装

    centos自带的PHP源是5.4版本的.如果需要安装PHP 5.4 直接输入 yum install php -y 即可 因为PHP7性能巨大的提升,因此本文选择安装PHP7 如果已经安装过了php ...

  9. LAMP环境的搭建(二)----Mysql安装与配置

    Mysql是一款免费开源的关系型数据库. 尽管Mysql被oracle公司收购.但是oracle并没有限制了mysql的发展. 目前mysql是使用范围最广的关系型数据库,许多大型公司也在使用.截至本 ...

随机推荐

  1. 详解 Go 语言中的 time.Duration 类型

    swardsman详解 Go 语言中的 time.Duration 类型swardsman · 2018-03-17 23:10:54 · 5448 次点击 · 预计阅读时间 5 分钟 · 31分钟之 ...

  2. Spring的一种拦截器SimpleUrlHandlerMapping

    spring的一种拦截器,用于在XML文件中配置以拦截url,它是以map映射的方式进行拦截.映射是从前台urls到具体后台的beans.同时支持到bean实例和bean名称的映射,后者要求非单实例控 ...

  3. selenium 获取按钮的笔记

    测试odoo时,发现大部分按钮都是动态生成,id也是动态的, 只能用xpath,但是配置一旦改变导致按钮位置改变 想到一个办法,遍历所有按钮,然后内容相符的才点击,测试代码如下 submit_loc ...

  4. 【BZOJ】1625: [Usaco2007 Dec]宝石手镯(01背包)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1625 太水了. #include <cstdio> #include <cstri ...

  5. MFC常见错误提示:opened in another editor

    有时候在使用MFC的过程中常常会遇到这种提示.假设你在看想必你也遇到这种烦恼. 没办法-- 把打开的文件所有关闭.然后你就发现期待的RC文件出现了! .!!!.!!!!!!! ! !.! !! .

  6. Git神器sourceTreesetup,让你的git效率迅速提升

    image.png 小编之前在简书和公众号发不过idea如何git clone,git add,创建分支,创建码云的操作idea和Webstorm上使用git和github,码云最近又找到一款git神 ...

  7. [ASK] brew install nginx

    .......... .......... Error: Permission denied - /usr/local/etc/openssl .......... .......... Cannot ...

  8. C++ 智能指针学习

     C++ Code  12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 ...

  9. 数据驱动ddt+excel数据读取

    我们可以将测试数据用excel存储,再用ddt去传入,不过我们需要安装对应的库,因为python是无法操作excel的 1.安装第三方库xlrd 2.创建一个excel表格,将需要测试的数据保存 3. ...

  10. ArcGIS ArcMap 问题(ArcMap闪退、cx_oracle安装不上)

    一.问题描述 1.ArcMap闪退 2.安装32位cx_oracle提示python目录不存在 二.解决方案 1.修改pythoncore的文件目录,指向C:\Python27\ArcGIS10.3\ ...