LAMP的编译安装

一、编译安装amp:

(1)系统环境:centos6,7

httpd依赖于apr和apr-util

appache protable runtime

(2)开发环境:

Development Tools,Server Platform Development

(3)各程序的版本:

httpd:2.2,2.4

php:5.x

mysql:5.1,5.5,5.6,5.7,5.8

mariadb:5.x,10.x

(4)httpd+php

modules:–with-apxs=

prefork:libphp5.so

worker,event:libphp5-zts.so

fpm:

5.3.3-,手动打上fpm patch;

5..3.3+,自带了fpm,编译时只需要使用–fpm选项;

过程:

先安装am,再安装p

安装MySQL:

预制的二进制程序包:

os vendor:mariadb-devel或mysql-devel;

项目官方提供的

二进制格式的程序包:展包即用;

源代码:编译安装

第一种安装:

(1)yum install mariadb-devel

(2)yum install mariadb-server

假如部署mysql时,将http和mysql安装在不同机器上,那么本台安装http的服务器只需安装好开发环境即可,无需安装mariadb-server.只在另一台上安装mariadb-server即可。

以模块化安装,割裂为两台主机。以fpm安装可以分割为三台主机。

第二种(二进制格式程序安装):

移除mariadb-server 和mariadb-devel

(1)获取tar包,创建mysql用户和组

(2) tar xf mariadb-5.5.46-linux-x86_64.tar.gz -C /usr/local

(3)ln -sv mariadb-5.5.46-linux-x86_64 mysql

数据库默认存在于data目录下

