lamp编译安装

author author     2022-08-09     780

关键词:

lamp编译安装

================================================================================

编译安装amp

 1.编译前环境准备及相关介绍

系统环境:CentOS 6, 7

  • CentOS 6:apr, apr-util 的版本为1.3.9,不适用于httpd-2.4的编译安装;

  • CentOS 7:apr, apr-util的版本为1.4+,

(apr:简言之是为apache各程序包运行时提供的环境,可以当做是httpd的虚拟机,所以httpd是高度依赖于apr的)

  • 在生产环境中,一般不建议去编译安装,只有当默认提供的程序包不足以满足我们的需求时,即我们用到的模块没有时,才去编译安装。当然为了方便我们也可以自己制作成rpm包。

开发环境:

  任何编译安装依据的都是开发环境

  • Development Tools, 

  • Server Platform Development

各程序版本

  • httpd: 2.2, 2.4

  • php:5.3.x 5.4.x, 5.6.x

  • mysql:5.1, 5.5, 5.6, 5.7, 5.8, 8.0

  • mariadb:5.x, 10.x

httpd+php结合方式

 php的编译选项:

  • Modules:--with-apxs

      httpd MPM:

         prefork:编译的是进程模型的模块

         worker, event:

             专用选项 --enable-maintainer-zts 编译的是线程模型的模块

  • ftm:--enable-fpm 


编译安装amp

编译的amp环境:

  • 在CentOS 7上编译 httpd-2.4, mariadb, php-5.4

安装次序:

  • httpd, mariadb, php 

   httpd和mariadb是无先后次序的,但是php是依赖于前面的所以要放到最后编译;


安装MariaDB:

  • 预制的包管理器格式的程序包:

      rpm包:

         os vendor:安装 mariadb-devel包,编译php时会基于此程序包 ;

         MariaDB官方

  • 通用二进制格式的程序包:展包即用,是别人已经编译好的;

  • 源码包编译:项目构建工具为cmake, 而非流行的make;



1.这里我们以CentOS 7采用通用二进制的格式编译安装mariadb,详细过程如下:


   1)首先获取mariadb的程序包,并下载到本地

[[email protected] ~]# lftp 10.1.0.1/pub
lftp 10.1.0.1:/pub/Sources/7.x86_64/mariadb> ls
-rwxr--r--    1 500      500      445617978 Nov 05  2015 mariadb-10.1.8-linux-glibc_214-x86_64.tar.gz
-rwxr--r--    1 500      500      222601284 Nov 05  2015 mariadb-5.5.46-linux-x86_64.tar.gz
lftp 10.1.0.1:/pub/Sources/7.x86_64/mariadb> pwd
ftp://10.1.0.1/pub/Sources/7.x86_64/mariadb
lftp 10.1.0.1:/pub/Sources/7.x86_64/mariadb> mget mariadb-5.5.46-linux-x86_64.tar.gz 
222601284 bytes transferred in 9 seconds (24.84M/s)                                        
lftp 10.1.0.1:/pub/Sources/7.x86_64/mariadb> bye
[[email protected] ~]# ls
anaconda-ks.cfg  mariadb-5.5.46-linux-x86_64.tar.gz # 下载的程序包 公共  模板  视频  图片  文档  下载  音乐  桌面
[[email protected] ~]# ll -h mariadb-5.5.46-linux-x86_64.tar.gz 
-rw-r--r-- 1 root root 213M 11月  5 2015 mariadb-5.5.46-linux-x86_64.tar.gz

   2)采用通用二进制的格式编译安装要求安装在/usr/local/mysql下

