Thursday, 15 August 2013

apache - HTTPD conflict with other virtualhost -



apache - HTTPD conflict with other virtualhost -

this our httpd.conf file located in users directadmin directory

# auto generated apache config file directadmin version 1.42.1 # modifying file not recommended changes create # overwritten when user makes changes his/her website # global config changes impact users, see guide: # http://help.directadmin.com/item.php?id=2 # local config changes impact 1 user, see guide: # http://help.directadmin.com/item.php?id=3 # frontpage requires these parameters in every httpd.conf file or else # won't work. serverroot /etc/httpd <virtualhost 91.239.206.147:80 > servername www.tavaduri.ge serveralias www.tavaduri.ge tavaduri.ge alias /media/ /home/tavaduri/domains/tavaduri.ge/public_html/media/ alias /static/ /home/tavaduri/domains/tavaduri.ge/public_html/assets/ <directory /home/tavaduri/domains/tavaduri.ge/public_html/assets> order deny,allow allow </directory> <directory /home/tavaduri/domains/tavaduri.ge/public_html/media> options +includes +indexes order deny,allow allow </directory> wsgiscriptalias / /home/tavaduri/domains/tavaduri.ge/python/sites/tavaduri.ge/tavaduri/wsgi-production.py wsgidaemonprocess tavaduri.ge user=tavaduri group=tavaduri python-path=/home/tavaduri/domains/tavaduri.ge/python/sites/tavaduri.ge:/home/tavaduri/domains/tavaduri.ge/python/virtualenvs/tavaduri_env/lib/python2.7/site-packages wsgiprocessgroup tavaduri.ge <directory /home/tavaduri/domains/tavaduri.ge/python/sites/tavaduri.ge/tavaduri> <files wsgi-production.py> order deny,allow allow </files> </directory> servername www.tavaduri.ge serveralias www.tavaduri.ge tavaduri.ge serveradmin webmaster@tavaduri.ge documentroot /home/tavaduri/domains/tavaduri.ge/public_html usecanonicalname off <ifmodule !mod_ruid2.c> suexecusergroup tavaduri tavaduri </ifmodule> <ifmodule mod_ruid2.c> rmode config ruidgid tavaduri tavaduri rgroups apache access </ifmodule> customlog /var/log/httpd/domains/tavaduri.ge.bytes bytes customlog /var/log/httpd/domains/tavaduri.ge.log combined errorlog /var/log/httpd/domains/tavaduri.ge.error.log <directory /home/tavaduri/domains/tavaduri.ge/public_html> options +includes -indexes php_admin_flag safe_mode off php_admin_flag engine off php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f tavaduri@tavaduri.ge' php_admin_value open_basedir /home/tavaduri/:/tmp:/var/tmp:/usr/local/lib/php/ </directory> </virtualhost> <virtualhost 91.239.206.147:80> servername www.mywedding.tavaduri.ge serveralias www.mywedding.tavaduri.ge mywedding.tavaduri.ge documentroot /home/tavaduri/domains/tavaduri.ge/public_html/mywedding errorlog /var/log/httpd/domains/tavaduri.ge.mywedding.error.log customlog /var/log/httpd/domains/tavaduri.ge.mywedding.bytes bytes customlog /var/log/httpd/domains/tavaduri.ge.mywedding.log combined </virtualhost> #<virtualhost 91.239.206.147:80 > #alias /media/ /home/tavaduri/domains/tavaduri.ge/public_html/media/ #alias /static/ /home/tavaduri/domains/tavaduri.ge/public_html/assets/ #<directory /home/tavaduri/domains/tavaduri.ge/public_html/assets> # order deny,allow # allow #</directory> #<directory /home/tavaduri/domains/tavaduri.ge/public_html/media> # options +includes +indexes # order deny,allow # allow #</directory> #wsgiscriptalias / /home/tavaduri/domains/tavaduri.ge/python/sites/tavaduri.ge/tavaduri/wsgi-production.py #wsgidaemonprocess tavaduri.ge user=tavaduri group=tavaduri python-path=/home/tavaduri/domains/tavaduri.ge/python/sites/tavaduri.ge:/home/tavaduri/domains/tavaduri.ge/python/virtualenvs/tavaduri_env/lib/python2.7/site-packages #wsgiprocessgroup tavaduri.ge # <directory /home/tavaduri/domains/tavaduri.ge/python/sites/tavaduri.ge/tavaduri> # <files wsgi-production.py> # order deny,allow # allow # </files> # </directory> # servername www.mywedding.tavaduri.ge # serveralias www.mywedding.tavaduri.ge mywedding.tavaduri.ge # serveradmin webmaster@tavaduri.ge # documentroot /home/tavaduri/domains/tavaduri.ge/public_html/mywedding # usecanonicalname off # <ifmodule !mod_ruid2.c> # suexecusergroup tavaduri tavaduri # </ifmodule> # <ifmodule mod_ruid2.c> # rmode config # ruidgid tavaduri tavaduri # rgroups apache access # </ifmodule> # customlog /var/log/httpd/domains/tavaduri.ge.mywedding.bytes bytes # customlog /var/log/httpd/domains/tavaduri.ge.mywedding.log combined # errorlog /var/log/httpd/domains/tavaduri.ge.mywedding.error.log # <directory /home/tavaduri/domains/tavaduri.ge/public_html/mywedding> # options +includes -indexes # php_admin_flag safe_mode off # php_admin_flag engine off # php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f tavaduri@tavaduri.ge' # php_admin_value open_basedir /home/tavaduri/:/tmp:/var/tmp:/usr/local/lib/php/ # </directory> #</virtualhost> #<virtualhost 91.239.206.147:80 > #alias /media/ /home/tavaduri/domains/tavaduri.ge/public_html/media/ #alias /static/ /home/tavaduri/domains/tavaduri.ge/public_html/assets/ #<directory /home/tavaduri/domains/tavaduri.ge/public_html/assets> # order deny,allow # allow #</directory> #<directory /home/tavaduri/domains/tavaduri.ge/public_html/media> # options +includes +indexes # order deny,allow # allow #</directory> #wsgiscriptalias / /home/tavaduri/domains/tavaduri.ge/python/sites/tavaduri.ge/tavaduri/wsgi-production.py #wsgidaemonprocess tavaduri.ge user=tavaduri group=tavaduri python-path=/home/tavaduri/domains/tavaduri.ge/python/sites/tavaduri.ge:/home/tavaduri/domains/tavaduri.ge/python/virtualenvs/tavaduri_env/lib/python2.7/site-packages #wsgiprocessgroup tavaduri.ge # <directory /home/tavaduri/domains/tavaduri.ge/python/sites/tavaduri.ge/tavaduri> # <files wsgi-production.py> # order deny,allow # allow # </files> # </directory> # servername www.test.tavaduri.ge # serveralias www.test.tavaduri.ge test.tavaduri.ge # serveradmin webmaster@tavaduri.ge # documentroot /home/tavaduri/domains/tavaduri.ge/public_html/test # usecanonicalname off # <ifmodule !mod_ruid2.c> # suexecusergroup tavaduri tavaduri # </ifmodule> # <ifmodule mod_ruid2.c> # rmode config # ruidgid tavaduri tavaduri # rgroups apache access # </ifmodule> # customlog /var/log/httpd/domains/tavaduri.ge.test.bytes bytes # customlog /var/log/httpd/domains/tavaduri.ge.test.log combined # errorlog /var/log/httpd/domains/tavaduri.ge.test.error.log # <directory /home/tavaduri/domains/tavaduri.ge/public_html/test> # options +includes -indexes # # php_admin_flag safe_mode off # # php_admin_flag engine off # php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f tavaduri@tavaduri.ge' # php_admin_value open_basedir /home/tavaduri/:/tmp:/var/tmp:/usr/local/lib/php/ # </directory> #</virtualhost>

