subdomains w/o TLD - apache2

How do i set up a subdomain w/o a TLD? i have this set under my main config
<VirtualHost *:80>
ServerName bbs.67.777.777.777 #fake bc my server can easily be hacked ATM :(
DocumentRoot /var/www/phpBB
</VirtualHost>
when i goto bbs.serveripaddress i get a Address Not Found error. if i put that above my main config it still doesnt work however the entire site is pointing to /var/www/phpBB instead of /var/www (HUH!?!)
the main v host is
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
RedirectMatch ^/$ /apache2-default/
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I'm on a debian box using apache2 if that helps.

I don't think that server name (bbs.67.777.777.777 ) will get you anywhere - unless you have it added to your hosts file... Can you ping that address ok?
Why not just make your website the default... if you don't need a default?

You cannot have a subdomain with an IP address. The best way around this is to have a domain or a free subdomain (such as no-ip) to point at your IP address and create a ServerName for that. Remember to add the domain to your server DNS zones.
or make a domain in your host files and use that.

Related

Ubuntu 12.10 virtualhost conflict

I have two sites on my server. One I access via my IP, x.x.x.x/site1. The other is a registered domain name, www.mysite.com.
Initially, I had only my /etc/apache/sites-available/default file available but when I tried loading either of the sites above I just got my /var/www/index.html output.
I included a new virtualhost for mysite.com with the following code:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/mysite
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/mysite>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Mysite.com only loads when default is disabled but then, x.x.x.x/site1 doesn't.
So, I enable the default virtualhost which has the following code:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Now, x.x.x.x/site1 works but mysite.com does not - instead it loads the /var/www/index.html page.
I'm confused about what the issue is.
In your vhost configuratin for mysite.com you need to add the ServerName directive:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName mysite.com
DocumentRoot /var/www/mysite
[…]

Use bottlepy and php in the same computer

I use ubuntu 12.04 with apache2 and mod_wsgi installed. I want to use bottlepy and php in my local computer.
I know such an issue is already asked by someone else as in Apache mod_wsgi and php in the same domain.
But someone suggest me to make a new question since my problem could be different.
I've change /etc/apache2/sites-available/default into this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot /home/gofrendi/workspace/kokoropy
ServerName oraiso
WSGIDaemonProcess kokoropy user=www-data group=www-data processes=1 threads=5
WSGIScriptAlias /kokoropy /home/gofrendi/workspace/kokoropy/kokoro.wsgi
<Directory /home/gofrendi/workspace/kokoropy>
WSGIProcessGroup kokoropy
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
The first virtual host is for PHP, and the second one is for bottlepy.
I put my bottlepy application in /home/gofrendi/workspace/kokoropy. And I have kokoro.wsgi in the same directory which contains this script:
import os
sys.path = [os.path.dirname(__file__)] + sys.path
from kokoropy import kokoro_init
PWD = os.path.dirname(os.path.abspath(__file__))
APP_DIRECTORY = 'applications'
APPLICATION_PATH = os.path.join(PWD, APP_DIRECTORY)
application = kokoro_init(application_path = APPLICATION_PATH, run = False)
I've do enable the configuration by using
sudo a2ensite default
sudo service apache2 restart
My PHP scripts are still work as expected. But, whenever I don't know how to access my bottlepy script.
I've also try to remove the PHP part of /etc/apache2/sites-available/default, so that it only consists of
<VirtualHost *>
DocumentRoot /home/gofrendi/workspace/kokoropy
ServerName oraiso
WSGIDaemonProcess kokoropy user=www-data group=www-data processes=1 threads=5
WSGIScriptAlias /kokoropy /home/gofrendi/workspace/kokoropy/kokoro.wsgi
<Directory /home/gofrendi/workspace/kokoropy>
WSGIProcessGroup kokoropy
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
But I still can't get bottlepy work. It just simply show 404 not found.
Do anybody has the same experience? How to make it work?
Thanks.
The problem has been solved.
First I change httpd.conf setting (or in my case /etc/apache2/sites-available/default) nto this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
# THIS IS WHERE I START TO EDIT IT:
# It tells apache about wsgi existance
WSGIDaemonProcess kokoropy user=www-data group=www-data processes=1 threads=5
WSGIScriptAlias /kokoropy /home/gofrendi/workspace/kokoropy/kokoro.wsgi
<Directory /home/gofrendi/workspace/kokoropy>
WSGIProcessGroup kokoropy
WSGIApplicationGroup %{GLOBAL}
Options ExecCGI
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
This configuration say that localhost/kokoropy should be handled by the wsgi.
My wsgi script is located at /home/gofrendi/workspace/kokoropy/kokoro.wsgi.
kokoro.wsgi content is as follow:
import os, sys
os.chdir(os.path.dirname(__file__))
sys.path = [os.path.dirname(__file__)] + sys.path
from bottle import default_app
#route('/')
def index():
return 'run with apache'
application = default_app()
If you found internal sever error, when accessing bottlepy, but find no error when accessing php, that is probably some mistake in you wsgi. Just open up the apache log (in my case it is here: /var/log/apache2/error.log)

