实验目标:搭建lnmp并实现wordpress,phpmyadmin功能,并为phpmyadmin添加https服务
实验环境:centos7,使用epel源安装nginx,php,php-fpm,mariadb,pgp-mysql, php-mbstring
修改hosts文件,添加一条记录
[[email protected] php-fpm.d]# vim /etc/hosts172.16.34.2 www.pma.com www.wp.com
对nginx进行配置
切换至nginx配置文件目录,将配置文件中的server内容注释,在http上下文中添加index的默认查看选项
[[email protected] phpMyAdmin]# cd /etc/nginx[[email protected] nginx]# vim nginx.confindex index.php index.html index.htm;
切换至conf.d目录
[[email protected] nginx]# cd conf.d/
创建wp.conf配置文件
[[email protected] conf.d]# vim wp.confserver { listen80; server_namewww.wp.com; root/wp/wordpress; location ~ \.php$ { fastcgi_pass 172.16.34.2:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /wp/wordpress/$fastcgi_script_name; include fastcgi_params; }}
创建phpmyadmin配置文件
[[email protected] conf.d]# vim pma.confserver { listen80; server_namewww.pma.com; root/pma/pma; location ~ \.php$ { fastcgi_pass 172.16.34.2:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /pma/pma/$fastcgi_script_name; include fastcgi_params; }}
配置php-fpm,添加当前主机IP地址
[[email protected] ~]# cd /etc/php-fpm.d/[[email protected] php-fpm.d]# vim www.conflisten = 172.16.34.2:9000listen.allowed_clients = 172.16.34.2
配置mariadb
创建wordpress用的数据库及账号密码
MariaDB [(none)]> create [email protected]‘172.16.%.%‘ identified by ‘wppass‘;Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> create database wpdb;Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> grant all on wpdb.*to [email protected]‘172.16.%.%‘ identified by‘wppass‘;Query OK, 0 rows affected (0.01 sec) MariaDB [(none)]> flush privileges;Query OK, 0 rows affected (0.00 sec)
创建phpmyadmin用账号密码
MariaDB [(none)]> create [email protected]‘172.16.%.%‘ identified by ‘pmapass‘;Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all on *.*to [email protected]‘172.16.%.%‘ identified by‘pmapass‘;Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges;Query OK, 0 rows affected (0.00 sec)
安装wordpress
使用wordpress的压缩包,将复制至服务器,此处使用/wp目录
[[email protected] ~]# mkdir /wp[[email protected] ~]# cd /wp[[email protected] wp]# unzipwordpress-4.5.3-zh_CN.zip[[email protected] wp]# cd wordpress/
修改配置文件中数据库地址
[[email protected] wordpress]# mvwp-config-sample.php wp-config.php[[email protected] wordpress]# vimwp-config.php// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** ///** WordPress数据库的名称*/define(‘DB_NAME‘, ‘wpdb‘); /** MySQL数据库用户名 */define(‘DB_USER‘, ‘wpuser‘); /** MySQL数据库密码 */define(‘DB_PASSWORD‘, ‘wppass‘); /** MySQL主机 */define(‘DB_HOST‘, ‘172.16.34.2‘);
验证登录
配置phpmyadmin
使用phpmyadmin的压缩包,将复制至服务器,此处使用/pma目录
[[email protected] ~]# mkdir /pma[[email protected] ~]# cd /pma[[email protected] pma]# unzipphpMyAdmin-4.4.14.1-all-languages.zip
给解压的文件夹做一个软连接
[[email protected] pma]# ln -sphpMyAdmin-4.4.14.1-all-languages pma
编辑phpmyadmin的配置文件
[[email protected] pma]# mvconfig.sample.inc.php config.inc.php[[email protected] pma]# vim config.inc.php$cfg[‘Servers‘][$i][‘host‘] =‘172.16.34.2‘;
登录验证
时间: 2024-10-12 15:21:58