Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've installed CentOS as a virtual box os under my osx host, and have been trying to use it as a local web server, but I've run into some problems.

First, I want to establish that I've installed apache, mysql, and php properly using yum. Now, those of you familiar with virtual os's, how do I access my centos virtual os through my osx host. It does not show automatically in my osx network. I tried ifconfig in centos, but I got a weird ip 10.0.2.1 or something, and that does not work.

I just want to know what I should do next to setup my virtual os as a network drive.

Thanks.

share|improve this question

migrated from serverfault.com Feb 16 '12 at 14:02

This question came from our site for professional system and network administrators.

1  
What virtualization software are you using? You need to configure it for bridged networking (sounds like it's configured for NAT right now). –  Chris S Feb 16 '12 at 14:02
    
I'm using VirtualBox –  Adam Feb 16 '12 at 14:12

1 Answer 1

up vote 0 down vote accepted

First you need to get the virtual server on your LAN. If you shut down the VM and go to the settings, you can set the network to bridged. When it boots up again you should see the IP address similar to your Mac. I would expect something like 192.168.x.y.

Once that is done, check you can ping the VM from your Mac on the CentOS IP.

Now to test apache works, open http://centos IP

To test PHP is working with apache you will need to create a file in the document root of you web server on CentOS. This will be /var/www unless you have changed it. Create a file index.php and put the following inside

<?php

echo "I am PHP";

Now visit http://centos IP/index.php and you should see "I am PHP".

To test that mysql support is available for php, edit the PHP file again and add

mysql_connect( 'root', '', 'localhost' );

Open http://centos IP/index.php again, and if you get an error saying cannot connect, then mysql support is working, if you get an error about function mysql_connect doesn't exist you need to install php-mysql using Yum.

You can use samba or nfs to share a folder on your CentOS machine to make it available as a network share.

share|improve this answer
    
Thanks. It worked. –  Adam Feb 16 '12 at 19:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.