Now if you followed along on Part 1 or if you have your own LAMP Stack ready to go we can begin actually configuring the system so that we can have our very own movie database.
1. Log into the Turnkey LAMP control panel page (can be viewed from your VM and should be something like 192.168.0.XX)
2. Since we are going to be running some commands to update the software we will be using the Web Shell, open the web shell.
3. Login using the “root” account and the password you created during the install
4. type in “apt-get update” and enter. This will update a bunch of lists that the system needs to run an upgrade
5. type in “apt-get upgrade” and enter. This Upgrades the system, during this process (which might take a few minutes) you will be asked to confirm some setting with a “y” or “n” when asked just type “y” and enter for all of them.
6. type in “apt-get install build-essential” and enter, again just press “y” when asked to confirm anything.
7. type in ” apt-get install libxml-parser-perl” and enter.
8. type in ” apt-get install libyaml-perl” and enter.
9. type in “cpan” it will ask you again for a “y” prompt.
10. type in “install Bundle::CPAN” and enter, again just press “y” when asked to confirm anything.
11. type in “install YAML::XS” and enter.
12. type in “install XML::Simple” and enter, again just press “y” when asked to confirm anything.
13. type in “exit” and enter
14. Return to the vm and navigate to Advanced Menu ->Reboot and select Yes
15. Once the restart is complete return to the Turnkey LAMP Control panel and select PHPMyAdmin
16. Login as the PHPMyAdmin “root” account using the login details created at the beginning of part 1
17. Select Databases from the tab on the top left corner of the screen.
18. Using the Text box in the middle of the screen create a new database called “movieCol”
19. Select the SQL Tab and paste in the below and select Go
CREATE TABLE IF NOT EXISTS `movie_collection` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(128) binary DEFAULT NULL,
`year` varchar(128) binary DEFAULT NULL,
`rated` varchar(128) binary DEFAULT NULL,
`released` varchar(128) binary DEFAULT NULL,
`genre` varchar(128) binary DEFAULT NULL,
`director` varchar(128) binary DEFAULT NULL,
`writer` varchar(128) binary DEFAULT NULL,
`actors` varchar(128) binary DEFAULT NULL,
`plot` varchar(500) binary DEFAULT NULL,
`poster` varchar(500) binary DEFAULT NULL,
`runtime` varchar(128) binary DEFAULT NULL,
`rating` varchar(128) binary DEFAULT NULL,
`votes` varchar(128) binary DEFAULT NULL,
`imdb` varchar(128) binary DEFAULT NULL,
`tstamp` varchar(128) binary DEFAULT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1
This is going to create the database table that we will be storing our data in.
20. now download the PHP pages and Perl scripts that we will be using (it is currently hosted on Dropbox, I will move it if enough use it)
21. Return to the Control panel and select Webmin, Again login with the Root account created earlier
22. From the top toolbar select Tools -> File Manager
23. Navigate to /var/www using the navigation panel on the left
24. Using the Upload button in the top toolbar select and upload “movies.zip” from your machine
25. Using the Extract tool from the top toolbar extract the contents of “movies.zip” (if you select “yes, then delete” it helps tidy up the directory by removing movies.zip after you are finished with it)
26. Navigate to http://192.168.0.XX/movies/index.php (replace the XX with your machines number just as you did before) and you should be taken to a screen telling you that there are no movies in your database.
Nearly there all we need to do is tweak some permissions and passwords and then we are done.
27. In File manager navigate to /var/www and highlight the movies directory from the top toolbar select “info”
28. Tick every box in the permissions and change the User and Group to “www-data” and change the drop down to “This Directory and all subdirectories” and Save
if your “root” password is “root” you can skip to step 30 (root/root is not a good combo for security reasons but as you may have noticed this probably isnt the most secure website any and I would suggest you dont host it online and you leave it as an internal “intranet”)
29. Highlight process.php from within /var/www/movies and select edit. Change the password details within the top few lines
exec(” perl getMovieData.pl \”$title\” > \”input.sql\” “);
$mysqli = new mysqli(‘localhost’, ‘root’, ‘PASSWORD GOES HERE’, ‘movieCol’);
then save and close
repeat the process in index.php
$db_conn = new mysqli(‘localhost’, ‘root’, ‘PASSWORD GOES HERE’, ‘movieCol’);
$subtitle = ”;
30. Return to http://192.168.0.XX/movies/index.php enter a movie name and select submit. A successful entry will look like above and one that fails will only display the first two lines. Add another or return to catalogue to see your handy work.
Congratulations! you can of course tweak the PHP or Perl to your needs and let me known in comments of any new ideas/suggestions