LAMP 编译安装基于2.4

安装前准备

说明:

    操作系统:CentOS 6.7 64

    MySQL数据库版本:mariadb-5.5.48-linux-x86_64.tar.gz

    Apache 版本:httpd-2.4.12.tar.bz2

    PHP 版本:php-5.6.8.tar.bz2

    httpd服务器ip:192.168.1.5

    1.  配置好IPDNS 、网关,确保使用远程连接工具能够连接服务器

    2.     配置防火墙,iptables –F 清理防火墙规则或者关闭iptables

    3.     关闭SELINUX, setenforce 0  #立即生效(实际是宽容模式)

    4.  源码包编译安装位置:/usr/local/软件名字

    5.     安装编译需要的开发组件和依赖包

        yum -y groupinstall "Development Tools" "Server Platform Development"

        yum -y install pcre-devel openssl openssl-devel

 

二、编译安装apache

 1. httpd-2.4.12需要较新版本的aprapr-util,因此需要事先对其进行升级。升级方式有两种,一种是通过源代码编译安装,一种是直接升级rpm包。

  apr-1.5.2.tar.bz2

  apr-util-1.5.4.tar.gz

    (1) 编译安装apr

    tar jxvf apr-1.5.1.tar.bz2

    cd apr-1.5.1

     ./configure –prefix=/usr/local/apr

    make && make install

     

    (2) 编译安装apr-util

    cd

    tar zxvf apr-util-1.5.4.tar.gz

    cd apr-util-1.5.4

     ./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr/

    make && make install

     

 2.编译安装httpd-2.4.12

cd

tar jxvf httpd-2.4.12.tar.bz2

  cd httpd-2.4.12

  ./configure –prefix=/usr/local/apache –sysconfdir=/etc/httpd24 –enable-so –enable-ssl –enable-cgi –enable-rewrite –with-zlib –with-pcre –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util –enable-modules=most –enable-mpms-shared=all –with-mpm=event

make && make install

参数的各项含义:

–prefix=/usr/local/apache          #安装位置

–sysconfdir=/etc/httpd24           #配置文件位置

–enable-so                         #支持DSO动态装载模块

–enable-ssl                        #支持SSL/TLS,可实现https协议访问,需要安装openssl-devel

–enable-cgi                        #支持CGI脚本

–enable-rewrite                    #支持URL重写

–with-zlib                         #使用指定的zlib压缩库,不指定路径会自动寻找

–with-pcre                         #使用指定的pcre库,增强的正则表达式分析工具;不指定路径会自动寻找 需已安装pcre-devel

–with-apr=/usr/local/apr           #指定依赖apr程序安装位置

–with-apr-util=/usr/local/apr-util #指定依赖apr-util程序安装位置

–enable-modules=most               #支持动态启用模块;all:所有,most:常用

–enable-mpms-shared=all            #编译并共享模块

–with-mpm=event                    #默认启用模块{prefork|worker|event}

 

 3. 配置man手册文件路径

         vi /etc/man.config            #系统通过/etc/man.config中的MANPATH来指定查找路径

         MANPATH /usr/local/apache/man

 4. 输出头文件至系统

Linux系统的库文件都存放在/usr/include中,程序使用时会到这个目录中调用,因此需要将我们安装后的库文件跟系统库文件做以关联。我们使用软连接的方式,将httpd的头文件目录整个连接到/usr/include目录下。

ln -sv /usr/local/apache/include/ /usr/include/httpd

 

 5. 配置apache 启动服务

    vi /etc/profile  #添加apache服务系统环境变量

    在最后添加下面这一行

export PATH=$PATH:/usr/local/apache/bin

cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd      #apache加入到系统启动

vi /etc/init.d/httpd24   #编辑文件

#!/bin/sh下面添加以下两行

#chkconfig:2345 10 90
#description:Activates/Deactivates Apache Web Server

 

加入服务列表:

chkconfig –add httpd24

chkconfig httpd on

service httpd24 start

 

访问测试

    blob.png

安装mariadb-5.5.48

1.  新建用户以安全方式运行进程:

    groupadd -r -g 306 mysql     #添加mysql组
    useradd -r -g 306 -u 306 mysql    #创建mysql用户并加入到mysql组
    mkdir -pv /mydata/data                # #创建MySQL数据库存放目录
    chown -R mysql.mysql /mydata/data  #设置MySQL数据库目录权限

 

2.  安装并初始化mariadb-5.5.48-linux-x86_64.tar.gz

tar xf mariadb-5.5.48-linux-x86_64.tar.gz -C /usr/local/