and httpd.conf located in /etc/httpd/conf

# # main apache http server configuration file. contains # configuration directives give server instructions. # see <url:http://httpd.apache.org/docs/2.2> detailed information. # in particular, see # <url:http://httpd.apache.org/docs/2.2/mod/directives.html> # give-and-take of each configuration directive. # # not read instructions in here without understanding # do. they're here hints or reminders. if unsure # consult online docs. have been warned. serverroot "/etc/httpd" hear 80 #loadmodule dummy_module /usr/lib/apache/mod_dummy.so #loadmodule php5_module /usr/lib/apache/libphp5.so loadmodule ruid2_module /usr/lib/apache/mod_ruid2.so include /etc/httpd/conf/extra/httpd-phpmodules.conf #loadmodule socketpolicyserver /usr/lib/apache/mod_socket_policy_server.so #loadmodule socket_policy_server_module /usr/lib/apache/mod_socket_policy_server.so loadmodule wsgi_module /usr/lib/apache/mod_wsgi.so user apache grouping apache serveradmin admin@localhost documentroot "/var/www/html" # options , allowoverrides include conf/extra/httpd-directories.conf <ifmodule dir_module> directoryindex index.html index.htm index.shtml index.php index.php5 index.php4 index.php3 index.phtml index.cgi </ifmodule> <filesmatch "^\.ht"> order allow,deny deny satisfy </filesmatch> errorlog /var/log/httpd/error_log loglevel warn <ifmodule log_config_module> #replace %b %o more accurate logging <ifmodule mod_logio.c> logformat "%h %l %u %t \"%r\" %>s %o \"%{referer}i\" \"%{user-agent}i\"" combined logformat "%h %l %u %t \"%r\" %>s %o" mutual logformat "%o %i" bytes logformat "%h %l %u %t \"%r\" %>s %b \"%{referer}i\" \"%{user-agent}i\" %i %o" combinedio </ifmodule> customlog /var/log/httpd/access_log mutual </ifmodule> <ifmodule alias_module> # include directadmin alias include conf/extra/httpd-alias.conf </ifmodule> defaulttype text/plain <ifmodule mime_module> typesconfig conf/mime.types addtype application/x-gzip .tgz addencoding x-compress .z addencoding x-gzip .gz .tgz addtype application/x-compress .z addtype application/x-gzip .gz .tgz addhandler cgi-script .cgi addhandler type-map var addtype text/html .shtml addoutputfilter includes .shtml addtype video/x-ms-asf .avi addtype video/mpeg .mpg addtype video/mpeg .mpeg addtype video/quicktime .mov addtype video/x-ms-wmv .wmv </ifmodule> #enablemmap off #enablesendfile off ####################################################################################### # user configurations not maintained directadmin. empty default. ####################################################################################### include conf/extra/httpd-includes.conf ####################################################################################### # not alter in included files, because rewritten directadmin # ####################################################################################### # needed php include conf/extra/httpd-php-handlers.conf # server-pool management (mpm specific) include conf/extra/httpd-mpm.conf # multi-language error messages include conf/extra/httpd-multilang-errordoc.conf # fancy directory listings include conf/extra/httpd-autoindex.conf # language settings include conf/extra/httpd-languages.conf # user home directories #include conf/extra/httpd-userdir.conf # real-time info on requests , configuration include conf/extra/httpd-info.conf # virtual hosts include conf.d/wsgi.conf # local access apache http server manual #include conf/extra/httpd-manual.conf # distributed authoring , versioning (webdav) include conf/extra/httpd-dav.conf # various default settings include conf/extra/httpd-default.conf # secure (ssl/tls) connections #include conf/extra/httpd-ssl.conf # deflate module settings include conf/extra/httpd-deflate.conf # directadmin vhosts include conf/extra/directadmin-vhosts.conf # suphp directives #include conf/extra/httpd-su[5~php.conf ####################################################################################### # end of included files rewritten directadmin # ####################################################################################### <ifmodule ssl_module> sslrandomseed startup builtin sslrandomseed connect builtin </ifmodule> #<ifmodule mod_socket_policy_server.c> #listen 8889 #<virtualhost *:8889> # socketpolicyserver on # socketpolicyfile /var/www/html/crossdomain.xml # adobepolicyfileserverenabled on #</virtualhost> # </ifmodule>

