Archive for Apache

Opening local website on the Virtual Machine

In case if you have Windows XP (also true for Windows 7) on the VM, open “hosts” file from:

C:\WINXP\system32\drivers\etc

and add following line:

<ip-of-the-local-pc>	devel.localhost

of couse I assume that devel.localhost subdomain is set up. Now you can reach the website hosted on your local machine.

How to install PEAR on MAC OSX

First do:

curl http://pear.php.net/go-pear > go-pear.php
sudo php -q go-pear.php

Change installation directory to:

/usr/local

Add include path in /etc/php.ini:

include_path = ".:/usr/share/pear"

Restart Apache.

Tutorial based on http://clickontyler.com/blog/2008/01/how-to-install-pear-in-mac-os-x-leopard/. Thanks !

Useful paths

Paths on Mac:

/etc/php.ini
/private/etc/php.ini 
/etc/apache2/httpd.conf
/etc/apache2/extra/httpd-vhosts.conf
/etc/hosts

Configuring Apache with two VirtualHosts

The begining
Start Apache:

sudo apachectl start

Enabling VirtualHosts
Open httpd.conf file

sudo mate /etc/apache2/httpd.conf

Find the following line:

#Include /private/etc/apache2/extra/httpd-vhosts.conf

and uncomment it. To enable PHP5, find:

#LoadModule php5_module        /opt/local/apache2/modules/libphp5.so

and uncomment it as well.

Adding VirtualHosts

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
 
 
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
    DocumentRoot /Users/uzza/Development/workspace
    ServerName localhost
</VirtualHost>
 
<VirtualHost *:80>
    DocumentRoot /Users/uzza/Development/sandbox
    ServerName sandbox
</VirtualHost>

Adding the local hosts
Open hosts file:

sudo mate /etc/hosts

and add following lines:

127.0.0.1	localhost
127.0.0.1	sandbox

The ending
Restart Apache

sudo apachectl restart

and check if you can open

http://localhost
http://sandbox

SSH Connection

Open terminal and type:

ssh <host> -l <username>
<password>

Then log in as sudo if needed:

sudo su -

Other useful commands:
- Logging in to mysql:

mysql -h <host> -u <username> -p

- Logging in to mysql on some port:

mysql -h <host> -u <username> -p --port=<port>
use <db-name>
source <sql-file>

- Unzipping:

unzip package.zip -d /some/dir