# 展开至/usr/local
[[email protected] ~]# tar xf mariadb-5.5.46-linux-x86_64.tar.gz -C /usr/local
[[email protected] ~]# cd /usr/local
[[email protected] local]# ls
bin  games    lib    libexec                      sbin   src
etc  include  lib64  mariadb-5.5.46-linux-x86_64  share
# 为了方便以后的升级和管理我们这里创建一个软链接
[[email protected] local]# ln -sv mariadb-5.5.46-linux-x86_64/ mysql
"mysql" -> "mariadb-5.5.46-linux-x86_64/"
[[email protected] local]# ll
总用量 44
drwxr-xr-x.  2 root root 4096 8月  12 2015 bin
drwxr-xr-x.  2 root root 4096 8月  12 2015 etc
drwxr-xr-x.  2 root root 4096 8月  12 2015 games
drwxr-xr-x.  2 root root 4096 8月  12 2015 include
drwxr-xr-x.  2 root root 4096 8月  12 2015 lib
drwxr-xr-x.  2 root root 4096 8月  12 2015 lib64
drwxr-xr-x.  2 root root 4096 8月  12 2015 libexec
drwxr-xr-x  12 root root 4096 10月 15 15:21 mariadb-5.5.46-linux-x86_64
lrwxrwxrwx   1 root root   28 10月 15 15:26 mysql -> mariadb-5.5.46-linux-x86_64/
drwxr-xr-x.  2 root root 4096 8月  12 2015 sbin
drwxr-xr-x.  5 root root 4096 8月  22 09:16 share
drwxr-xr-x.  2 root root 4096 8月  12 2015 src

   3)因为我使用的这台CentOS 7已经安装过mariadb了,所以为了防止和系统中的起冲突,所以,我把原来系统中的移除

[[email protected] local]# rpm -q mariadb-server
mariadb-server-5.5.44-2.el7.centos.x86_64
[[email protected] local]# yum remove mariadb-server # 移除本机服务器端程序包
[[email protected] local]# rpm -q mariadb
mariadb-5.5.44-2.el7.centos.x86_64
[[email protected] local]# yum remove mariadb # 卸载客户端程序包

    4)通常我们运行mysql都需要一个普通用户,所以要创建一个叫mysql的系统用户,和系统组;并且我们要创建一个数据库目录,(实际生产环境中应该放在一个单独的存储设备并且有冗余的功能,如:RAID10),并且授权属主和属组为myaql

[[email protected] local]# id mysql # mysql 用户已经存在
uid=27(mysql) gid=27(mysql) 组=27(mysql)
[[email protected] local]# mkdir -pv /mydata/data # 创建数据库目录
mkdir: 已创建目录 "/mydata"
mkdir: 已创建目录 "/mydata/data"
[[email protected] local]# chown -R mysql.mysql /mydata/data # 授权属主属组为mysql
[[email protected] local]# ll -d /mydata/data
drwxr-xr-x 2 mysql mysql 4096 10月 15 15:54 /mydata/data

    5)接下来我们设定数据库服务器的相关文件,并且都应该以mysql的身份运行,但为了保证安全,不能让mysql有写权限,所以属主为root,属组为mysql仅有读权限。

[[email protected] local]# chown -R root.mysql ./*
[[email protected] local]# ll
总用量 44
drwxr-xr-x.  2 root mysql 4096 8月  12 2015 bin
drwxr-xr-x.  2 root mysql 4096 8月  12 2015 etc
drwxr-xr-x.  2 root mysql 4096 8月  12 2015 games
drwxr-xr-x.  2 root mysql 4096 8月  12 2015 include
drwxr-xr-x.  2 root mysql 4096 8月  12 2015 lib
drwxr-xr-x.  2 root mysql 4096 8月  12 2015 lib64
drwxr-xr-x.  2 root mysql 4096 8月  12 2015 libexec
drwxr-xr-x  12 root mysql 4096 10月 15 15:21 mariadb-5.5.46-linux-x86_64
lrwxrwxrwx   1 root mysql   28 10月 15 15:26 mysql -> mariadb-5.5.46-linux-x86_64/
drwxr-xr-x.  2 root mysql 4096 8月  12 2015 sbin
drwxr-xr-x.  5 root mysql 4096 8月  22 09:16 share
drwxr-xr-x.  2 root mysql 4096 8月  12 2015 src

  6)接下来我们要初始化mysql,即生成元数据数据库