ZPanelcp , Domains activation not work

-Hello everyone , I just rent an a dedicated server (ubuntu 12.4) and i install apache + php, mySQL etc ...but using SSH to creat domains (virtual hosts) it is a litle bit laborer so I decided to install some GUI admin panel and also decided for ZPanelcp last version so everything installed fine without errors and I set first time two domains something like :
new.domain.com
new.otherdomain.com
these domains has been activated successfully without set zpanel DNS for those domains but next day I notice when I try to create again other domains in my ZPanel show as "live" but in my webbrowser can not see so in reality they were not activated , ok first time I Run Daemon again and restart BIND also restart apache I try a few changes in my server conf files but nothing I reboot my server also nothing my server use one static ip.
Here are my Zpanel, apache2 conf files.
Apache2 files:
folder files:
/etc/apache2/apache2.conf
# Here is last lines of this files related to my problem
# Include of directories ignores editors' and dpkg's backup files,
# see the comments above for details.
# Include generic snippets of statements
Include conf.d/
# Include the virtual host configurations:
Include sites-enabled/
ServerName cp.zpanel.com
Include /etc/zpanel/configs/apache/httpd.conf
/etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
/etc/apache2/sites-enabled/000-default
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/etc/zpanel/configs/apache/httpd.conf
# ZPanel Apache Include file for CentOS Linux
# Written by Bobby Allen, 15/05/2011
# Set the Zpanel Alias (used for development, sable will eventually use a VHOST)
Alias /zpanel /etc/zpanel/panel
# Setup the directory settings and PHP security flags for the Zpanel application directory.
<Directory /etc/zpanel/panel>
Options FollowSymLinks
DirectoryIndex index.php
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_admin_value upload_tmp_dir /var/zpanel/temp
</IfModule>
</Directory>
# Disallow web access to directories that don't need it/that we don't want people looking in!
<Directory /etc/zpanel/panel/cnf>
Order Deny,Allow
Deny from All
</Directory>
# Set server tokens (security??)
ServerTokens Maj
# Now we include the generic VHOST configuration file that holds all the ZPanel user hosted vhost data
Include /etc/zpanel/configs/apache/httpd-vhosts.conf
/etc/zpanel/configs/apache/httpd-vhosts.conf
################################################################
# Apache VHOST configuration file
# Automatically generated by ZPanel 10.0.1
# Generated on: 09:15 13th Dec 2012 CET
################################################################
NameVirtualHost *:80
# Configuration for ZPanel control panel.
<VirtualHost *:80>
ServerAdmin zadmin#localhost
DocumentRoot "/etc/zpanel/panel/"
ServerName cp.zpanel.com
ServerAlias *.cp.zpanel.com
AddType application/x-httpd-php .php
<Directory "/etc/zpanel/panel/">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# Custom settings are loaded below this line (if any exist)
</VirtualHost>
################################################################
# ZPanel generated VHOST configurations below.....
################################################################
# DOMAIN: new.domain.com
<virtualhost *:80>
ServerName new.domain.com
ServerAlias new.domain.com www.new.domain.com
ServerAdmin zadmin#localhost
DocumentRoot "/var/zpanel/hostdata/zadmin/public_html/new_domain_com"
php_admin_value open_basedir "/var/zpanel/hostdata/zadmin/public_html/new_domain_com:/var/zpanel/temp/"
php_admin_value suhosin.executor.func.blacklist "passthru, show_source, shell_exec, system, pcntl_exec, popen, pclose, proc_open, proc_nice, proc_terminate, proc_get_status, proc_close, leak, apache_child_$
ErrorLog "/var/zpanel/logs/domains/zadmin/new.domain.com-error.log"
CustomLog "/var/zpanel/logs/domains/zadmin/new.domain.com-access.log" combined
CustomLog "/var/zpanel/logs/domains/zadmin/new.domain.com-bandwidth.log" common
<Directory />
Options FollowSymLinks Indexes
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
AddType application/x-httpd-php .php3 .php
ScriptAlias /cgi-bin/ "/_cgi-bin/"
<location /cgi-bin>
AddHandler cgi-script .cgi .pl
Options ExecCGI -Indexes
</location>
ErrorDocument 403 /_errorpages/403.html
ErrorDocument 500 /_errorpages/500.html
ErrorDocument 404 /_errorpages/404.html
ErrorDocument 510 /_errorpages/510.html
DirectoryIndex index.html index.htm index.php index.asp index.aspx index.jsp index.jspa index.shtml index.shtm
# Custom Global Settings (if any exist)
# Custom VH settings (if any exist)
</virtualhost>
# END DOMAIN: new.domain.com
################################################################
##ETC other domains##
/etc/hosts
### Hetzner Online AG installimage
# nameserver config
# IPv4
127.0.0.1 localhost
6.8.81.52 Ubuntu-1210-quantal-64-minimal
#
# IPv6
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Check the permissions of httpd-vhosts.conf file. Maybe you don't have write permission.