first there python code on root. through directadmin added 2 subdomains, test , mywedding using php.

the thing apache wont start if don't comment newly added lines. added virtualhost straight without directadmin.

<virtualhost 91.239.206.147:80> servername www.mywedding.tavaduri.ge serveralias www.mywedding.tavaduri.ge mywedding.tavaduri.ge documentroot /home/tavaduri/domains/tavaduri.ge/public_html/mywedding errorlog /var/log/httpd/domains/tavaduri.ge.mywedding.error.log customlog /var/log/httpd/domains/tavaduri.ge.mywedding.bytes bytes customlog /var/log/httpd/domains/tavaduri.ge.mywedding.log combined </virtualhost>

this lines, problem subdomain "mywedding.tavaduri.ge" keeps redirecting (not http internally) python.

your first virtual host block not define servername has no way know requests it, , requests next virtual host block. since cannot discriminate, accepts , responds requests. add together servername different servername (and aliases) in sec block.

see documentation here.

ip-based virtual hosts utilize ip address of connection determine right virtual host serve. hence need have separate ip address each host. name-based virtual hosting, server relies on client study hostname part of http headers. using technique, many different hosts can share same ip address.

what follows illustration vhost respond differently requests made www.example.com compared www.another.com. can find issue:

# line in /etc/apache2/ports.conf, if uncommented # not need repeat it. namevirtualhost *:80 <virtualhost *:80> servername www.example.com documentroot /tmp/example.com <directory /> options followsymlinks allowoverride none </directory> <directory /tmp/example.com> options indexes followsymlinks multiviews allowoverride none order allow,deny allow </directory> </virtualhost> <virtualhost *:80> servername www.another.com documentroot /tmp/another.com <directory /> options followsymlinks allowoverride none </directory> <directory /tmp/another.com> options indexes followsymlinks multiviews allowoverride none order allow,deny allow </directory> </virtualhost>

i set 2 files, 1 in /tmp/example.com/index.html, , in /tmp/another.com/index.html different content. able see different content when requested files:

$ curl http://www.another.com/index.html $ curl http://www.example.com/index.html illustration

you need add together entries /etc/hosts file able create requests:

127.0.0.1 www.example.com www.another.com

apache centos httpd.conf directadmin

No comments:

Post a Comment