The Ops Community ⚙️

Cover image for AMI 2 build WordPress based on LNMP
Feng Lei
Feng Lei

Posted on

AMI 2 build WordPress based on LNMP

The LNMP + WordPress environment built this time is as follows

MySQL php
Wordpress 4.9 nginx
AMI2 172.31.91.2

1.Install MariaDB, PHP, nginx, WGet

2. Modify PHP FPM and nginx configuration files

3. Download WordPress and configure

4. The web page enters the background

1. Master configuration

sudo yum -y install mariadb mariadb-server php php-server wget php-fpm php-mysql 
sudo amazon-linux-extras  install -y nginx1
#Start nginx, MariaDB, and initialize mailadb

systemctl start mariadb
/usr/sbin/nginx
systemctl enable mariadb
systemctl enable nginx

mysql_secure_installation  #Set the database root user password
Enter fullscreen mode Exit fullscreen mode

2、Modify PHP-FPM configuration files

Edit PHP FPM configuration file

[root@localhost ~]# vi /etc/php-fpm.d/www.conf


## Modify the following lines file to change Apache to nginx
listen = /var/run/php-fpm.sock # add this 
listen.owner = nginx # Modify line 32
listen.group = nginx # Modify line 33

user = nginx # Modify line40

group = nginx # Modify line42

## restart php


[root@localhost ~]# systemctl start php-fpm
Enter fullscreen mode Exit fullscreen mode

Image description
Image description

3、Download WordPress and configure

# wget https://wordpress.org/wordpress-4.9.tar.gz
Enter fullscreen mode Exit fullscreen mode
You can download it to the computer first and then transfer it to the server
Tar decompression package
tar -zxf wordpress-4.9.tar.gz 
Enter fullscreen mode Exit fullscreen mode
Log in to MySQL and create WordPress database and user
MariaDB [(none)]> create database `wordpress-db`;
MariaDB [(none)]> grant all privileges on `wordpress-db`.* to 'wordpress'@'localhost' identified by '000000';
MariaDB [(none)]> flush privileges;
Enter fullscreen mode Exit fullscreen mode
Create and edit WP config PHP file
[root@server ~]# cp wordpress/wp-config-sample.php wordpress/wp-config.php
[root@server ~]# vi wordpress/wp-config.php

Enter fullscreen mode Exit fullscreen mode
Modify database name, database user and password

Image description

Copy the contents of WordPress installation directory
#Remove page files from the original directory
mv /usr/share/nginx/html/* /opt/

cp -r wordpress/* /usr/share/nginx/html
#change permission
[root@localhost ~]# chown -R nginx:nginx /usr/share/nginx/
Enter fullscreen mode Exit fullscreen mode
Restart nginx and MariaDB services
[root@server ~]# systemctl restart  mariadb
[root@server ~]# /usr/sbin/nginx -s reload
Enter fullscreen mode Exit fullscreen mode

4、The web page enters the background

Enter the IP address of the browser for installation

Image description
Image description

Top comments (0)