Why doesn't Apache redirect my IP address to the desired location on my server?

I made a simple page /home/david/mainSite/index.html. I then added a virtual host in Apache to redirect my IP address to this page.
<VirtualHost *:80>
ServerName 74.181.105.228
DocumentRoot /home/david/mainSite
</VirtualHost>
However, when I go to 74.181.105.228after restarting Apache, I get a page with this text instead of "index.html."
Welcome to mydomain.com!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
Why does Apache redirect to the default page instead of "/home/david/mainSite/index.html"?
Here is how my "/etc/apache2/sites-available/default" file looks like.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I discovered the answer! It was tricky.
In "apache2.conf", I originally had ServerName 74.181.105.228, which makes accessing 74.181.105.228 via a browser load the default page for my server.
Changing this value in "apache2.conf" to ServerName mydomain.com solves the problem since Apache no longer directs 74.181.105.228 to the default page of my server. In turn, I can direct 74.181.105.228 to load a page from a certain directory in my file system.
My virtual host block still remains
<VirtualHost *:80>
ServerName 74.181.105.228
DocumentRoot /home/david/mainSite
</VirtualHost

CakePHP and SSL

I just installed a SSL certificate on my website that uses CakePHP and now the site doesn't load anymore files from webroot (images, css files). Any ideas? I think SSL installation affected mod_rewrite, or something like this.
I just ran into this problem. Check your sites configuration for apache2. Make sure:
AllowOverride all
is set to allow .htaccess overrides under ssl. Here is my snippet of my config (on ubuntu).
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

Resources