编译安装LAMP

编译安装LAMP

(1) 系统环境:CentOS 6, 7 
    CentOS 6:
apr, apr-util的版本为1.3.9,不适用于httpd-2.4; 
    CentOS 7:
apr, apr-util的版本为1.4+, 
(2) 开发环境: 
    Development Tools, Server Platform Development 
(3) 各程序版本 
    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 
(4) httpd+php 
    php的编译选项: 
        Modules:
--with-apxs 
        httpd MPM: 
            prefork: 
            worker, event:专用选项–enable-maintainer-zts 
    fpm:
--enable-fpm

本次安装以CentOS 7为例进行安装

安装httpd-2.4

[root@centos7 ~]# mkdir -p /usr/local/lamp  #创建lamp目录
[root@centos7 ~]# yum -y groupinstall "Development Tools" "Server Platform Development"  #安装开发环境
[root@centos7 ~]# yum -y install pcre-devel openssl-devel libevent-devel apr-devel apr-util-devel  #安装依赖包
[root@centos7 ~]# useradd -r -s /sbin/nologin apache  #创建apache系统用户
[root@centos7 ~]# tar xf httpd-2.4.6.tar.bz2  #解压
[root@centos7 ~]# cd httpd-2.4.6/
[root@centos7 httpd-2.4.6]# ./configure --prefix=/usr/local/lamp/apache2 --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork --with-pcre --with-zlib --with-apr=/usr --with-apr-util=/usr  #配置httpd
[root@centos7 httpd-2.4.6]# make   #编译
[root@centos7 httpd-2.4.6]# make install #安装
[root@centos7 ~]# echo "export PATH=/usr/local/lamp/apache2/bin:$PATH" > /etc/profile.d/httpd.sh  #配置PATH环境变量
[root@centos7 ~]# . /etc/profile.d/httpd.sh   #生效
[root@centos7 ~]# vim /etc/httpd/httpd.conf   #编辑配置文件

287)C{F]5MS5S7{PE[G@357.png

8JL)6O$0I(7S7B6[81U`_N9.png

[root@centos7 ~]# apachectl start  #启动httpd服务

G$$Z}(FYJ5MFKLX){[C[TSW.png

]PK)ZMXWWT7T1S0({HSJ_KK.png

安装mariadb

安装MariaDB: 
    1.预制的包管理器格式的程序包: 
        rpm包: 
            os vendor:mariadb-devel 
            MariaDB官方 
    2.通用二进制格式的程序包: 
    3.源码包编译:项目构建工具为cmake, 而非流行的make;

本次以通用二进制格式包的安装配置

[root@centos7 ~]# useradd -r -s /sbin/nologin mysql  #创建mysql系统用户
[root@centos7 ~]# tar xf mariadb-VERSION-linux-x86_64.tar.gz -C /usr/local/lamp  #解压至/usr/local/lamp目录下
[root@centos7 ~]# cd /usr/local/lamp
[root@centos7 lamp]# ln -s mariadb-VERSION-linux-x86_64 mysql  #创建软连接
[root@centos7 ~]# cd mysql
[root@centos7 mysql]# chown -R mysql:mysql ./*  #修改属主属组为mysql
[root@centos7 mysql]# mkdir -pv /mydata/data  #为mysql创建数据目录
[root@centos7 mysql]# chown -R mysql:mysql /mydata/data  #修改数据目录属主属组为msql
[root@centos7 mysql]# ./scripts/mysql_install_db  --user=mysql  --datadir=/mydata/data --skip_name_resolve   #安装mysql
[root@centos7 mysql]# cp support-files/my-large.cnf  /etc/my.cnf  #生成配置文件
[root@centos7 mysql]# cp support-files/mysql.server  /etc/rc.d/init.d/mysqld   #生成服务脚本文件
[root@centos7 mysql]# chkconfig --add mysqld   #添加开机自启动
[root@centos7 mysql]# chkconfig --level 2345 mysqld on  #开机在2345运行级别下启动

[root@centos7 mysql]# vim /etc/my.cnf  #编辑配置文件

%RS3FI0M@E4I(DW]4{9N33U.png

[root@centos7 mysql]# service mysqld start   #启动mysql服务
Starting MySQL.. SUCCESS!
[root@centos7 mysql]#

1E2E4)XP}VB%I_P}F2U(E8S.png

[root@centos7 ~]# echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh   #配置PATH环境变量
[root@centos7 ~]# . /etc/profile.d/mysql.sh   #生效
[root@centos7 ~]# mysql_secure_installation   #可对数据库做安全配置  
[root@centos7 ~]# mysql  #测试数据库
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
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)]>     #数据库配置成功!!!!

基于module安装php

Modules:--with-apxs 
    httpd MPM: 
        prefork: 
        worker, event:专用选项
--enable-maintainer-zts 

[root@centos7 ~]# yum -y install gd-devel freetype-devel libxml2-devel libmcrypt-devel   #安装php依赖包
[root@centos7 ~]# tar xf php-5.4.40.tar.bz2  #解压
[root@centos7 ~]# cd php-5.4.40/
[root@centos7 php-5.4.40]# ./configure --prefix=/usr/local/lamp/php5 --with-mysql=/usr/local/lamp/mysql --with-mysqli=/usr/local/lamp/mysql/bin/mysql_config --with-openssl --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-apxs2=/usr/local/lamp/apache2/bin/apxs --with-config-file-path=/etc/php.ini --with-config-file-scan-dir=/etc/php.d/  #配置php参数
[root@centos7 php-5.4.40]# make  #编译
[root@centos7 php-5.4.40]# make install  #安装
[root@centos7 php-5.4.40]# cp php.ini-production /etc/php.ini  #复制配置文件
[root@centos7 php-5.4.40]# vim /etc/httpd/httpd.conf  #编辑httpd配置文件整合httpd+php

U~2WL7IY2OV2~GWT4W]4I_M.png

W~BZECTA}_BP2CIRQCOWK3J.png

[root@centos7 ~]# vim /usr/local/lamp/apache2/htdocs/index.php   #创建默认访问页

EHROD{PZ_11Z2N`1_1A@H[F.png

测试

I~GIT6%CXQ]F[1CF9}Z~KI0.png

基于php-fpm安装php

fpm:--enable-fpm 

[root@centos7 ~]# yum -y install gd-devel freetype-devel libxml2-devel libmcrypt-devel  #安装php依赖包
[root@centos7 ~]# tar xf php-5.4.40.tar.bz2  #解压
[root@centos7 ~]# cd php-5.4.40/
[root@centos7 php-5.4.40]# ./configure --prefix=/usr/local/lamp/php5 --with-mysql=/usr/local/lamp/mysql --with-mysqli=/usr/local/lamp/mysql/bin/mysql_config --with-openssl --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 --enable-fpm --with-config-file-path=/etc/php.ini --with-config-file-scan-dir=/etc/php.d/  #配置php参数
[root@centos7 php-5.4.40]# make  #编译
[root@centos7 php-5.4.40]# make install  #安装
[root@centos7 php-5.4.40]# cp php.ini-production /etc/php.ini  #复制配置文件
[root@centos7 php-5.4.40]# cp /usr/local/lamp/php5/php-fpm.conf.default /usr/local/lamp/php5/php-fpm.conf  #生成php-fpm配置文件
[root@centos7 php-5.4.40]# vim /etc/httpd/httpd.conf  #编辑httpd配置文件整合httpd+php

U~2WL7IY2OV2~GWT4W]4I_M.png

W~BZECTA}_BP2CIRQCOWK3J.png

)YSFV7Y8R~Z9$$2UVENP2_B.png

