Install WordPress on LAMP server

Step1. Created ECS and RDS instance

Open port 80 on ECS for web traffic
Whitelisted ECS public IP (47.75.190.46) for RDS access
Verify mysql connection from ECS
root@iZj6c5vmzbgujq3xi2m45aZ:~# mysql -u hasnain -p -h rm-3ns0usu7zsxr6r1n4ho.mysql.rds.aliyuncs.com -P 3306 wordpress
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 82324
Server version: 5.6.16-log Source distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Step2. Install a LAMP web server on a ECS

Install Apache and PHP
root@iZj6c5vmzbgujq3xi2m45aZ:~# apt update && sudo apt install lamp-server^

Verify installation and configuration:
root@iZj6c5vmzbgujq3xi2m45aZ:~# apache2 -v
Server version: Apache/2.4.29 (Ubuntu)
Server built:   2020-03-13T12:26:16

root@iZj6c5vmzbgujq3xi2m45aZ:~# php -v
PHP 7.2.24-0ubuntu0.18.04.3 (cli) (built: Feb 11 2020 15:55:52) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.24-0ubuntu0.18.04.3, Copyright (c) 1999-2018, by Zend Technologies
  
root@iZj6c5vmzbgujq3xi2m45aZ:~# sh -c 'echo "<?php phpinfo(); ?>" > /var/www/html/info.php'


Another way to check RDS DB connection is by creating checkdb.php file in /var/www/html with below conent

1.  <? php  
2.  $ test  = mysqli_connect ( 'rm-3ns0usu7zsxr6r1n4ho.mysql.rds.aliyuncs.com' ,  'hasnain' );  
3.  if  (! $ test ) {  
4.  die 'MySQL Error:'  . mysqli_error ());  
5.  }  
6.  echo 'Database connection is working properly!' ;   
7.  mysqli_close ( $ testConnection );  
8.  ?>  
Step3. Install WordPress on LAMP server

root@iZj6c5vmzbgujq3xi2m45aZ:~# apt install wordpress

Configure WordPress to use MySQL RDS and PHP.

1.  CREATE DATABASE wordpress;  
2.  GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER  
3.  ON wordpress.*  
4.  TO hasnain@47.75.190.46;  

Configure PHP

root@iZj6c5vmzbgujq3xi2m45aZ:~# vi /etc/wordpress/config-localhost.php

Copy the following lines to the file
1.  <?php  
2.  define('DB_NAME''wordpress');  
3.  define('DB_USER''hasnain');  
4.  define('DB_PASSWORD''');  
5.  define('DB_HOST''rm-3ns0usu7zsxr6r1n4ho.mysql.rds.aliyuncs.com:3306');  
6.  define('WP_CONTENT_DIR''/usr/share/wordpress/wp-content');  
7.  ?> 
Move the WordPress installation to the web server document root:

root@iZj6c5vmzbgujq3xi2m45aZ:~# vi /etc/wordpress/config-localhost.php

root@iZj6c5vmzbgujq3xi2m45aZ:~# ln -s /usr/share/wordpress /var/www/html/wordpress

root@iZj6c5vmzbgujq3xi2m45aZ:~# mv /etc/wordpress/config-localhost.php /etc/wordpress/config-default.php

Completed the WordPress setup and published on the platform.



Setup Login site name, email, username, password above and Login to wordpress



To install Apache Web Server on RedHat/CentOS 7 go here.
Also to install Apache Tomcat as a service on RedHat/CentOS 7 go here

Post a Comment

Thanks for your comment !
I will review your this and will respond you as soon as possible.