实现CentOS 7 编译安装基于httpd 模块方式的LAMP

环境准备

两台主机:

一台主机:httpd+php(模块方式)
一台主机:mariadb 服务器

软件版本:

mariadb-10.2.27-linux-x86_64.tar.gz 通用二进制格式
apr-1.7.0.tar.bz2
apr-util-1.6.1.tar.bz2
httpd-2.4.41.tar.gz
php-7.3.10.tar.xz
wordpress-5.2.3-zh_CN.zip

实现步骤

二进制编译安装mariadb

useradd -r -s /sbin/nologin mysql

tar xvf mariadb-10.2.27-linux-x86_64.tar.gz -C /usr/local

cd /usr/local

ls -sv mariadb-10.2.27-linux-x86_64 mysql

cd mysql

chown -R root.root ./*

mkdir /data/mysql -p

chown -R mysql.mysql /data/mysql

mkdir /etc/mysql

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

vim /etc/mysql/my.cnf
[mysqld]
#加下面行
datadir =/data/mysql
skip_name_resolve = ON

#准备PATH变量
vim /etc/profile.d/lamp.sh

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

. /etc/profile.d/lamp.sh

cd /usr/local/mysql;scripts/mysql_install_db  --user=mysql --datadir=/data/mysql

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

chkconfig --add mysqld

service mysqld start

#为wordpress应用准备数据库和用户
mysql
mysql> create database wordpress;
mysql> grant all on wordpress.* to wpuser@'192.168.8.%' identified by "wppass";

编译安装httpd2.4

useradd -r -s /sbin/nologin apache

yum install  gcc pcre-devel   openssl-devel expat-devel

tar xvf apr-1.7.0.tar.bz2  

tar xvf apr-util-1.6.1.tar.bz2

tar xf httpd-2.4.41.tar.gz

mv apr-1.7.0 httpd-2.4.41/srclib/apr

mv apr-util-1.6.1 httpd-2.4.41/srclib/apr-uti

cd httpd-2.4.41/
./configure --prefix=/apps/httpd24 \
 --enable-so \
 --enable-ssl \
 --enable-cgi \
 --enable-rewrite \
 --with-zlib \
 --with-pcre \
 --enable-modules=most \
 --enable-mpms-shared=all \
 --with-mpm=prefork \
 --with-included-apr
 
make -j 4 && make install

#配置PATH变量
vim /etc/profile.d/lamp.sh
PATH=/usr/local/mysql/bin/:/app/httpd24/bin:$PATH
. /etc/profile.d/lamp.sh
vim /app/httpd24/conf/httpd

#修改下面两行
user apache
group apache

apachectl start

编译安装httpd模块方式php7.3

#安装相关包,依赖EPEL源
yum install gcc libxml2-devel bzip2-devel libmcrypt-devel

#编译安装php
tar xvf php-7.3.10.tar.xz

cd php-7.3.10/
./configure \
--prefix=/apps/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=/app/httpd24/bin/apxs \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d \
--enable-maintainer-zts \  
--disable-fileinfo

make -j 4 && make install

#为php提供配置文件
cp php.ini-production /etc/php.ini

编译安装apache配置文件支持php

vim /etc/httpd24/conf/httpd.conf
#下面加二行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

定位至 DirectoryIndex index.html, 修改为
DirectoryIndex index.php index.html

apachectl restart

部署WordPress

unzip wordpress-5.2.3-zh_CN.zip

mv wordpress /var/www/html

setfacl –R –m u:apache:rwx /var/www/html/wordpress/
#或者chown –R apache.apache /var/www/html/wordpress

#打开http://LAMP服务器IP/wordpress进行页面安装
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值