Skip to content

Instantly share code, notes, and snippets.

@leeklee0427
Last active June 27, 2024 18:43
Show Gist options
  • Save leeklee0427/4566ccc399a72fd7d00e8dc587e29dbb to your computer and use it in GitHub Desktop.
Save leeklee0427/4566ccc399a72fd7d00e8dc587e29dbb to your computer and use it in GitHub Desktop.
Oracle Cloud Deployment Instructions

Deployments on Oracle Cloud

This document serves as a comprehensive guide to deploying a MySQL database service on the Oracle Cloud platform. The deployment includes setting up an interactive web interface using Apache/HTTPd and PHP designed to facilitate essential database operations, such as INSERT, DELETE, UPDATE, and SELECT.

Sample scripts in this document comes from Order Management Portal.

You can interact with the database using the following link: http://150.136.153.174/order-management-portal/index.html.

Prerequisites

  1. An Oracle Cloud Infrastructure Free Tier account or similar;

  2. A MacOS, Linux, or Windows computer with ssh support installed.

Environment

The operating system (image) deployed in the Oracle Cloud environment is CentOS-7-2022.04.26-0.

Outlines

  1. Apache/HTTPd
  2. MySQL Database
    1. Download MySQL
    2. Login
    3. User
    4. Error Handling
  3. PHP
    1. Download PHP
    2. Install MySQLi
    3. Troubleshooting

Apache/HTTPd

  1. Install Apache/HTTPd service:

    $ yum install httpd
    
  2. Start web service:

    $ sudo systemctl start httpd
    
  3. Check internet connections:

    $ netstat -lntp
    

/var/www/html is the typical/default location for web server files in Linux distributions.

References

MySQL Database

MySQL is not pre-installed in the default CentOS 7 repositories.

Download MySQL

  1. Enable the MySQL 5.7 repository:

    $ sudo yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

    If "No package mysql-community-server available" pops up, try:

    $ sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
  2. Install MySQL 5.7 package with yum:

    $ sudo yum install mysql-community-server
  3. Start MySQL

    $ sudo systemctl start mysqld
    
  4. Locate temporary password

    $ sudo grep 'temporary password' /var/log/mysqld.log
    
    2024-01-08T02:43:21.036079Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: %7Fp2N9/bOrT
    
  5. Run the security script and set up new password for root user

    $ sudo mysql_secure_installation
    

    Note: You should answer "y" (yes) to all questions.

Login

  • To login into the MySQL server as the root user:
    $ mysql -u root -p
    

User

Login as root user:

  • Create user:
    mysql> CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
    
  • Grant privileges:
    mysql> GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';
    

Error Handling

If Authentication plugin 'caching_sha2_password' cannot be loaded pops up, try:

mysql> ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

References

PHP

Download PHP

  1. Configure the Oracle Linux package repos to use PHP 7:

    $ sudo yum install -y oracle-php-release-el7
    
  2. Install PHP 7:

    $ sudo yum install -y php
    
  3. Restart Apache:

    $ sudo systemctl restart httpd
    
  4. Verify installation:

    $ php -v
    

    Add a PHP test file:

    $ sudo vi /var/www/html/info.php
    

    Input the following text and wq:

     <?php
     phpinfo();
     ?>
    

    Connect to http://<your-public-ip-address>/info.php, which will produce a listing of PHP configuration on your instance.

Install MySQLi

  1. Install MySQLi using yum:
    $ sudo yum install php-mysqli
    
  2. Restart Apache:
    $ sudo systemctl restart httpd
    

Troubleshooting

Add the following lines at the beginning of your PHP script to display errors, which might help identify any issues:

ini_set('display_errors', 1);
error_reporting(E_ALL);

References


leeklee0427
Last Edited on: 01/08/2024
Go to Top

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment