Now it's time to make our machine a real web server. The actual “web server” software is Apache HTTP server, but we’ll also be needing PHP for dynamic websites like the wiki, MySQL as the database of choice, and PHPMyAdmin as a GUI on MySQL. These are typical tools for web servers.
Start up your virtual machine, and start up a terminal window. You can do this via Dash, the uppermost button in the shortcut bar on the left of the screen of your virtual machine. In the search box, enter “terminal”. This will open a console within the GUI, like cmd would on a Windows machine. We’ll be using this terminal a lot.
|Apache Software Foundation|
The most used web server software is the Apache HTTP server. It's powerful, robust, and completely free.To install, type this into the terminal:
sudo apt-get install apache2It will ask you for your password (you set this up when installing Ubuntu). Then it will ask you to confirm the installation. Enter Y to confirm. That's it! You've just made your machine a web server.
The entering Y to confirm installation is a rather standard thing. I won't be repeating it for all the following installs, I'm sure you'll remember.
MySQL is a free and open source database from Oracle. It is often used for storing data for dynamic websites such as a wiki, forum (phpBB), bugtracker, etc
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysqlDuring install, it will ask you for a password for the “root” user for MySQL. Enter one and remember it, you'll be needing this later.
Now, to activate mysql, type:
sudo mysql_install_dbAnd do the security setup by typing:
You’ll have to give the MySQL root password again. No need to change it, we’ve already changed from default. To make the thing secure, you will want to remove the anonymous users, disallow root login remotely, and remove the test database. Let it reload the privilege tables to complete the security setup.
PHP is a programming language. It's fast and easy, and is widely used to create websites which require programming logic, such as (ao) Wikipedia. Since we'll be using the same software to create our own wiki, we have need of PHP.
In the terminal, type:
sudo apt-get install php5 libapache2-mod-php5 php5-mcryptAnd voilà, you've installed PHP. Admit it, you're beginning to love how fast this is going. If you wouldn't have taken the time to read all the text in between commands, you could have done all this installing work in 30 seconds flat :-)
Don't stop reading the text in between commands though. You'd be done with the article too fast. Bad for my ratings.
Anyway, you may have installed PHP, but Apache doesn't know this yet. We need to let Apache know that a file like index.php is now also a valid index file to show to your website users. To do this, we need to change an Apache configuration file. In the terminal, type:
sudo nano /etc/apache2/mods-enabled/dir.confYou need to add index.php as shown here:
DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm
After you've done that, press CTRL+o to save the file (and ENTER to confirm the filename), CTRL+x to exit the editor. As always after changing Apache settings, you need to restart Apache for the changes to take effect. In the terminal, type:
sudo service apache2 restart
PHPMyAdminActually, you're done installing the basic web server software. PHPMyAdmin is a website which will already be making use of it! But I still count is as a basic requirement, because we'll be needing it to administer our MySQL database. You can do everything we need to do just from command-line, but hey, if people build you a nice GUI, you're not going to say no.
Install PHPMyAdmin by typing:
sudo apt-get install phpmyadminWhen asked, select Apache as web server. When asked, select Yes.
It will ask for the MySQL root password. Then PHPMyAdmin will ask for a password for itself (its own user). Leave this blank to let it generate its own password, we don’t need to know this per se.
Now some more magic. Enter:
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.confWhen it’s done, open FireFox (there's a button on the bar on the left) and go to
sudo /etc/init.d/apache2 reload
localhost/phpmyadminYou can login with the (root) MySQL username and password and have a first look. This is your first installed website, and it works. Well done.
In the next article, we'll be installing the MediaWiki software which will empower your own wiki. It's the same software that is used for Wikipedia. How cool is that!