[[email protected] local]# cd mysql/
[[email protected] mysql]# ls
bin  COPYING  COPYING.LESSER  data  EXCEPTIONS-CLIENT  include  INSTALL-BINARY  lib  man  mysql-test  README  scripts  share  sql-bench  support-files

# 使用scripts/mysql_install_db 生成元数据数据库
[[email protected] mysql]# ./scripts/mysql_install_db --help # 查看帮助
Usage: ./scripts/mysql_install_db [OPTIONS]
  --basedir=path       The path to the MariaDB installation directory.
  --builddir=path      If using --srcdir with out-of-directory builds, you
                       will need to set this to the location of the build
                       directory where built files reside.
  --cross-bootstrap    For internal use.  Used when building the MariaDB system
                       tables on a different host than the target.
  --datadir=path       The path to the MariaDB data directory.
  --defaults-extra-file=name
                       Read this file after the global files are read.
  --defaults-file=name Only read default options from the given file name.
  --force              Causes mysql_install_db to run even if DNS does not
                       work.  In that case, grant table entries that
                       normally use hostnames will use IP addresses.
  --help               Display this help and exit.                     
  --ldata=path         The path to the MariaDB data directory. Same as
                       --datadir.
  --no-defaults        Don‘t read default options from any option file.
  --defaults-file=path Read only this configuration file.
  --rpm                For internal use.  This option is used by RPM files
                       during the MariaDB installation process.
  --skip-name-resolve  Use IP addresses rather than hostnames when creating
                       grant table entries.  This option can be useful if
                       your DNS does not work.
  --srcdir=path        The path to the MariaDB source directory.  This option
                       uses the compiled binaries and support files within the
                       source tree, useful for if you don‘t want to install
                       MariaDB yet and just want to create the system tables.
  --user=user_name     The login username to use for running mysqld.  Files
                       and directories created by mysqld will be owned by this
                       user.  You must be root to use this option.  By default
                       mysqld runs using your current login name and files and
                       directories that it creates will be owned by you.

All other options are passed to the mysqld program

# 指明用户,位置,生成元数据库数据文件,
[[email protected] mysql]# ./scripts/mysql_install_db --datadir=/mydata/data --user=mysql --skip-name-resolve
[[email protected] mysql]# ls /mydata/data/  # 查看生成的文件如下
aria_log.00000001  aria_log_control  mysql  performance_schema  test

   7)如上mysql数据库就已经创建完成了,接下来我们要为数据库提供主配置文件,需要复制示例配置文件到/etc/my.cnf/目录下,修改即可;

[[email protected] mysql]# pwd
/usr/local/mysql
[[email protected] mysql]# ls
bin             EXCEPTIONS-CLIENT  man         share
COPYING         include            mysql-test  sql-bench
COPYING.LESSER  INSTALL-BINARY     README      support-files 
data            lib                scripts
[[email protected] mysql]# ls support-files/ # 配置文件示例
binary-configure        my-large.cnf         mysql-log-rotate
magic                   my-medium.cnf        mysql.server
my-huge.cnf             my-small.cnf         SELinux
my-innodb-heavy-4G.cnf  mysqld_multi.server

# 复制示例配置文件到/etc/my.cnf.d下并命名为server.cnf(只要以.cnf结尾即可)
[[email protected] mysql]# cp support-files/my-large.cnf /etc/my.cnf.d/server.cnf 
[[email protected] mysql]# vim /etc/my.cnf.d/server.cnf  # 编辑文件如下图

 技术分享


    8)为mysql提供sysv服务脚本

[[email protected] mysql]# pwd
/usr/local/mysql
[[email protected] mysql]# ls support-files/
binary-configure  my-innodb-heavy-4G.cnf  my-small.cnf         mysql.server # 脚本文件
magic             my-large.cnf            mysqld_multi.server  SELinux
my-huge.cnf       my-medium.cnf           mysql-log-rotate 

