Run Your Own Web Server with VMWare

After spending years playing with Linux Servers and VMWare I have decided to give a little bit back to the community.  I have created a minimal VMWare web server image with everything you need to get started hosting your own web pages and applications.

This is a CentOS 4.6 minimal installation with all the updates / upgrades (to date) and a full LAMP stack to get you started.

It ships with :

  • PHP 5.1
  • Most common PHP Libraries (GD, Mcrypt…)
  • Mysql 5
  • Apache 2
  • Cent OS 4.6 Minimal - Up to date

What starts on boot :

  • SSH (remote management)
  • HTTPD (Apache 2 Web Server)
  • MySQL (Database Server)

Getting Started - Windows User Beware, No Mouse Available!

If you are a linux user you probaly don’t need any help - just a quick and easy LAMP stack.

If you are a Windows user, I am guessing you may need some help setting this up.

In Windows there is an annoying application or “exe” called putty you can use to configure this system remotely.  All you have to do is know the servers IP, you will have to either check your gateway for new DHCP leases or log into the virtual machine to find this out.

Default Administrative Username : root

Default Administrative Password : password

Change your password IMMEDIATELY using the following command - I know Mr. NT,  its scary not using the mouse.

# passwd
and follow the on screen instructions - if you are having problems already - give up, you suck.

Now that you have changed your password lets set our database password, use the following command :

# mysql -u root -p

// It will then ask you for a password - it is “password” - without the quotes

Password : password
mysql> set password = password(”your new password”);

I facepalm when I see people set their password to that of “your new password” - if you are confued, give up.

Now if you want to use DHCP (bad idea for servers unless you set static routes in your gateway) then just run :
#ifconfig
and write down the IP address it spits out.

Otherwise you want to set a static IP, one that doesn’t ever change - type :

#netconfig
And specify the IP, Subnet, Gateway and DNS info - if you don’t know what this means then you may as well give up.

Great, we have set our IP, admin password and mysql database password - lets use ssh now - press ctrl + d to logout.

Now open your shitty windows “putty” program and all you have to type in is the IP you wrote down earlier, or the staic IP you configured using netconfig.

Login as root and type in the password you just set (not the damn mysql password!)

It is time to set up an Apache Virtual Host

Since you love M$ use nano, it’s the easiest editor for n00bs :

# nano /etc/httpd/conf/httpd.conf

at the very bottom of the file paste :

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot “/var/www/yourdomain.com
ServerName yourdomain.com
<Directory “/var/www/yourdomain.com“>
AllowOverride All
Allow from All
</Directory>
ServerAlias www.yourdomain.com
</VirtualHost>

Where 80 is the port the web server listens on and yourfomain.com is your FQDN (fully qualified domain name)

Make a directory to host your files using this command :

# mkdir /var/www/yourdomain.com

Where yourdomain.com is the same you specified in your httpd.conf.

How to restart applications

Apache Web Server : # service httpd restart

Mysql Database : # service mysqld restart

To stop a service replace the above restart with “stop”.

Awesome - now you are ready to get started on your DNS info. Login to wherever you registered your domain and change your name servers to ns1.everydns.net, ns2.everydns.net and ns3.everydns.net.  Create an account at everydns.net (its free) and add a Dynamic domain which will automatically point to your server IP as long as you are at the same IP when you create the Dynamic Entry.

You want to set an A record to your IP - MX is not necesarry if you are not hosting an email server.

Last thing you need to do is open your router / gateway management page and Forward port 80 (or whatever port you put in your httpd.conf) to the IP of the your VMWare Image.

Once that is all done and the DNS has propogated (could take overnight) - you should be able to visit yourdomain.com and see a “Welcome to Cent OS” page.  You can change this by adding files to /var/www/yourdomain.com specifically an index.php or index.html file.

I hope this wasn’t too painful to read - download the image here. If the file is not 686 MB, it means it’s not done uploading and wont work - be patient!

If you are an r-tard Windows user and can’t unzip this tar.gz archive, download winrar, google it if you are stupid.

I will write a tut in the future re: connecting to VMWare without a GUI

Share/Save/Bookmark

No Comment