lamp环境的搭建和安装
最近,部门有些系统需要迁移到新的机器上,因此需要在新的机器上安装lamp和lnmp的环境,因此在这里总结一下:
一. 安装lamp环境的步骤:
(1).因为是新的机器,因此需要安装gcc的各种环境:
- 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:
- +-------------------------------------------------------------------------------+
- | 操作 | 作用 |
- +-------------------------------------------------------------------------------+
- |shell> cd /usr/local/src | 进入软件包所在目录(不要照抄) |
- |-------------------------------------------------------------------------------|
- |shell> groupadd mysql | 增加mysql组(如果有就不用加了) |
- |-------------------------------------------------------------------------------|
- |shell> useradd mysql -g mysql | 增加mysql用户,并属于mysql组 |
- |-------------------------------------------------------------------------------|
- |shell> tar -xzvf mysql-5.1..tar.gz | 解压mysql源码包 |
- |-------------------------------------------------------------------------------|
- |shell> cd mysql-5.1. | 进入源码包 |
- |-------------------------------------------------------------------------------|
- |shell> ./configure --prefix=/usr/local/mysql \ | 配置mysql编译选项, |
- | --with-charset=utf8 \ | 指定安装路径及支持的字符集 |
- | --with-extra-charsets=gbk,gb2312,binary \
- | |
- |-------------------------------------------------------------------------------|
- |shell> make | 编译 |
- |-------------------------------------------------------------------------------|
- |shell> make install | 安装 |
- +-------------------------------------------------------------------------------+
2).配置并初始化MySQL
- +---------------------------------------------------------------------------------------+
- | 操作 | 作用 |
- +---------------------------------------------------------------------------------------+
- |shell> cp support-files/my-medium.cnf /etc/my.cnf | 把MySQL配置文件复制到/etc下 |
- |---------------------------------------------------------------------------------------|
- |shell> vi /etc/my.cnf 在'skip_federated'前加'#'号 | 注释掉这个错误的启动项,这是一个比较新式的存储引擎|
- |---------------------------------------------------------------------------------------|
- |shell> cd /usr/local/mysql | 进入mysql的安装目录 |
- |---------------------------------------------------------------------------------------|
- |shell> chown -R mysql.mysql . | 修改属主属组为mysql,才能完成 |
- | | 下一步的初始化数据库工作 |
- |---------------------------------------------------------------------------------------|
- |shell> bin/mysql_install_db --user=mysql \ | 初始化数据数据库 |
- | --datadir=/usr/local/mysql/var | |
- |---------------------------------------------------------------------------------------|
- |shell> chown -R root . | 把var目录修改为mysql用户所有 |
- |shell> chown -R mysql var | 其他文件修改为root所有,保证安全|
- |---------------------------------------------------------------------------------------|
- |shell> bin/mysqld_safe --user=mysql & | 启动mysql |
- +---------------------------------------------------------------------------------------+
3).测试数据库
- +-------------------------------------------------+-------------------------------------+
- | 操作 | 作用 |
- +-------------------------------------------------+-------------------------------------+
- |shell> bin/mysql -uroot | 以root用户连mysql,无密码 |
- |---------------------------------------------------------------------------------------|
- |mysql> show databases; | 显示数据库 |
- |---------------------------------------------------------------------------------------|
- | +--------------------+ | |
- | | Database | | |
- | +--------------------+ | 看到左面的信息,数据库就安装 |
- | | information_schema | | 并启动成功了! |
- | | mysql | | |
- | | test | | |
- | +--------------------+ | |
- +---------------------------------------------------------------------------------------+
4).接上步,修改mysql密码(可不做此步,默认无密码)
- +-------------------------------------------------------------------------------+
- | 操作 | 作用 |
- +-------------------------------------------------------------------------------+
- |mysql>UPDATE user SET | |
- | password=PASSWORD('new_password') | 修改root用户的密码 |
- | WHERE user='root'; | |
- |-------------------------------------------------------------------------------+
- |mysql>flush privileges; | 清空权限缓存 |
- +-------------------------------------------------------------------------------+
二.安装 apache2
1) 安装zlib压缩库
- shell> cd /usr/local/src
- shell> tar -zxvf zlib-1.2..tar.gz
- shell> cd zlib-1.2.
- shell>./configure //这个配置编译命令不要加目录参数
- shell> make && make install
2)安装apache:
- shell> cd /usr/local/src
- shell> tar -zxvf httpd-2.2..tar.gz
- shell> cd httpd-2.2.
- shell>./configure --prefix=/usr/local/http2 \
- --enable-modules=most \
- --enable-rewrite \
- --enable-ssl \ #支持https的访问
- --enable-so
- shell> make && make install
- #启动Apache
- /usr/local/http2/bin/apachectl start
- #测试apache
- 浏览器打开: http://虚拟机IP
- 如果没有成功的话,可能是防火墙的问题 这时需要我们去设置防火墙 打开80端口
- 看到 "it works!",即为成功
三.安装图形库,为编译php做准备:
- )libxml2
- shell> cd /usr/local/src
- shell> tar -zxvf libxml2-2.6..tar.gz
- shell> cd libxml2-2.6.
- shell>./configure --prefix=/usr/local/libxml2
- shell> make && make install
- )jpeg6
- #安装出现错误 提示无关键目录无法继续
- #手动建立如下目录 ,注意 man1是数字1,不是字母L
- shell> mkdir -p /usr/local/jpeg6
- shell> mkdir -p /usr/local/jpeg6/bin
- shell> mkdir -p /usr/local/jpeg6/lib
- shell> mkdir -p /usr/local/jpeg6/include
- shell> mkdir -p /usr/local/jpeg6/man
- shell> mkdir -p /usr/local/jpeg6/man1
- shell> mkdir -p /usr/local/jpeg6/man/man1
- shell> cd /usr/local/src
- shell> tar -zxvf jpegsrc.v6b.tar.gz
- shell> cd jpeg-6b
- shell>./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
- shell> make && make install
- )libpng
- shell> cd /usr/local/src
- shell> tar -zvxf libpng-1.2..tar.gz
- shell> cd libpng-1.2.
- shell>./configure #和zlib一样不要带参数,让它默认安装到相应目录
- shell> make && make install
- )freetype
- shell> cd /usr/local/src
- shell> tar -zvxf freetype-2.3..tar.gz
- shell> cd freetype-2.3.
- shell> mkdir -p /usr/local/freetype
- shell>./configure --prefix=/usr/local/freetype
- shell> make && make install
- )GD库
- shell> cd /usr/local/src
- shell> tar -zvxf gd-2.0..tar.gz
- shell> mkdir -p /usr/local/gd
- shell> cd gd-2.0.
- shell>./configure --prefix=/usr/local/gd \
- --with-jpeg=/usr/local/jpeg6/ \
- --with-png --with-zlib \
- --with-freetype=/usr/local/freetype
- shell> make && make instal
4).安装php:
- shell> cd /usr/local/src
- shell> tar -zxvf php-5.3..tar.gz
- shell> cd php-5.3. (必须使用php 5.3 不然的话 就会出现 配置选项不正确)
- shell>./configure --prefix=/usr/local/php \
- --with-apxs2=/usr/local/http2/bin/apxs \
- --with-mysql=mysqlnd \
- --with-pdo-mysql=mysqlnd \
- --with-mysqli=mysqlnd \
- --with-freetype-dir=/usr/local/freetype \
- --with-gd=/usr/local/gd \
- --with-zlib --with-libxml-dir=/usr/local/libxml2 \
- --with-jpeg-dir=/usr/local/jpeg6 \
- --with-png-dir \
- --enable-mbstring=all \
- --enable-mbregex \
- --enable-shared
- shell> make && make install
- shell> cp php.ini-dist /usr/local/php/lib/php.ini
五. 配置apache,使其支持PHP
- vi /usr/local/http2/conf/httpd.conf
- ):在httpd.conf(Apache主配置文件)中增加:
- AddType application/x-httpd-php .php
- ):找到下面这段话:
- <IfModule dir_module>
- DirectoryIndex index.html
- </IfModule>
- 在index.html 前面添加index.php
- ):建立php测试网页
- vi /usr/local/http2/htdocs/index.php
- 输入如下内容:
- <?php
- phpinfo();
- ?>
- ): 重启apache
- shell> /usr/local/http2/bin/apachectl restart
- ):再次浏览器查看http://虚拟机IP
- 如果看到php信息,工作就完成了!
六 配置虚拟主机:
- )配置host文件
- 打开C:/windows/system32/drivers/etc/hosts 文件
- 增加域名记录
- 如:
- 192.168.1.246 www.ec1.com
- 192.168.1.246 www.ec2.com
- ) 增加虚拟主机
- vi /usr/local/http2/conf/httpd.conf
- 取消#Include conf/extra/httpd-vhosts.conf
- 这一行前面的#号
- 保存退出
- vi /usr/local/http2/conf/extra/httpd-vhosts.conf
- 增加虚拟主机记录
- <VirtualHost *:>
- ServerAdmin webmaster@dummy-host.example.com
- DocumentRoot "/usr/local/http2/htdocs/ec1"
- ServerName www.ec1.com
- ServerAlias www.dummy-host.example.com
- ErrorLog "logs/dummy-host.example.com-error_log"
- CustomLog "logs/dummy-host.example.com-access_log" common
- </VirtualHost>
- <VirtualHost *:>
- ServerAdmin webmaster@dummy-host2.example.com
- DocumentRoot "/usr/local/http2/htdocs/ec2"
- ServerName www.ec2.com
- ErrorLog "logs/dummy-host2.example.com-error_log"
- CustomLog "logs/dummy-host2.example.com-access_log" common
- </VirtualHost>
- )
- shell> cd /usr/local/http2/htdocs
- shell> mkdir ec1 ec2
- shell> echo this is ec1.com > ec1/index.html
- shell> echo this is ec2.com > ec2/index.html
- )重启apache
- /usr/local/http2/bin/apachectl restart
- )浏览器打开www.ec1.com,和www.ec2.com
- 看到不同的网站内容,虚拟主机创建完毕!
以上就是整个配置流程,当然这个是源码编译的,你也可以使用yum进行安装!
lamp环境的搭建和安装的更多相关文章
- linux之lamp环境的搭建
linux之lamp环境的搭建 1.安装lamp环境的安装工具 我们的lamp环境都是采用源码包进行编译安装: 编译安装需要工具gcc gcc-c++. 建议在线联网安装:yum -install ...
- LAMP环境的搭建
[一些前言废话]一名web开发尤其是后端不懂LAMP环境的搭建,那就摊上事了,有些人说他一直用win下的wampServer这种傻瓜式环境搭建,用的挺好的,也有人说他用云服务器,搭配“一键搭建LAMP ...
- Linux:LAMP环境的搭建
LAMP环境的搭建 安装DNS服务器 安装DNS服务 yum install bind -y DNS的配置 创建正向解析 以创建一个名为"lsy.com"的正向查找区域为例: 第一 ...
- LAMP环境源码编译安装过程
LAMP环境源码编译安装过程 一.Apache的安装 1.1.apache软件包及依赖包准备 httpd-2.4.29.tar.bz2 apr-1.6.3.tar.gz apr- ...
- LAMP环境 源码包安装
linux的学习很早就开始了,大学的时候的时候有有学过unix,后来每年都有去看看linux,因为在小城市的缘故,很少会实际工作中用到,基本都是智慧云之类的,同事也说,你学起来也用不上,IT生态不好, ...
- LAMP环境的搭建(四)----Apache下部署项目
根据前文完成了LAMP基本环境的安装,那么接下来就是部署线上的环境了. yum 安装的apache 目录存在于 /etc/httpd apache最重要的文件就是 httpd.conf. 目录再 ...
- PHP学习记录第一篇:Ubuntu14.04下LAMP环境的搭建
最近一段时间会学习一下PHP全栈开发,将会写一系列的文章来总结学习的过程,以自勉. 第一篇记录一下LAMP环境的安装 0. 安装Apache Web服务器 安装之前先更新一下系统 sudo apt-g ...
- LAMP环境的搭建(三)----PHP7的安装
centos自带的PHP源是5.4版本的.如果需要安装PHP 5.4 直接输入 yum install php -y 即可 因为PHP7性能巨大的提升,因此本文选择安装PHP7 如果已经安装过了php ...
- LAMP环境的搭建(二)----Mysql安装与配置
Mysql是一款免费开源的关系型数据库. 尽管Mysql被oracle公司收购.但是oracle并没有限制了mysql的发展. 目前mysql是使用范围最广的关系型数据库,许多大型公司也在使用.截至本 ...
随机推荐
- 详解 Go 语言中的 time.Duration 类型
swardsman详解 Go 语言中的 time.Duration 类型swardsman · 2018-03-17 23:10:54 · 5448 次点击 · 预计阅读时间 5 分钟 · 31分钟之 ...
- Spring的一种拦截器SimpleUrlHandlerMapping
spring的一种拦截器,用于在XML文件中配置以拦截url,它是以map映射的方式进行拦截.映射是从前台urls到具体后台的beans.同时支持到bean实例和bean名称的映射,后者要求非单实例控 ...
- selenium 获取按钮的笔记
测试odoo时,发现大部分按钮都是动态生成,id也是动态的, 只能用xpath,但是配置一旦改变导致按钮位置改变 想到一个办法,遍历所有按钮,然后内容相符的才点击,测试代码如下 submit_loc ...
- 【BZOJ】1625: [Usaco2007 Dec]宝石手镯(01背包)
http://www.lydsy.com/JudgeOnline/problem.php?id=1625 太水了. #include <cstdio> #include <cstri ...
- MFC常见错误提示:opened in another editor
有时候在使用MFC的过程中常常会遇到这种提示.假设你在看想必你也遇到这种烦恼. 没办法-- 把打开的文件所有关闭.然后你就发现期待的RC文件出现了! .!!!.!!!!!!! ! !.! !! .
- Git神器sourceTreesetup,让你的git效率迅速提升
image.png 小编之前在简书和公众号发不过idea如何git clone,git add,创建分支,创建码云的操作idea和Webstorm上使用git和github,码云最近又找到一款git神 ...
- [ASK] brew install nginx
.......... .......... Error: Permission denied - /usr/local/etc/openssl .......... .......... Cannot ...
- C++ 智能指针学习
C++ Code 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 ...
- 数据驱动ddt+excel数据读取
我们可以将测试数据用excel存储,再用ddt去传入,不过我们需要安装对应的库,因为python是无法操作excel的 1.安装第三方库xlrd 2.创建一个excel表格,将需要测试的数据保存 3. ...
- ArcGIS ArcMap 问题(ArcMap闪退、cx_oracle安装不上)
一.问题描述 1.ArcMap闪退 2.安装32位cx_oracle提示python目录不存在 二.解决方案 1.修改pythoncore的文件目录,指向C:\Python27\ArcGIS10.3\ ...