[[email protected] mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld #复制脚本
[[email protected] mysql]# chmod +x /etc/rc.d/init.d/mysqld # 添加执行权限

#添加至服务列表
[[email protected] mysql]# chkconfig --add mysqld

    9)接下来我们就可以启动服务了

[[email protected] mysql]# service mysqld start
Starting MySQL... SUCCESS!  # 启动成功
[[email protected] mysql]# ss -tnl # 查看端口3306
State       Recv-Q Send-Q      Local Address:Port                     Peer Address:Port              
LISTEN      0      128             127.0.0.1:9000                                *:*                  
LISTEN      0      50                      *:3306                                *:*                  
LISTEN      0      5           192.168.122.1:53                                  *:*                  
LISTEN      0      128                     *:22                                  *:*                  
LISTEN      0      128             127.0.0.1:631                                 *:*                  
LISTEN      0      100             127.0.0.1:25                                  *:*                  
LISTEN      0      128             127.0.0.1:6010                                *:*                  
LISTEN      0      128                    :::80                                 :::*                  
LISTEN      0      128                    :::22                                 :::*                  
LISTEN      0      128                   ::1:631                                :::*                  
LISTEN      0      100                   ::1:25                                 :::*                  
LISTEN      0      128                   ::1:6010                               :::*
# 客户端程序文件在/usr/local/mysql/bin/mysql,可以连接上去
[[email protected] mysql]# /usr/local/mysql/bin/mysql
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 2
Server version: 5.5.46-MariaDB-log MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type ‘help;‘ or ‘h‘ for help. Type ‘c‘ to clear the current input statement.

MariaDB [(none)]>

   10)为了使用mysql的安装符合系统使用规范,并将其开发组件导出给系统使用,这里还需要进行如下配置:


  输出mysql的man手册至man命令的查找路径:

      编辑/etc/man_db.conf添加如下图所示内容

技术分享

  • 出mysql的头文件至系统文件路径/usr/include

[[email protected] mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql
"/usr/include/mysql" -> "/usr/local/mysql/include/"
  • 输出mysql的库文件给系统库查找路径:

       # echo ‘/usr/local/mysql/lib‘ > /etc/ld.so.conf.d/mysql.conf

     而后让系统重新载入系统库

       # ldconfig

  • 修改PATH环境变量,让系统可以直接使用mysql的相关命令。 

[[email protected]~]# cat << eof > /etc/profile.d/mysql.sh
> PATH=$PATH:/usr/local/mysql/bin
> eof
[[email protected] profile.d]# cat mysql.sh 
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin

 如上整个编译过程就已经完成了,直接运行命令即可。。。

 总结过程如下:

技术分享


2.httpd-2.4编译安装

技术分享


3.php5编译安装

技术分享







lamp源码编译安装

查看详情

编译安装lamp环境

LAMP环境配置:httpd-2.4.23+mysql-5.5.51+php-5.5.38编译安装过程编译前先准备系统的开发环境:# yum groupinstall "Development tools" "Server Platform Development"一、编译安装apache1、解决依赖关系httpd-2.4.23 查看详情

源码编译安装lamp

一、概述1、源码编译安装LAMP为什么要源码编译      一般来说,我们软件的安装方式有yum(rpm),和源码编译两种方式,那么为什么我们需要源码编译安装一部分软件?选择源码编译安装软件有以下几个原... 查看详情

编译安装lamp

题目:在LAMP架构中,请分别以php编译成httpd模块形式和php以fpm工作为独立守护进程的方式来支持httpd,列出详细的过程。本次实验以CentOS7为搭建环境,并且已经使用源码编译安装了httpd-2.4(默认使用prefork模块)和使用通用二进... 查看详情

lamp编译安装(代码片段)

lamp编译安装CentOS6:PHP-5.3.2之前:默认不支持fpm机制;需要自行打补丁并编译安装httpd-2.2:默认不支持fcgi协议,需要自行编译此模块解决方案:编译安装httpd-2.4,php-5.3.3+CentOS7:httpd-2.4:rpm包默认编译支持fcgi模块php-fpm包:专用于... 查看详情

lamp之自动化编译安装

...php-fpm的安装,安装高版本的数据库在centos6上也需要通过编译安装完成,本文介绍了Modules模式和FastCGI模式快速部署LAMP的包和相关操作,同时附上了一键安装的编译脚本。2 快速部署LAMP在CentOS6和7中,在Modules模式和FastCGI模式... 查看详情

lamp编译安装1

650)this.width=650;"src="https://s4.51cto.com/wyfs02/M00/8C/CC/wKioL1h4o0aQgM_GAAP_QuXLPWc712.jpg"title="LAMP编译安装1.jpg"alt="wKiom1h4oGbwtqpHAAQHoqOfbzE513.jpg"/> 查看详情

