实战案例1
目标
实现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";
编译安装httpd-2.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模块方式 php-7.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进行页面安装
本文链接:http://www.yunweipai.com/36111.html
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/52451.html