CentOS 7 yum安装lamp,三者位于不同服务器,并为之安装WordPress及phpmyadmin
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS 7 yum安装lamp,三者位于不同服务器,并为之安装WordPress及phpmyadmin相关的知识,希望对你有一定的参考价值。
系统平台:CentOS 7 1611
phpMyAdmin下载地址(CentOS 7 建议不要安装最新版,否则需要编译最新的php-fpm)
分别在三台主机上安装httpd(192.168.1.200),php-fpm(192.168.1.201),mariadb(192.168.1.202),
并提供WordPress、phpMyAdmin应用
1、安装并配置httpd服务器
1.1 安装httpd服务
[[email protected] ~]# yum install -y httpd
1.2 编辑httpd配置文件并创建虚拟主机
[[email protected] ~]# mkdir -pv /www/{wp.com,pma.com}/htdocs [[email protected] ~]# vim /etc/httpd/conf/httpd.conf ServerName localhost:80 #DocumentRoot "/www/wp.com/htdcos" <VirtualHost 192.168.1.200:80> ServerName www.wp.com DocumentRoot "/www/wp.com/htdocs/" ProxyRequests off ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.1.201:9000/www/wp.com/htdocs/$1 <Directory "/www/wp.com/htdocs/"> Options None AllowOverride None Require all granted </Directory> </VirtualHost> <VirtualHost 192.168.1.200:80> ServerName www.pma.com DocumentRoot "/www/pma.com/htdocs/" ProxyRequests off ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.1.201:9000/www/pma.com/htdocs/$1 <Directory "/www/pma.com/htdocs/"> Options FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost>
2、安装并配置php-fpm服务
2.1 安装php-fpm、php-mbstring、php-mysql服务
[[email protected] ~]# yum -y install php-fpm php-mbstring.x86_64 php-mysql
2.2 修改php-fpm配置文件
[[email protected] ~]# vim /etc/php-fpm.d/www.conf listen = 0.0.0.0:9000 #表示监听所有端口 ;listen.allowed_clients = 127.0.0.1 #注释掉后,默认允许所有主机访问
2.3 创建/wordpress和phpmyadmin的网页文件目录,并将WordPress和phpmyadmin文件放置在该文件夹中
[[email protected] ~]# mkdir -pv /www/{wp.com,pma.com}/htdocs
3、安装配置mariadb服务
3.1 安装mariadb服务(CentOS 7自带有mariadb服务,启动即可)
[[email protected] ~]# yum -y install mariadb-server
[[email protected] ~]# systemctl start mariadb.service
3.2 创建数据库并添加用户、赋予权限
MariaDB [(none)]> create database wp; MariaDB [(none)]> CREATE UESR ‘wp‘@‘%.%.%.%‘ IDENTIFIED BY ‘wppasswd‘; MariaDB [(none)]> GRANT ALL ON *.* TO [email protected]‘192.168.1.%‘ IDENTIFIED BY ‘wppasswd‘;
4、配置WordPress、phpMyAdmin
4.1 解压下载的文件并为phpmyadmin创建链接
[[email protected] wordpress]# unzip wordpress-4.7.4-zh_CN.zip [[email protected] wordpress]# unzip phpMyAdmin-4.0.10.20-all-languages.zip [[email protected] html]# ln -sv phpMyAdmin-4.0.10.20-all-languages pma
4.2 修改WordPress配置文件
[[email protected] html]# cd wordpress/ [[email protected] wordpress]# cp wp-config-sample.php wp-config.php [[email protected] wordpress]# vim wp-config.php define(‘DB_NAME‘, ‘wp‘); #数据库名称 define(‘DB_USER‘, ‘wp‘); #用于连接数据库的用户名 define(‘DB_PASSWORD‘, ‘wppasswd‘); #用于连接数据库的密码 define(‘DB_HOST‘, ‘192.168.1.202‘); #数据库的路径
4.3 修改phpMyAdmin的配置文件
[[email protected] wordpress]# cd /var/www/html/pma/ [[email protected] pma]# cp config.sample.inc.php config.php [[email protected] pma]# openssl rand -base64 15 #生成配置文件中所需的随机数 A42B1Noto1YiqQMC3DV7 [[email protected] pma]# vim config.php $cfg[‘blowfish_secret‘] = ‘A42B1Noto1YiqQMC3DV7‘; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ $cfg[‘Servers‘][$i][‘host‘] = ‘192.168.1.202‘;
4.4 复制WordPress和phpMyAdmin到httpd服务器上对应的路径中
[[email protected] pma]# scp -P 22 /var/www/html/pma/* [email protected]:/var/www/html/pma [[email protected] pma]# scp -P 22 /var/www/html/wordpress/* [email protected]:/var/www/html/wordpress
本文出自 “7358072” 博客,请务必保留此出处http://7368072.blog.51cto.com/7358072/1925388
以上是关于CentOS 7 yum安装lamp,三者位于不同服务器,并为之安装WordPress及phpmyadmin的主要内容,如果未能解决你的问题,请参考以下文章
CentOS 7.4 yum方式安装LAMP环境,并部署WordPress,使用XCache优化性能