lamp之编译安装

...易用,但在某些特定情况下,由于有特殊需求,需要基于编译这种方式来定制化安装所需要的软件,以能特供自己所需的功能,此处我们来基于编译实现LAMP环境,来揭开编译安装这种听起来高大上的安装方式。首先来交代一下... 查看详情

lamp编译安装系列

主要还是centos6.9和centos7上相应软件包的安装及编译安装。所用版本均为当前最新版。生产环境中不建议这么干,毕竟生成以稳定为主。LAMP里php是最后安装,php依赖于服务器和数据库,所以这里单独编译系列就只有httpd和mariadb了... 查看详情

lamp安装脚本(编译方式)

#!/bin/bash##**********************************************************#*filename:   lamp_install.sh  *#*discription:  lampinstall  *#*version:   centos6.7a 查看详情

lamp环境编译安装

MySQL编译安装#安装编译代码需要的包yum-yinstallmakegcc-c++cmakebison-devel  ncurses-devel#mysql安装wgethttp://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.32.tar.gztar-zxvfmysql-5.6.32.tar.gzcdmysql-5.6.3 查看详情

lamp编译安装(未完待续)

顺序安装:linuxapachemysqlphpLinux这个就不多说明了...CentOS6.5镜像虚拟机安装一次性安装开发工具:#yumgroupinstall"Developmenttools"or:#yum-ygroupinstall"Developmenttools"查看已安装的:#yumgrouplist|more#yumgrouplist|grepDevelpment#yumgrou 查看详情

编译安装lamp

yuminstallgccgcc-c++ncurses-develperl 安装cmakewgethttp://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz  tar-xzvfcmake-2.8.10.2.tar.gz  cdcmake-2.8.10.2  ./bootstrap& 查看详情

超详细lamp环境手动编译安装实例

LAMP编译安装实例:    HTTPD编译安装:    下载软件包:    # wget http://mirrors.hust.edu.cn/apache//apr/apr-1.6.3.tar.gz http://mirrors.hust.edu 查看详情

源码编译安装lamp

环境:centos6.6;httpd-2.2.34;mysql-5.5.55;php5.6.31#!/bin/bash#2017-08-12#author by Tan Wen Xin#Auto install LAMP#create DNS servercat>>/etc/resolv.conf<& 查看详情

编译安装lamp

软件包链接:http://pan.baidu.com/s/1mijn44g  密码:abja 系统环境:centos7开发环境:Developmenttools、ServerPlatformDevelopmenthttp+php的方式:PHP模块化个程序版本:mariadbmariadb-5.5.46-linux-x86_64.tar.gzhttphttpd-2.4. 查看详情

lamp编译实现

一、简述LAMP:二、HTTP2.4编译安装三、源码安装MySQL5.6四、源码安装php-5.6五、配置http访问PHP六、配置php访问mysql实验环境为:   php-fpm和msyql编译为同一台主机(CentOS6.9)   httpd单独一台主机(CentOS6.9)一、... 查看详情

编译安装lamp

文章说明本文中Linux命令使用的大部分是绝对路径(若没有前面有相应的目录切换命令)安装时可以不考虑路径问题服务器相关信息腾讯云Centos72G内存20G硬盘软件源码位置及软件安装的目录源码存放目录:usrsrc软件安装目录:usrl... 查看详情