(4)改权限:chown -R root:mysql ./*

(5)创建存放数据的文件目录mkdir -pv /mydata/data

chown mysql:mysql /mydata/data

(6)scripts/mysql_install_db –help

(7)[root@centos7 mysql]# scripts/mysql_install_db –datadir=/mydata/data –user=mysql

(8)ls  /mydata/data/

LAMP的编译安装1.jpg

(9) 配置文件的修改cp support-files/my-large.cnf /etc/my.cnf

LAMP的编译安装2.jpg

修改thread_concurrency = 2

datadir=/mydata/data

skip_name_resolve=ON

innodb_file_per_table=ON

其中2指的是CPU的核心数乘以2.

(10)提供mysql运行的脚本cp support-files/mysql.server /etc/rc.d/init.d/mysqld

chmod +x /etc/rc.d/init.d/mysqld

(11)chkconfig –add mysqld

chkconfig –list

(12)开启服务service mysqld start

(13)vim /etc/profile.d/mysql.sh

LAMP的编译安装3.jpg

(14) . /etc/profile.d/mysql.sh

二、安装httpd-2.4

(1) yum groupinstall "Development Tools" "Server Platform Development"

(2)yum install pcre-devel openssl-devel libevent-devel apr-devel apr-util-devel

(3)./configure –prefix=/usr/local/apache2 –sysconfdir=/etc/httpd –enable-so –enable-cgi –enable-modules=most –enable-mpms-shared=all –with-mpm=prefork –with-zlib –with-apr=/usr –with-apr-util=/usr

(4)make

(5)make install

(6)vim /etc/profile.d/apache.sh

LAMP的编译安装4.jpg

(7) . /etc/profile.d/apache.sh

(8) apachectl start

LAMP的编译安装5.jpg

出现如下报错,原来是/etc/hosts文件中没有写主机信息

网友解决方案:http://www.cnblogs.com/Anker/p/3355039.html

LAMP的编译安装6.jpg

三、安装php5

(1)yum install gd-devel freetype-devel libmcrypt-devel libxml2-devel

(2)./configure –prefix=/usr/local/php –with-mysql –with-openssl –with-mysql=/usr/bin/mysql_config –enable-mbstring –enable-xml –enable-sockets –with-freetype-dir –with-gd –with-libxml-dir=/usr –with-zlib –with-jpeg-dir –with-png-dir –with-mcrypt –with-apx2=/usr/local/apache2/bin/apxs –with-config-file-path=/etc/php.ini –with-config-file-scan-dir=/etc/php.d/

(3)make -J #

(4)make install

(6)cp php.ini-production /etc/php.ini

(7)makedir /etc/php.d/

注意:如果httpd使用线程模型MPM,需要额外的–enable-maintainer-zts选项;

注意:如果要以fpm方式允许php,需要编译时移除–with-apxs选项。

注意:如果独立安装的mysql-server,假设安装在/usr/local/mysql目录下,则需要使用类似如下的.configure命令。

./configure –prefix=/usr/local/php –with-mysql=/usr/local/mysql –with-openssl –with-mysql=/usr/local/bin/mysql/mysql_config –enable-mbstring –enable-xml –enable-sockets –with-freetype-dir -with-gd –with-libxml-dir=/usr –with-png-dir –with-apxs2=/usr/local/apache2/bin/apxs –with-config-file-path=/etc/php.ini –with-config-file-scan-dir=/etc/php.d/

整合php

httpd.conf配置文件中:

AddType application/x-httpd-php.php

DirectoryIndex index.php index.html

原创文章,作者:178babyhanggege,如若转载,请注明出处:http://www.178linux.com/51141

(0)
178babyhanggege178babyhanggege
上一篇 2016-10-17
下一篇 2016-10-17

相关推荐

  • 主流Linux发行版对比

      对服务器来说,没有最好的Linux发行版。一切都取决于企业的实际需求。 如今Linux已不再只是一款自由操作系统,它还承载了许多企业的核心应用。在对比流行的Linux发行版时,不仅要考虑有吸引力的功能集,还要关注系统的支持与服务。 服务器管理员担心操作系统的维护和支持周期。维护生命周期指的是Linux发行版持续提供产品补丁和更新的时间。支持方面…

    Linux干货 2016-10-31
  • class9 bash编程基础(一)

    一、编程基础 程序:指令+ 数据 程序编程风格: 过程式:以指令为中心,数据服务于指令 对象式:以数据为中心,指令服务于数据 shell 程序:提供了编程能力,解释执行 程序的执行方式 计算机:运行二进制指令; 编程语言: 低级:汇编 高级: 编译:高级语言–> 编译器–> 目标代码   &n…

    Linux干货 2016-08-15
  • 缓存需知

    Edit Web缓存核心技术点需知 5.1 HTTP首部控制 5.2 基于新鲜度检测机制: 2.1 特征1:时间局部性 2.2 特征2:空间局部性 2.3 缓存的优点 2.4 哪类数据应该被缓存 2.5 哪类数据可缓存但不应该被缓存 2.6 缓存命中率决定缓存有效性 2.7 缓存数据生命周期 2.8 缓存处理步骤 2.9 缓存和普通数据读取的区别 1. 完整…

    Linux干货 2015-02-22
  • 进程和优先级

         什么是进程?我们先来了解一下进程的概念:我们知道操作系统最核心的概念就是进程。进程简单来说就是在操作系统中运行的程序,它是操作系统资源管理的最小单位。但是进程是一个动态的实体,它是程序的一次执行过程。进程和程序的区别在于:进程是动态的,程序是静态的,进程是运行中的程序,而程序是一些保存在硬盘上的可执行代码。    当多个任务要执行时怎么办呢?先执行…

    2017-09-09
  • N23-北京-阿来

           我是阿来,我参加了马哥Linux运维网络班,从2016年9月开始我将跟随马哥学习Linux技术。我的学习宣言是:学习的路,就在脚下,一步一个脚印,领路的人,就这这里,一天一点进步!

    Linux干货 2016-09-12
  • grub的启动加密及删除恢复

    一、实验1:设置grub口令 1、生成一个加密运算为"nd5"的密码 2、设置grub口令 3、测试grub是否已加密 4、在虚拟机的下图的图形界面中,直接敲"Esc"或者"e"键 5、在图形的框下,提示只能敲"p"键,原因是因为grub加密的原因 6、直接敲"p&qu…

    Linux干货 2016-10-04