Linux 集群架构之LAMP综合演练
实现CentOS 7 编译安装基于httpd 模块方式的LAMP
1.2环境准备
一台主机:httpd+php(模块方式) 192.168.146.130
一台主机:mariadb 服务器 192.168.146.129
1.3软件版本准备
apr-1.7.0.tar.bz2
apr-util-1.6.1.tar.bz2
httpd-2.4.39.tar.bz2
php-7.3.10.tar
Discuz_X3.3_SC_UTF8.zip
wordpress-5.2.2.tar.gz
mariadb-10.2.25-linux-x86_64.tar.gz
2.实验步骤
1)二进制安装mariadb 数据库
getent passwdmysql; useradd -r -s /sbin/nologin mysql -d /data/mysql
chown mysql.mysql /data/mysql/
tar xvf mariadb-10.2.27-linux-x86_64.tar.gz -C /usr/local cd /usr/local ln -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
chkconfig --add list
service mysqld start
#为wordpress应用准备数据库和用户 mysql
mysql>create database wordpress;
mysql>create database discuz;
mysql>grant all on wordpress.* to wordpress@'192.168.146.%' identified by '111111';
mysql>grant all on discuz.* to discuz@'192.168.146.%' identified by '111111';
2)编译安装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 6.1.3.3 编译安装httpd模块方式 php-7.3 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
2)修改http配置文件让其支持访问php,并配置www.x.com域名实现首页访问,admin.x.com域名实现wordpress的后台访问。
1.修改用户名 User apache Group apache 2.启用模块 LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so 3.修改DirectoryIndex DirectoryIndex index.php index.html 4.添加4行并配置域名 <virtualhost *:80> servername www.x.com documentroot /data/wordpress <directory /data/wordpress> require all granted </directory> ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/wordpress/$1 </virtualhost> <virtualhost *:80> servername admin.x.com documentroot /data/discuz <directory /data/discuz> require all granted </directory> ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/discuz/$1 </virtualhost> 5.准备网站存放路径并授权 mkdir /data/{wordpress,discuz} setfacl -Rm u:apache:rwx /data/{wordpress,discuz}
3)实现编译安装php
1) yum install libxml2-devel bzip2-devel libmcrypt-devel 2)tar xvf php-7.3.7.tar.xz cd php-7.3.7/ ./configure --prefix=/app/php --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets --enable-fpm --enable-maintainer-zts --disable-fileinfo make && make install cp php.ini-production /etc/php.ini cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm cd /app/php/etc cp php-fpm.conf.default php-fpm.conf cd php-fpm.d/ cp www.conf.default www.conf vim www.conf user = apache group = apache service php-fpm start 4 /etc/hosts blog.magedu.com forum.magedu.com
4)准备php开源包discuz 和wordpress
1.tar -xvf wordpress-5.2.2.tar.gz -C /data/wordpress 2.unzip Discuz_X3.3_SC_UTF8.zip 3.[root@chujiapeng data]# mv upload/* discuz/
5)安装并测试
2.搭建discus网站
1. 修改winhosts文件后安装
posted on 2021-05-04 11:07 jiapengchu 阅读(80) 评论(0) 编辑 收藏 举报