Small c to learn Linux (29)--LAMP detailed configuration

LAMP detailed configuration

Take building a wordpress blog website as an example

software preparation

  1. WordPress installation package download address: https://cn.wordpress.org/releases/
  2. PhpMyAdmin installation package download address: https://www.phpmyadmin.net/

PhpMyAdmin is a database GUI management.

Install

1) Keep the environment clean

In order to ensure that the environment for installing LAMP is clean, first check whether the relevant packages have been installed on the machine.

rpm -q httpd mysql-server mysql php php-mysql

2) Install LAMP

yum -y install httpd mysql-server mysql php php-server

3) Configure wordpress

1.将安装好的wordpress解压  
unzip wordpress.zip
2.将wordpress下的全部文件复制到http默认站点路径下
cp -r wordpress/* /var/www/html/
3.进入html
cd /var/www/html
4.准备wordpress配置文件
cp wp-config-sample.php wp-config.php
5. 编辑wordpress配置文件,填写需要连接的数据库数据
/** WordPress 数据库的名称 */
define('DB_NAME', 'wpdb');

/** MySQL 数据库用户名 */
define('DB_USER', 'wpuser');

/** MySQL 数据库密码 */
define('DB_PASSWORD', 'wppass');

/** MySQL 主机 */
define('DB_HOST', 'localhost');

4) Configure PhpMyAdmin

1.将安装好的PhpMyAdmin解压
unzip wordpress.zip
2.将PhpMyAdmin下的全部文件复制到新的站点路径下
mkdir /var/www/phpmyadmin

cp -r wordpress/* /var/www/phpmyadmin
3.进入phpmyadmin
cd /var/www/phpmyadmin
4.准备phpmyadmin配置文件
cp config.sample.inc.php config.inc.php
5. 编辑config配置文件,加密数据库
#生成加密密码
openssl rand -hex 8

#将生成的密码填写进配置文件
vim config.inc.php

$cfg['blowfish_secret'] = '00aa783bbff27c1e';  

5) Configure mysql

1. 创建wordpress数据库:wpdb  
CREATE DATABASE wpdb;
2. 授权给wordpress用户,数据库会自动创建此用户
#和wordpress的配置文件数据库的数据内容保持一致
GRANT ALL PRIVILEGES ON *.* TO 'wpuser'@'localhost' IDENTIFIED BY 'wppass'
3. 开启mysql服务
service mysqld start
4. 查看3306端口是否被监听
ss -tnl

6) Configure the virtual machine

1. 准备两个域名
  • www.a.com
  • www.b.com

a is used to access wordpress
b is used to access PhpMyAdmin

2. 编辑httpd.conf
vim /etc/httpd/conf/httpd.conf

<VirtualHost *:80>
   ServerName www.a.com
   DocumentRoot "/var/www/html"
 </VirtualHost>
<VirtualHost *:80>
   ServerName www.b.com
   DocumentRoot "/var/www/phpmyadmin"
</VirtualHost>

7) Domain name resolution

For details, refer to DNS service configuration

Check if port 53 is listening

ss -tnl

8) Access wordpress

#开启httpd服务
service httpd start

#查看80端口是否监听
ss -tnl

#浏览器分别访问
www.a.com
www.b.com

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325982419&siteId=291194637