[root@centos7 php-5.4.40]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm   #生成php-fpm服务脚本文件
[root@centos7 php-5.4.40]# chkconfig --add php-fpm   #添加php-fpm开机自启动
[root@centos7 php-5.4.40]# chkconfig --level 2345 php-fpm on   #开机在2345运行级别下开启此服务
[root@centos7 ~]# service php-fpm start   #开启php-fpm服务

EME%SB{KZGEU[%PUORLV(@D.png

测试

I~GIT6%CXQ]F[1CF9}Z~KI0.png

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

(0)
zhai796898zhai796898
上一篇 2016-11-03 21:32
下一篇 2016-11-03 23:08

相关推荐

  • Linux基础 & bash相关

    Q1:Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。 文件管理类命令: cd, ls, touch, cp, mv, rm, cat, tac, more, less, tail, head; 详细介绍以上命令: cd: 在Linux文件系统上,可以使用切换目录命令cd将shell会话切换到另一个目录。 命令格式: ~]#&nbsp…

    Linux干货 2016-11-06
  • 随笔

    GREP正则表达式: 复习: glob文件通配符:     *:任意长度字符:     ?:任意单个字符:     []:括号内的任意单个字符:     [^]:括号内字符除外:  &nbs…

    Linux干货 2016-07-16
  • N25期–第十四周作业

    系统的INPUT和OUTPUT默认策略为DROP; # iptables -P INPUT DROP # iptables -P OUTPUT DROP 1、 限制本地主机的web服务器在周一不允许访问;新请求的速率不能超过100个每秒;web服务器包含了admin字符串的页面不允许访问;web服务器仅允许响应报文离开本机;   #iptables…

    Linux干货 2017-04-10
  • 马哥教育网络19期+第十五周课程练习

    1、总结sed和awk的详细用法;   a).sed命令 sed可以实现grep的大部分功能,而且还可以查找替换 [root@localhost ~]# sed '10'p -n 1.txt [root@localhost ~]# sed &#039…

    Linux干货 2016-08-22
  • 马哥教育-第二周作业

    问题一:文件管理类命令 常规命令:mkdir、rmdir、stat、touch、copy、mv、rm (1).mkdir  创建目录: 注意:路径基名方为命令的作用对象;基名之前的路径必须得存在; -p:自动按需创建父目录; -v:显示创建过程; -m 参数:直接给定所需权限; 例子:问题:创建 /tmp/x ; /tmp/x/y1 ; /tmp/…

    Linux干货 2016-12-11
  • 优云Monitor:开启数据中心主机运维的上帝视角

    常常有这么一句话在激励每一位运维人员,“不以故障多为耻,而以恢复快为荣。”运维人员就是要快速定位问题,分析问题,排除故障,快速恢复来保障生产业务不受中断。然而,现代大型数据中心,运维人员要管理的系统节点比以前繁多,为了掌控数据中心的实时运行情况与定位问题,需要花的时间成本已经长得无法接受。 而优云Monitor给运维人员提供了极好的可视化手段,能够让运维人员…

    系统运维 2017-01-09