centos

Mounting HTML folder in Centos VirtualBox

I have a particular Linux set up I need to test something on, but I use a Mac, so I use VirtualBox with a Linux VM for the testing.

So, to do this normally, you either install an IDE on the VM and code on there. Installing Java, Netbeans, Subversion, Git, etc, etc, etc, or, you just checkout the code on the VM and make code changes on the Mac…

Neither of these options are really that great, so a friend recommended I mount the code folder from the Mac on the Linux VM. Great idea. So I install a new copy of CentOS and keep it minimal, no window managers, nothing like that. Just Apache, and the database connectors I require.

Now, I would not class myself as a Linux expert in any shape or form. I can set up a server and manage it, ut if you delve too deeply, I start to struggle. I used the VirtualBox automatic mounting for my code folder (using Guest Additions) – this just would not work. I tried checking out the code into a local folder and that worked fine. Must be a problem with the share/permissions or something.

After wasting an hour or so checking permissions and groups, I gave up and tried the internet. Came across a really helpful post, which I sort of followed. I had to alter it for CentOS as it was Ubuntu orientated.

You have to install Guest Additions first!

Add a virtual box shared folder

Create a Transient folder in the shared folders section and take note of the name, I used ‘sites’ – do not select any of the checkboxes when creating the share. This is what causes the problem as VirtualBox creates the share with permissions that Apache cannot use.

mkdir /var/www/sites
mount -t vboxsf -o rw,uid=0,gid=0 sites /var/www/sites

I used the UID and GID of 0 as I was only installing this VM as root. There were no other users installed, but you do need to change the UID and GID of the Apache process (www-data?)

Test that and make sure it works, if it does, lets make it permanent:

nano /etc/fstab
sites /var/www/sites vboxsf defaults 0 0

Hey presto, the folder is mounted on boot and you should be able to serve the docs from there.

Obviously you need to update the vhosts to point at the shared folder. But you know how to do that, right?

Setting up CentOS with no X Window Manager

For a nice VM I needed a Linux server, but no need for a GUI, so went for CentOS.

Installed fine, but no networking. How do I install that? Turns out, it is installed, just disabled by default:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

Find the line ONBOOT and change to yes:

DEVICE=eth0
HWADDR=00:00:00:00:00:00:00 TYPE=ETHERNET
UUID=some guid string
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp

Then just restart networking at you should be up and running:

service network restart

Test by entering ifconfig and you should see the loopback address.

If you need to install Guest Additions on VirtualBox:

yum update
yum install gcc make kernel-devel
mkdir /media/cdrom
mount /dev/scd0 /media/cdrom
sh /media/cdrom/VBoxLinuxAdditions.run

Getting wkhtmltopdf working on Linux

I’ve had a few troubles getting this running, and thought I would document it here.

First of all get the static binaries from the wkhtmltopdf site

And then install the following packages: (either through yum or aptitude)

  • libXrender
  • libXext
  • xz
  • openssl-devel
  • glibc
  • glibc-common
  • ld-linux.so.2
  • urw-fonts
  • libfontconfig.so.1
  • libz.so.1
  • libXext.so.6
  • libstdc++.so.6

Now, I have done this before, in Ubuntu and not hd to install the .so.x files but Centos 6 required that I did so… Annoying, and head scratching…

 

New install of Centos – No network

If you have just set up a new Centos server and found that the network isn’t functioning, and you have no IP address for it then fear not, its a ‘secure’ default for Centos to not enable networking until you are ready to do so.

cd /etc/sysconfig/network-scripts/ 
sed -i -e 's@^ONBOOT="no@ONBOOT="yes@' ifcfg-eth0

Then reboot.

If this doesn’t help, then double check the filename in that folder. You may have ifcfg-lo instead.

More help here: http://wiki.centos.org/FAQ/CentOS6#head-b67e85d98f0e9f1b599358105c551632c6ff7c90

Installing Skype on Centos 6

Taken from http://linuxinternetworks.com/applications/how-to-install-skype-on-centos6-rhel6/

Run update and install wget

yum update
yum install wget

Install the dependencies and download the skype for enterprise linux

yum install libXi.so.6 libXss.so.1 libasound.so.2 libXv.so.1 libSM.so.6 libXrender.so.
wget http://download.skype.com/linux/skype-2.2.0.35-fedora.i586.rpm
yum localinstall --nogpgcheck ./skype-*.rpm

Sometimes skype will not start, the only solution to start the skype is replacing the /usr/bin/skype with the download static skype:

wget http://download.skype.com/linux/skype_static-2.2.0.35.tar.bz2
tar xvf skype_static-x.x.x.x.tar.bz2
cp skype_static-2.2.0.35/skype /usr/bin/skype
cp: overwrite '/usr/bin/skype' ? Y

Now its clear. You can access the skype from Applicaions -> Internet -> Skype or type skype in your terminal.

How to transfer files over SSH/SCP

I often forget the syntax for getting files over a SSH connection.

scp user@address:/path/to/file /path/of/new/file

For example:

scp root@domain.com:/tmp/mysql/test.sql .

Will transfer test.sql to the current folder (.) Also, if you need to change the port, just use the -P option

scp -P 9000 user@address:/path/to/file .

If you want to transfer a file TO another server:

scp /path/of/file user@address:/path/to/new/location

 

How to install MySQL Server on Centos

To install MySQL on Centos is a little different from Ubuntu – as I found out. Obviously APT is replaced with yum on this flavour of Linux, but not only that, yum doesn’t appear to set it up for you after installing it (with root account, etc).

Step 1, Install MySQL

> yum install mysql-server mysql

This will download the files and install them in the correct folders, as apptitude would. Step 2 shows you how to prepare the MySQL service.

Step 2, Configure the service

Tell the system to start the MySQL Daemon upon startup:

chkconfig --levels 235 mysqld on
service mysqld start

Now MySQL is installed and running, but the root account will have no password, so we need to ensure there is a strong one. (Or not if you are a crazy one) – You will get some message when the service starts for the first time related to security measures, I would suggest you do read it.

Step 3, Set up Root user

> mysql -u root
> SET PASSWORD FOR 'root'@'%' = PASSWORD(<password>);

Replace <password> with your desired password.

Obviously change the root user details based on your particular set up. I.e. where the root account can connect from, which servers, ips, etc.