Archive

Posts Tagged ‘Apache’

Configure Apache with a Server Alias

March 10th, 2010

Notes on setting up apache for multiple web sites:

In the /etc/apache2 directory you have two directories:
- sites-available
- sites-enabled

The sites-available directory contains configuration files for each website.
The sites-available contains links to the configuration file in the sites-available directory.  It does not contain the file itself.

The mistake that is made at times is that *all* configs are placed in one file – default.

So, for a domain name like domain.com you would create a file called domain.com in the sites-available directory with the following:

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/domain
ServerName www.domain.com
Server Alias domain.com
</VirtualHost>

you would do:  /ln -s /etc/apache2/sites-available/domain.com /etc/apache2/sites-enabled/domain.com

OR

a2ensite domain.com (from within the sites-available) directory.

finally:  /etc/init.d/apache2 reload

So, in a nutshell — create a file per domain name — use ServerAlias to cover www.domain.com and domain.com.

Andrew Hosting , , , , , ,

Instructions for Installing WordPress on Ubuntu 9.10 (Karmic Koala)

January 19th, 2010

Instructions for Installing WordPress
——————————————————————————————————

# Setup Sources (some VPS vendors block sources)
vi /etc/apt/sources.list

(remove all # in front of all sources)
To save in vi: :qw
To exit without saving: :q!

# Do updates, upgrades, and install essentials
apt-get update
apt-get upgrade
apt-get dist-upgrade
apt-get install build-essential
apt-get install linux-headers-$(uname -r)

# Install a friendly editor if you are not familiar with VI
apt-get install jed

# Now for some security (iptables will probably be installed, running command doesn’t hurt and verifies that it is)
# The config below allows for FTP, SMTP, POP, IMAP, HTTP, HTTPS and SSH
# Adjust according to your needs

apt-get install iptables
iptables -F
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p icmp –icmp-type any -j ACCEPT
iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 25 -j ACCEPT
iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 110 -j ACCEPT
iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 143 -j ACCEPT
iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 443 -j ACCEPT
iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 993 -j ACCEPT
iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 995 -j ACCEPT
iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 10000 -j ACCEPT
iptables -A INPUT -j REJECT –reject-with icmp-host-prohibited
iptables -A FORWARD -j REJECT –reject-with icmp-host-prohibited

iptables-save > /etc/network/iptables
printf ‘#!/bin/sh\niptables-restore < /etc/network/iptables\n’ > /etc/network/if-pre-up.d/iptables
chmod 754 /etc/network/if-pre-up.d/iptables

# Deny Hosts is a nifty little program that tracks people who try to brute force your root account
apt-get install denyhosts

#Location of config files:
#config: /etc/denyhosts.conf
#datafile: /etc/hosts.deny

# This installs the lamp stack
tasksel install lamp-server

# And now for Wordpress
cd ~/
mkdir downloads
cd downloads
wget http://wordpress.org/latest.tar.gz
mkdir /var/www/wordpress
cd /var/www/
chown -R www-data:www-data wordpress
chmod -R -v 755 wordpress
tar -zxvf ~/downloads/latest.tar.gz –directory=/var/www
cd /var/www
mv wordpress myblog
cp /etc/apache2/sites-available/default /etc/apache2/sites-available/default.org
jed /etc/apache2/sites-available/default

#add the following section to the top
#-START——————————————
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/myblog
ServerName www.myblog.com
</VirtualHost>
#-END——————————————–
/etc/init.d/apache2 restart

#Setup a database for WordPress
#Change command below according to your needs

mysqladmin -u root -p create wordpress-myblog
mysql -u root -p
CREATE USER ‘wp-myblog’@'localhost’ IDENTIFIED BY ‘NiftyPasswordGoesHere’;
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO ‘wp-myblog’@'localhost’ WITH GRANT OPTION;
FLUSH PRIVILEGES;
USE wordpress-myblog;

#Finally point your domain DNS records to your IP address and complete setup.

Andrew Hosting, How-to , , , , , , ,

apache2: apr_sockaddr_info_get() failed for SERVERNAME

May 22nd, 2009

Apache error when booting server:

apache2: apr_sockaddr_info_get() failed for SERVERNAME

WOW – this one took me a bit to figure out and the solution is so simple.

vi /etc/apache2.httpd.conf
note: it will probably be blank
add the following line:  ServerName myservername.mydomain.com

Reboot

Andrew Troubleshooting ,

How to find which user / service account Apache is using.

May 7th, 2009

The following command will display the information:

ps -ef | grep apache

For example:

www-data   310  4474  0 May05 ?        00:00:17 /usr/sbin/apache2 -k start
www-data   469  4474  0 May05 ?        00:00:15 /usr/sbin/apache2 -k start
www-data 29914  4474  0 May05 ?        00:00:14 /usr/sbin/apache2 -k start

The account running apache is www-data.

Andrew Where is that again? , ,