CentOS6编译安装LAMP(CentOS6、httpd

安装环境说明:

(软件下载地址在文末附录)

  1. Linux : CentOS release 6.9 (最小化安装)
  2. Apache : httpd-2.4.33.tar.bz2
  3. MariaDB : mariadb-10.2.14-linux-x86_64.tar.gz
  4. PHP : php-7.1.17.tar.bz2
  5. libmemcached : libmemcached-1.0.18.tar.gz
  6. php-memcached : memcached-3.0.4.tgz
  7. Apr : apr-1.6.3.tar.gz
  8. Apr-util : apr-util-1.6.1.tar.gz

安装的顺序:

Apache --> MariaDB --> PHP

1.关闭SELinux,防火墙

1# vim /etc/selinux/config 2 SELINUX=disabled 3# setenforce 0 4# service iptables stop 5# chkconfig iptables off

2.配置aliyun Yum源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

3.安装开发工具组和依赖包

1# yum -y groupinstall "development tools" 2# yum -y install pcre pcre-devel openssl-devel expat-devel

4.编译安装apr-1.4和apr-1.5

1最新版的httpd2.4需要依赖apr-1.4以上版本和apr-1.5以上版本 2# tar vxf apr-1.6.3.tar.gz 3# cd apr-1.6.3 4# ./configure --prefix=/usr/local/apr 5# make 6# make install 7 8# tar vxf apr-util-1.6.1.tar.gz 9# cd apr-util-1.6.1 10# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr 11# make 12# make install

5.编译安装httpd2.4.33

1# tar vxf httpd-2.4.33.tar.bz2 2编译httpd之前把上一步解压出来的apr和apr-util文件复制到httpd-2.4.33/srclib/文件夹下,再进行httpd编译 3# mv apr-1.6.3 httpd-2.4.33/srclib/apr 4# mv apr-util-1.6.1 httpd-2.4.33/srclib/apr-util 5# cd httpd-2.4.33 6# ./configure --prefix=/usr/local/apache --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork 7# make 8# make install 9 10配置以支持chkconfig控制 11# cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd 12# vim /etc/rc.d/init.d/httpd 13 在第二行加入如下三行(前面的#号不能省略) 14 # Comments to support chkconfig on RedHat Linux 15 # chkconfig: 35 85 15 16 # description: Apache is a World Wide Web server. 17# chkconfig --add httpd 18# chkconfig httpd on 19# service httpd restart 20# vim /etc/profile.d/httpd.sh 21 export PATH=$PATH:/usr/local/apache/bin 22# source /etc/profile.d/httpd.sh 23 24 25打开http://192.168.10.10/ 可以看到httpd已经工作

6.编译安装Mariadb10.2.14

1# yum install libaio 2解压安装并指定解压路径/usr/local,创建软连接 3# tar xvf mariadb-10.2.14-linux-x86_64.tar.gz -C /usr/local 4# cd /usr/local 5# ln -s mariadb-10.2.14-linux-x86_64/ mysql 6创建mysql用户,并指定家目录。 7# mkdir /mysql 8# useradd -r -m -s /sbin/nologin -d /mysql/data mysql 9生成mysql数据库 10# /usr/local/mysql/scripts/mysql_install_db --datadir=/mysql/data --basedir=/usr/local/mysql --user=mysql 11 12配置mysql的配置文件 13# cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf 14# vim /etc/my.cnf ## 在[mysqld]节点下追加如下三行 15 [mysqld] 16 datadir = /mysql/data 17 innodb_file_per_table = ON 18 skip_name_resolve = ON 19 20配置以支持chkconfig控制 21# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld 22# chkconfig --add mysqld 23# chkconfig mysqld on 24# service mysqld restart 25执行安全初始化数据库脚本 26# /usr/local/mysql/bin/mysql_secure_installation 27 28# vim /etc/profile.d/mysqld.sh 29 export PATH=$PATH:/usr/local/mysql/bin:/usr/local/apache/bin 30# source /etc/profile.d/mysqld.sh

7.编译安装PHP7.1.17

1解决依赖 2# yum install -y epel-release 3# yum -y install php-mcrypt libmcrypt libmcrypt-devel libxml2-devel 4 5编译安装 6# tar xvf php-7.1.17.tar.bz2 7# cd php-7.1.17 8# ./configure --prefix=/usr/local/php --enable-mysqlnd --with-mysqli=mysqlnd --with-openssl --with-pdo-mysql=mysqlnd --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 --enable-maintainer-zts --disable-fileinfo 9注意: php-7.0以上版本使用 –enable-mysqlnd –with-mysqli=mysqlnd ,原–with-mysql不再支持 10# make 11# make install 12 13提供php配置文件 14# cp php.ini-production /etc/php.ini 15 16编辑apache配置文件httpd.conf,以使apache支持php 17# vim /usr/local/apache/conf/httpd.conf 18 添加如下两行 19 AddType application/x-httpd-php .php 20 AddType application/x-httpd-php-source .phps 21 找到如下行并追加index.php 结果如下 22 DirectoryIndex index.html index.php 23 重启httpd服务以使配置生效 24# service httpd restart 25 26测试httpd、mariadb、php是否能够协同工作 27# rm -rf /usr/local/apache/htdocs/index.html 28# vim /usr/local/apache/htdocs/index.php 29 <?php 30 $mysqli=new mysqli("localhost","root","123456"); 31 if(mysqli_connect_errno()){ 32 echo "连接数据库失败!"; 33 $mysqli=null; 34 exit; 35 } 36 echo "连接数据库成功!"; 37 $mysqli->close(); 38 ?> 39 40 41打开http://192.168.10.10/ 能看到"连接数据库成功!"即可,否则请检查错误。

8.编译安装php-memcached扩展

1最新版Xcache3.2最高只支持到PHP 5.6,所以PHP7不在支持列表里,我以这里我们使用memcached来提供缓存功能 2这个扩展需要 libmemcached 客户端库(版本大于等于 1.0.0)。链接memcached服务器时使用SASL认证,需要libmemcached 必须开启SASL选项。 3官方教程http://php.net/manual/zh/memcached.installation.php 4 5编译安装libmemcached 6# yum -y install cyrus-sasl-devel 7# wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz 8# tar vxf libmemcached-1.0.18.tar.gz 9# cd libmemcached-1.0.18 10# ./configure --prefix=/usr/local/libmemcached --with-memcached --enable-sasl 11# make 12# make install 13 14编译安装php-memcached 15# tar xvf memcached-3.0.4.tgz 16# cd memcached-3.0.4 17# /usr/local/php/bin/phpize 18 Configuring for: 19 PHP Api Version: 20160303 20 Zend Module Api No: 20160303 21 Zend Extension Api No: 320160303 22# ./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --enable-memcached 23# make 24# make install 25# echo "extension=memcached.so" >> /etc/php.ini 26# service httpd restart

附录:软件下载地址

  1. CentOS 6.9 : http://mirrors.sohu.com/centos/6/isos/x86_64/CentOS-6.9-x86_64-LiveDVD.iso
  2. httpd-2.4.33.tar.bz2 : http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.33.tar.bz2
  3. mariadb-10.2.14-linux-x86_64.tar.gz : https://downloads.mariadb.org/interstitial/mariadb-10.2.14/bintar-linux-x86_64/mariadb-10.2.14-linux-x86_64.tar.gz
  4. php-7.1.17.tar.bz2 : http://cn2.php.net/get/php-7.1.17.tar.bz2/from/this/mirror
  5. libmemcached-1.0.18.tar.gz : https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
  6. memcached-3.0.4.tgz : http://pecl.php.net/get/memcached-3.0.4.tgz
  7. apr-1.6.3.tar.gz : http://mirrors.shu.edu.cn/apache//apr/apr-1.6.3.tar.gz
  8. apr-util-1.6.1.tar.gz : http://mirrors.shu.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )