I wanted to have my WordPress Blog running on a local Webserver so I can test upgrades before I do it on the live system. Follow this guide to setup a small Webserver in a Virtual Machine to easy host your websites. I am going to use Ubuntu 1310 (64bit only) as the basis and install it into Parallels Desktop as that is my default VM Tool. You can of course do the same with the open-source tool VirtualBox from Oracle.
- Download Ubuntu Server package
- Install Ubuntu Server 1310
- Run update and install some dependencies
- Install Webmin
- Install MySQL Database
- Install Apache
- Install PHP Support for MySQL
- Install MyphpAdmin
- Install FTP Server (vsftpd)
Step 1: Download Ubuntu 13.10
First download Ubuntu choose the right package below for your Computer (32bit or 64bit)
PC (Intel x86) server install image
For almost all PCs. This includes most machines with Intel/AMD/etc type processors and almost all computers that run Microsoft Windows, as well as newer Apple Macintosh systems based on Intel processors. Choose this if you are at all unsure.
64-bit PC (AMD64) server install image
Choose this to take full advantage of computers based on the AMD64 or EM64T architecture (e.g., Athlon64, Opteron, EM64T Xeon, Core 2). If you have a non-64-bit processor made by AMD, or if you need full support for 32-bit code, use the Intel x86 images instead.
64-bit Mac (AMD64) server install image
Choose this to take full advantage of computers based on the AMD64 or EM64T architecture (e.g., Athlon64, Opteron, EM64T Xeon, Core 2). If you have a non-64-bit processor made by AMD, or if you need full support for 32-bit code, use the Intel x86 images instead. This image is adjusted to work properly on Mac systems.
Step 2: Install Ubuntu 13.10 Server
I am using Parallels Desktop 9 but you can choose whatever you like. VirtualBox ist a open-source and free alternative owned and enhanced by Oracle. It is pretty decent and did I mention its free? Then there is of course VMWare Workstation another product that is very much like Parallels. Choose whatever you like best.
Installing Ubuntu in your favourite Virtual Machine is pretty straight forward and I won’t bore you with dozens of screenshots. If you do this the first time check out the screen-recording I did.
Installing Ubuntu 13.10 in Parallels Video
My VM (Parallels Settings)
I choose the following Settings for the Webserver:
- RAM: 1GB
- CPU: 1 Core
- Hard Disk: 6GB
- Network: Virtio Adapter (Default)
rest default settings.
Step 3: Run Update and install some dependencies
After you have Installed the basic Ubuntu Server 13.10 check if there are any updates available and install them. Execute the following 2 commands:[cc lang=”bash”] sudo apt-get update
sudo apt-get upgrade
Setting up Environment[cc lang=”bash”] sudo nano /etc/environment
and add the following line:[cc lang=”bash”] LC_ALL=C
next install some packages we will need[cc lang=”bash”] sudo apt-get install python-software-properties libnet-ssleay-perl libauthen-pam-perl
libio-pty-perl apt-show-versions vim-nox
Step 4: Install Webmin
If you don’t wan’t to install webmin, just skip this step. It is a useful tool and if you are not 100% familiar with Linux and command-line tools then I would advise to use Webmin as you still have the comfort of the GUI available to you if you need it. At the time when I wrote this Post the latest Version was 1.660 but please check beforehand and install the latest one. Just replace the number of the current version in the below commands.
Link to Latest webmin
To download webmin 1.660 execute the following command:[cc lang=”bash”] sudo wget http://prdownloads.sourceforge.net/webadmin/webmin_1.660_all.deb
To install webmin 1.660 execute the following command:[cc lang=”bash”] sudo dpkg –install webmin_1.660_all.deb
All done, you can now access webmin via your web browser https://<server name or IP-Address>:10000
Step 5: Install Apache
To host your websites we will install Apache. Pretty simple just execute the below command:[cc lang=”bash”] sudo apt-get install apache2
all done. You can try it out by opening the Address of your web-browser. (http://<server name or IP-Address>)
Starting / Stopping Apache[cc lang=”bash”] service apache2 start
service apache2 restart
service apache2 stop
Step 6: Install MySQL
Next lets install MySQL Server and Client. As easy as with Apache, just execute the following command:[cc lang=”bash”] sudo apt-get install mysql-server mysql-client
You will be ask to set the root password for MySQL, make sure you remember it.
Step 7: Install PHP Support for MySQL
To get MySQL support in PHP, we install the php5-mysql package. It is also a good idea to install other PHP5 modules as well as you might need them for your applications later on. Execute the below:[cc lang=”bash”] aptitude -y install php5 libapache2-mod-php5 php5-mysql php5-curl php5-gd php5-intl php-pear
php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode
php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
After completion restart Apache by executing:[cc lang=”bash”] sudo /etc/init.d/apache2 restart
You can search for available PHP5 modules with the following command:[cc lang=”bash”] sudo apt-cache search php5
After you pick the packages you need install them with the following command:[cc lang=”bash”] sudo apt-get install (package-name)
You can check if all worked well by creating a file in your /var/www directory called info.php – add the following content in it and after saving it call it in your web-browser.[cc lang=”bash”] sudo nano /var/www/info.php
copy the below into the file and save it.[cc lang=”bash”]
open a web-browser and call http://server-name/info.php
Step 8: Install phpMyAdmin
Quickly done, just execute the below command.[cc lang=”bash”] sudo apt-get install phpmyadmin
During the installation you will be ask for your root password of the MySQL Database. Just enter the correct password you choose earlier in the MySQL installtion.
Step 9: Install FTP Server (vsftpd)
Normally you would not need a FTP Server, however for my next project it will be required so I will show you already how to setup ftp. Install the package via the following command:[cc lang=”bash”] sudo apt-get install vsftpd
to configure the FTP Server you have to open the config file at /etc/vsftpd.conf
I am not going too deep into it. Of course running a ftp Server for the outside world is not ideal, you should think about a more secure way and use the FTPS or SFTP protocol instead.
All done, well you have now a Webserver installed with a MySQL Database incl. a FTP Server. They are not yet configured perfectly but then everyone will use it in a different way.
- Apache: http://httpd.apache.org/
- PHP: http://www.php.net/
- MySQL: http://www.mysql.com/
- Ubuntu: http://www.ubuntu.com/
- phpMyAdmin: http://www.phpmyadmin.net/
- vsftpd: http://vsftpd.beasts.org/