Changes

Jump to: navigation, search

OPS335 Lab 5

48 bytes added, 10:43, 3 March 2017
Test Connection to MySQL Database Server
=== Test Connection to MySQL Database Server ===
*While the web server (with php), and MySQL server may be working individually, we need to ensure that they can connect to each other.*Since this test will involve storing the database password in a plain-text html file, we want to make sure no one else can access it.*'''Perform the following steps:''' # Modify the Directory statement for your private directory to prevent any machine other than your vm1 from accessing it.*# Re-start the web-server and try to access the page from another machine. Make sure that you can '''not''' do so before you continue.*# Install the '''php-mysql''' module so that the installation of php your web server is using can execute sql statements. You will have to restart the service after installing it.*#Modify the index.php page in your private directory to match the code below. This will test that your web server can connect to the database (replace the user, password, and database with values appropriate for your machine).:<br><presource>
<?php
$mysqli = new mysqli("localhost", "user", "password", "database");
echo $mysqli->host_info . "\n";
?>
</presource>*#Once that page shows a successful connection on your VM ('''Localhost via UNIX socket''') this step is complete.
*You have now established that the web server is able to run code which can interract with the database. This will allow dynamic pages to make use of information stored there when providing resources to your users.
13,420
edits

Navigation menu