Easy installation of LASP (Linux, Apache, SQLite and PHP) on Ubuntu
If you think about learning how to create dynamic database-driven web sites, the simplest way to start is with PHP and SQLite. PHP offers high level programming, but most importantly, unparalleled documentation with clear and easy to understand usage examples. There are many SQL database engines out there, but SQLite is definitely the most simple to set up, because it is completely self-contained, cross-platform, and serverless. SQLite database is actually a single file that is also cross-platform. Conveniently, SQLite comes bundled in PHP5 as PDO extension. This extension provides abstracted access to your database. It means that if you later decide to switch to a different database like MySQL or PostgreSQL, you can use the same functions that you used to access SQLite.
Ubuntu is a wonderful Linux distribution that makes installation of this software extremely easy. Installation process literally takes seconds. All you need to do is open Terminal and type:
Creating SQLite database is also very easy. There are a few things, however, that you should know. First, the best practice is to place the database file outside the /var/www directory. For our purpose, create new directory /var/databases/testsite. Second, Apache needs write permissions for both the directory where the database resides and the database file itself. Therefore you must change the owner of the database directory to Apache. Open Terminal and write:
Finally, create a dynamic web page that will randomly display a single book from your library. Save the following as pickbook.php:
$book[title] by $book[author]"; ?>
I hope you see from this brief example the idea behind PDO and how simple SQLite is to setup and use on Ubuntu. There is so much more you can do with the simple but powerful SQLite. I, Librarian, the scientific PDF manager I wrote is built with PHP-PDO & SQLite as well. Visit these links to learn more:
http://www.php.net/manual/en/book.pdo.php
http://sqlite.org
Comments
- Scott Furry on September 14, 2009, at 10:53 AM