博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CentOS7编译安装LAMP(CentOS7、httpd-2.4、php-7.1、mariadb-10.2、memcached-3.0.4)
阅读量:7101 次
发布时间:2019-06-28

本文共 5013 字,大约阅读时间需要 16 分钟。

hot3.png

安装环境说明:

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

  1. Linux : CentOS Linux release 7.4.1708 (Core)(最小化安装)
  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,防火墙

禁用SELinux# vim /etc/selinux/config    SELINUX=disabled# setenforce 0配置防火墙放行http和https# firewall-cmd --permanent --zone=public --add-service=http# firewall-cmd --permanent --zone=public --add-service=https# firewall-cmd --reload

2.配置aliyun Yum源

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

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

# yum -y groupinstall "development tools" # yum -y install pcre pcre-devel-devel openss-devel expat-devel

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

最新版的httpd2.4需要依赖apr-1.4以上版本和apr-1.5以上版本

# tar vxf apr-1.6.3.tar.gz# cd apr-1.6.3# ./configure --prefix=/usr/local/apr# make# make install# tar vxf apr-util-1.6.1.tar.gz# cd apr-util-1.6.1# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr# make# make install

5.编译安装httpd2.4.33

# tar vxf httpd-2.4.33.tar.bz2编译httpd之前把上一步解压出来的apr和apr-util文件复制到httpd-2.4.33/srclib/文件夹下,再进行httpd编译# mv apr-1.6.3 httpd-2.4.33/srclib/apr# mv apr-util-1.6.1 httpd-2.4.33/srclib/apr-util# cd httpd-2.4.33# ./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# make# make install配置以支持chkconfig控制# cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd# vim /etc/rc.d/init.d/httpd    在第二行加入如下三行(前面的#号不能省略)    # Comments to support chkconfig on RedHat Linux    # chkconfig: 35 85 15    # description: Apache is a World Wide Web server.# chkconfig --add httpd# chkconfig httpd on# systemctl restart httpd# vim /etc/profile.d/httpd.sh    export PATH=$PATH:/usr/local/apache/bin# source /etc/profile.d/httpd.sh
打开 http://192.168.10.10/ 可以看到httpd已经工作

6.编译安装Mariadb10.2.14

解压安装并指定解压路径/usr/local,创建软连接 # tar xvf mariadb-10.2.14-linux-x86_64.tar.gz -C /usr/local# cd /usr/local# ln -s mariadb-10.2.14-linux-x86_64/ mysql创建mysql用户,并指定家目录。# mkdir /mysql# useradd -r -m -s /sbin/nologin -d /mysql/data mysql生成mysql数据库# /usr/local/mysql/scripts/mysql_install_db --datadir=/mysql/data --basedir=/usr/local/mysql --user=mysql配置mysql的配置文件# cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf# vim /etc/my.cnf     ## 在[mysqld]节点下追加如下三行    [mysqld]    datadir = /mysql/data    innodb_file_per_table = ON    skip_name_resolve = ON配置以支持chkconfig控制# cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld# chkconfig --add mysqld# chkconfig mysqld on# systemctl restart mysqld执行安全初始化数据库脚本# /usr/local/mysql/bin/mysql_secure_installation# vim /etc/profile.d/mysqld.sh    export PATH=$PATH:/usr/local/mysql/bin:/usr/local/apache/bin# source /etc/profile.d/mysqld.sh

7.编译安装PHP7.1.17

解决依赖# yum install -y epel-release# yum -y install php-mcrypt  libmcrypt  libmcrypt-devel libxml2-devel编译安装# tar xvf php-7.1.17.tar.bz2# cd php-7.1.17# ./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注意: php-7.0以上版本使用 –enable-mysqlnd –with-mysqli=mysqlnd ,原–with-mysql不再支持# make# make install提供php配置文件# cp php.ini-production /etc/php.ini编辑apache配置文件httpd.conf,以使apache支持php# vim /usr/local/apache/conf/httpd.conf    添加如下两行    AddType application/x-httpd-php .php    AddType application/x-httpd-php-source .phps    找到如下行并追加index.php 结果如下    DirectoryIndex index.html index.php重启httpd服务以使配置生效# systemctl restart httpd测试httpd、mariadb、php是否能够协同工作# rm -rf /usr/local/apache/htdocs/index.html# vim /usr/local/apache/htdocs/index.php        
close(); ?>
打开http://192.168.10.10/ 能看到"连接数据库成功!"即可,否则请检查错误。

8.编译安装php-memcached扩展

最新版Xcache3.2最高只支持到PHP 5.6,所以PHP7不在支持列表里,我以这里我们使用php-memcached来提供缓存功能

编译安装libmemcached# yum -y install cyrus-sasl-devel# wget  https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz# cd libmemcached-1.0.18# ./configure --prefix=/usr/local/libmemcached --with-memcached --enable-sasl# make# make install编译安装php-memcached# tar xvf memcached-3.0.4.tgz# cd memcached-3.0.4# /usr/local/php/bin/phpize        Configuring for:        PHP Api Version:         20160303        Zend Module Api No:      20160303        Zend Extension Api No:   320160303# ./configure --with-php-config=/usr/local/php/bin/php-config  --with-libmemcached-dir=/usr/local/libmemcached --enable-memcached# make # make install# echo "extension=memcached.so" >> /etc/php.ini# systemctl restart httpd

附录:软件下载地址

  1. :
  2. :
  3. :
  4. :
  5. :
  6. :
  7. :
  8. :

转载于:https://my.oschina.net/kangvcar/blog/1805852

你可能感兴趣的文章
the art of seo(chapter eight)
查看>>
接口、继承和泛型方法的使用
查看>>
C#入门篇6-10:字符串操作 DateTime操作
查看>>
Shared_ptr 相互引用问题
查看>>
Nginx 入门指南
查看>>
冒泡排序与选择排序
查看>>
[多人合作的项目] - 记项目开发的多人化
查看>>
CSS3教程:pointer-events属性值详解
查看>>
[Android Pro] 告别编译运行 ---- Android Studio 2.0 Preview发布Instant Run功能
查看>>
[Web 前端] webstorm 快速搭建react项目
查看>>
阿里巴巴实习 面试题
查看>>
洛谷 P1443 马的遍历
查看>>
Asp.net MVC3 中,动态添加filter
查看>>
人民币主动贬值 你的理财方式主动调整了吗?加上外币兑换的费用,也远不如投资人民币理财产品带来的收益高...
查看>>
m6-第11周作业
查看>>
JMeter 功能挖掘之 WEB 文件导出
查看>>
Java中线程池的介绍
查看>>
js之滚动置顶效果
查看>>
algorithms第四版学习进程(一)背包,栈,队列
查看>>
HTML(五)选择器--伪类选择器
查看>>