cd /usr/local/
ln -sv mariadb-5.5.48-linux-x86_64 mysql         #创建软连接到mysql目录,方便后面的配置
cd /usr/local/mysql
chown -R root:mysql ./*
scripts/mysql_install_db --datadir=/mydata/data --user=mysql     #生成mysql系统数据库

 

3. mysql提供主配置文件:

 mkdir /etc/mysql

cp support-files/my-large.cnf /etc/mysql/my.cnf

 vi /etc/mysql/my.cnf

datadir = /mydata/data                 #数据存放位置

innodb_file_per_table = on

skip_name_resolve = on                 #跳过名称反解

4.  mysql提供sysv服务脚本:

cp supper-files/mysql.server /etc/rc.d/init.d/mysqld

添加至服务列表:

chkconfig –add mysqld

vi /etc/profile   #mysql服务加入系统环境变量:在最后添加下面这一行

export PATH=$PATH:/usr/local/mysql/bin

source  /etc/profile #使配置立即生效

service mysqld start

blob.png

5.       数据库安全初始化

mysql_secure_installation

blob.png

 

 

编译安装php-5.6.8

 1. 解决依赖关系:

yum -y install bzip2-devel libmcrypt-devel libxml2-devel          #注意有些包用epel源才有

 2. 编译安装php-5.6.8

tar xf php-5.6.8.tar.bz2

cd php-5.6.8

./configure –prefix=/usr/local/php –with-mysql=/usr/local/mysql –with-openssl –with-mysqli=/usr/local/mysql/bin/mysql_config –enable-mbstring –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml  –enable-sockets –with-apxs2=/usr/local/apache/bin/apxs –with-mcrypt  –with-config-file-path=/etc –with-config-file-scan-dir=/etc/php.d –with-bz2  –enable-maintainer-zts

make && make install      #编译安装

php提供配置文件:

cp php.ini-production /etc/php.ini

 3. 编辑apache配置文件httpd.conf,以apache支持php

cd /etc/httpd24

cp httpd.conf{,.bak}     #配置文件做个备份

vi /etc/httpd24/httpd.conf

添加如下二行

  AddType application/x-httpd-php  .php

  AddType application/x-httpd-php-source  .phps

定位至DirectoryIndex index.html

修改为:

  DirectoryIndex  index.php  index.html

blob.png

blob.png

 

而后重新启动httpd,或让其重新载入配置文件即可测试php是否已经可以正常使用。

 

 4. 创建一个测试页面,访问测试是否成功

cd /usr/loaca/apache/htdocs

mv index.html index.php

vi index.php
<?php
        $link = mysql_connect('127.0.0.1','root','liangkai');
        if ($link)
            echo  "Success...";
        else
            echo  "Failure...";
 
        mysql_close();
        phpinfo();
?>

blob.png

部署phpMyAdmin来做测试使用

tar xf phpMyAdmin-4.5.5.1-all-languages.tar.bz2

mv phpMyAdmin-4.5.5.1-all-languages /usr/local/apache/htdocs/pma

cd /usr/local/apache/htdocs/pma

cp config.sample.inc.php config.inc.php

tr -d 'a-zA-Z0-9' < /dev/urandom | head -20 | md5sum           #生成一段随机数

vi config.inc.php

blob.png

blob.png

ab 做下压力测试

ab -c 20 -n 100 http://192.168.1.5/pma/index.php

blob.png

 

安装xcache,为php加速:

 1. 安装

tar xf xcache-3.2.0.tar.gz

cd xcache-3.2.0

/usr/local/php/bin/phpize

./configure –enable-xcache –with-php-config=/usr/local/php/bin/php-config

make && make install

 

安装结束时,会出现类似如下行:

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20131226/

 2. 编辑php.ini,整合php和xcache:

 

首先将xcache提供的样例配置导入php.ini

 mkdir /etc/php.d

cp xcache.ini /etc/php.d

 

说明:xcache.ini文件在xcache的源码目录中。

 

接下来编辑/etc/php.d/xcache.ini,找extension开头的行,修改为如下行:

extension = /usr/local/php/lib/php/extensions/no-debug-zts-20131226/xcache.so

 

service httpd24 restart

 

ab 做下压力测试,看看效果如何

blob.png

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

(0)
上一篇 2016-11-21 10:13
下一篇 2016-11-21 13:33

相关推荐

  • 系统自动化安装和SELinux

    一、知识整理 1、anaconda系统安装程序:默认图形启动; 使用光盘启动,在选择模式界面tab键在后面增加text或按下ESC键,输入lnux text进入字符界面安装。 2、创建kickstart文件: 直接手动编辑:依据模板修改,/root目录下的anaconda.cfg 使用创建工具创建:system-config-kickstart,图形化工具:…

    Linux干货 2016-09-26
  • week4

    一,复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其他用户均没 有任何访问权限; cp -r /etc/skel/ /home/tuser1 chmod -R go= /home/tuser1/ 二,编辑/etc/group文件,添加组hado…

    Linux干货 2016-11-18
  • 手动编译内核+busybox+dropbear+nginx

    我们需要先在宿主机上添加一个磁盘,然后,把这个磁盘做好分区和文件系统: fdisk /dev/sdb 创建第一个分区: n p 1 +512M 创建第二个分区: n p 2 +10G 保存退出: w 为分区提供文件系统: kpartx /dev/sdb 为分区提供文件系统: mke2fs -t ext4 /dev/sd…

    Linux干货 2015-09-24
  • 第四周小结

    这周我们主要学习了写脚本的简单语法,写了一些简单的脚本,下面就由我来简单介绍一下: 第一步使用文本编辑来创建脚本: 创建好后在里面写想要运行的脚本即可,然后按Esc—wq退出保存即可。也可以按q不保存退出;q!不保存强制退出;wq!保存强制退出。 第二步运行脚本,给予执行权限,在命令行上指定脚本的相对路径和绝对路径 对了,当在脚本里输入内容时,要Ese&#8…

    2017-08-06
  • linux中文本处理工具cat 、less、more、head、tail、cut等使用

    文本内容查看工具:cat和less  cat 使用:查看文件内容          cat  选项      文件        …

    Linux干货 2016-08-08
  • 马哥教育20期面授2班第一周课程练习1

    计算机基础   1,计算机系统           硬件系统            主机部分:中央处理器CPU(运算器ALU、控制器CU);  &nb…

    Linux干货 2016-07-29