-
Notifications
You must be signed in to change notification settings - Fork 0
/
webphpapp.txt
executable file
·52 lines (46 loc) · 1.05 KB
/
webphpapp.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
sudo yum update -y
sudo setsebool -P httpd_can_network_connect_db 1
sudo yum install -y php php-pear php-mysql
sudo systemctl start httpd
sudo chkconfig httpd on
cat > mydb.php <<EOF
<?php
\$servername = "MYdatabase";
\$username = "phh";
\$password = "kjh865LJHG98[[76";
\$dbname = "test";
// Create connection
\$conn = new mysqli(\$servername, \$username, \$password, \$dbname);
// Check connection
if (\$conn->connect_error) {
die("Connection failed: " . \$conn->connect_error);
}
\$sql = "SELECT mycol FROM mytable";
\$result = \$conn->query(\$sql);
if (\$result->num_rows > 0) {
// output data of each row
while(\$row = \$result->fetch_assoc()) {
echo "Mycol: " . \$row["mycol"]. "<br>";
}
} else {
echo "0 results";
}
\$conn->close();
?>
EOF
sudo cp mydb.php /var/www/html/mydb.php
cat > mydb2.php <<EOF2
<html>
<head>
<title>MYDB PHP Page</title>
</head>
<body>
<h1>first line</h1>
<h2>Second Line</h2>
<?php phpinfo(); ?>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
EOF2
sudo cp mydb2.php /var/www/html/mydb2.php