HTTPD en conflit avec d’autres virtualhost

Ceci est notre fichier httpd.conf situé dans le répertoire directAdmin des utilisateurs

# Auto generated apache config file by DirectAdmin version 1.42.1 # Modifying this file is not recommended as any changes you make will be # overwritten when the user makes any changes to his/her website # For global config changes that affect all Users, see this guide: # http://help.directadmin.com/item.php?id=2 # For local config changes that only affect one User, see this guide: # http://help.directadmin.com/item.php?id=3 # Frontpage requires these parameters in every httpd.conf file or else # it won't work. ServerRoot /etc/httpd  ServerName www.duri.ge ServerAlias www.duri.ge duri.ge Alias /media/ /home/duri/domains/duri.ge/public_html/media/ Alias /static/ /home/duri/domains/duri.ge/public_html/assets/  Order deny,allow Allow from all   Options +Includes +Indexes Order deny,allow Allow from all  WSGIScriptAlias / /home/duri/domains/duri.ge/python/sites/duri.ge/duri/wsgi-production.py WSGIDaemonProcess duri.ge user=duri group=duri python-path=/home/duri/domains/duri.ge/python/sites/duri.ge:/home/duri/domains/duri.ge/python/virtualenvs/duri_env/lib/python2.7/site-packages WSGIProcessGroup duri.ge   Order deny,allow Allow from all   ServerName www.duri.ge ServerAlias www.duri.ge duri.ge ServerAdmin [email protected] DocumentRoot /home/duri/domains/duri.ge/public_html UseCanonicalName OFF  SuexecUserGroup duri duri   RMode config RUidGid duri duri RGroups apache access  CustomLog /var/log/httpd/domains/duri.ge.bytes bytes CustomLog /var/log/httpd/domains/duri.ge.log combined ErrorLog /var/log/httpd/domains/duri.ge.error.log  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 [email protected]' php_admin_value open_basedir /home/duri/:/tmp:/var/tmp:/usr/local/lib/php/    ServerName www.mywedding.duri.ge ServerAlias www.mywedding.duri.ge mywedding.duri.ge DocumentRoot /home/duri/domains/duri.ge/public_html/mywedding ErrorLog /var/log/httpd/domains/duri.ge.mywedding.error.log CustomLog /var/log/httpd/domains/duri.ge.mywedding.bytes bytes CustomLog /var/log/httpd/domains/duri.ge.mywedding.log combined  # #Alias /media/ /home/duri/domains/duri.ge/public_html/media/ #Alias /static/ /home/duri/domains/duri.ge/public_html/assets/ # # Order deny,allow # Allow from all # # # Options +Includes +Indexes # Order deny,allow # Allow from all # #WSGIScriptAlias / /home/duri/domains/duri.ge/python/sites/duri.ge/duri/wsgi-production.py #WSGIDaemonProcess duri.ge user=duri group=duri python-path=/home/duri/domains/duri.ge/python/sites/duri.ge:/home/duri/domains/duri.ge/python/virtualenvs/duri_env/lib/python2.7/site-packages #WSGIProcessGroup duri.ge #  #  # Order deny,allow # Allow from all #  #  # ServerName www.mywedding.duri.ge # ServerAlias www.mywedding.duri.ge mywedding.duri.ge # ServerAdmin [email protected] # DocumentRoot /home/duri/domains/duri.ge/public_html/mywedding # UseCanonicalName OFF #  # SuexecUserGroup duri duri #  #  # RMode config # RUidGid duri duri # RGroups apache access #  # CustomLog /var/log/httpd/domains/duri.ge.mywedding.bytes bytes # CustomLog /var/log/httpd/domains/duri.ge.mywedding.log combined # ErrorLog /var/log/httpd/domains/duri.ge.mywedding.error.log #  # 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 [email protected]' # php_admin_value open_basedir /home/duri/:/tmp:/var/tmp:/usr/local/lib/php/ #  # # #Alias /media/ /home/duri/domains/duri.ge/public_html/media/ #Alias /static/ /home/duri/domains/duri.ge/public_html/assets/ # # Order deny,allow # Allow from all # # # Options +Includes +Indexes # Order deny,allow # Allow from all # #WSGIScriptAlias / /home/duri/domains/duri.ge/python/sites/duri.ge/duri/wsgi-production.py #WSGIDaemonProcess duri.ge user=duri group=duri python-path=/home/duri/domains/duri.ge/python/sites/duri.ge:/home/duri/domains/duri.ge/python/virtualenvs/duri_env/lib/python2.7/site-packages #WSGIProcessGroup duri.ge #  #  # Order deny,allow # Allow from all #  #  # ServerName www.test.duri.ge # ServerAlias www.test.duri.ge test.duri.ge # ServerAdmin [email protected] # DocumentRoot /home/duri/domains/duri.ge/public_html/test # UseCanonicalName OFF #  # SuexecUserGroup duri duri #  #  # RMode config # RUidGid duri duri # RGroups apache access #  # CustomLog /var/log/httpd/domains/duri.ge.test.bytes bytes # CustomLog /var/log/httpd/domains/duri.ge.test.log combined # ErrorLog /var/log/httpd/domains/duri.ge.test.error.log #  # 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 [email protected]' # php_admin_value open_basedir /home/duri/:/tmp:/var/tmp:/usr/local/lib/php/ #  # 

et ceci est httpd.conf situé dans / etc / httpd / conf

 # # This is the main Apache HTTP server configuration file. It contains the # configuration directives that give the server its instructions. # See  for detailed information. # In particular, see #  # for a discussion of each configuration directive. # # Do NOT simply read the instructions in here without understanding # what they do. They're here only as hints or reminders. If you are unsure # consult the online docs. You have been warned. ServerRoot "/etc/httpd" Listen 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 Group apache ServerAdmin admin@localhost DocumentRoot "/var/www/html" # Options and AllowOverrides Include conf/extra/httpd-directories.conf  DirectoryIndex index.html index.htm index.shtml index.php index.php5 index.php4 index.php3 index.phtml index.cgi   Order allow,deny Deny from all Satisfy All  ErrorLog /var/log/httpd/error_log LogLevel warn  #replace %b with %O for more accurate logging  LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %O" common LogFormat "%O %I" bytes LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio  CustomLog /var/log/httpd/access_log common   # Include some DirectAdmin alias Include conf/extra/httpd-alias.conf  DefaultType text/plain  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  #EnableMMAP off #EnableSendfile off ####################################################################################### # For user configurations not maintained by DirectAdmin. Empty by default. ####################################################################################### Include conf/extra/httpd-includes.conf ####################################################################################### # Do not change anything in included files, because they are rewritten by DirectAdmin # ####################################################################################### # This is needed for 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 and configuration Include conf/extra/httpd-info.conf # Virtual hosts Include conf.d/wsgi.conf # Local access to the Apache HTTP Server Manual #Include conf/extra/httpd-manual.conf # Dissortingbuted authoring and 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 # All the DirectAdmin vhosts Include conf/extra/directadmin-vhosts.conf # All suPHP directives #Include conf/extra/httpd-su[5~php.conf ####################################################################################### # End of included files that are rewritten by DirectAdmin # #######################################################################################  SSLRandomSeed startup builtin SSLRandomSeed connect builtin  # #Listen 8889 # # SocketPolicyServer On # SocketPolicyFile /var/www/html/crossdomain.xml # AdobePolicyFileServerEnabled On # #  

d’abord, il y avait un code python sur root. puis, par directAdmin, j’ai ajouté deux sous-domaines, test et mywedding pour l’utilisation avec php.

le fait est que Apache ne démarre pas si je ne commente pas ces nouvelles lignes ajoutées. Ensuite, j’ai ajouté virtualhost directement sans directAdmin.

  ServerName www.mywedding.duri.ge ServerAlias www.mywedding.duri.ge mywedding.duri.ge DocumentRoot /home/duri/domains/duri.ge/public_html/mywedding ErrorLog /var/log/httpd/domains/duri.ge.mywedding.error.log CustomLog /var/log/httpd/domains/duri.ge.mywedding.bytes bytes CustomLog /var/log/httpd/domains/duri.ge.mywedding.log combined  

cette ligne, mais le problème est que sous-domaine “mywedding.duri.ge” continue à redirect vers (pas avec http mais en interne) python.

Votre premier bloc d’hôte virtuel ne définit pas un nom de serveur, il n’a donc aucun moyen de savoir quelles requêtes le concernent et quelles requêtes sont destinées au bloc d’hôte virtuel suivant. Comme il ne peut pas discriminer, il accepte et répond à toutes les demandes. Ajoutez un ServerName différent de ServerName (et des alias) dans le deuxième bloc.

Voir la documentation ici .

Les hôtes virtuels basés sur IP utilisent l’adresse IP de la connexion pour déterminer l’hôte virtuel correct à servir. Par conséquent, vous devez disposer d’une adresse IP distincte pour chaque hôte. Avec l’hébergement virtuel basé sur le nom, le serveur s’appuie sur le client pour signaler le nom d’hôte dans le cadre des en-têtes HTTP. Grâce à cette technique, de nombreux hôtes différents peuvent partager la même adresse IP.

Ce qui suit est un exemple de vhost qui répondra différemment aux demandes faites à www.example.com par rapport à www.another.com . Espérons que cela vous permettra de trouver votre problème:

 # This line is probably in /etc/apache2/ports.conf, if it is uncommented you do # not need to repeat it. NameVirtualHost *:80  ServerName www.example.com DocumentRoot /tmp/example.com  Options FollowSymLinks AllowOverride None   Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all    ServerName www.another.com DocumentRoot /tmp/another.com  Options FollowSymLinks AllowOverride None   Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all   

J’ai mis deux fichiers, un dans /tmp/example.com/index.html et un autre dans /tmp/another.com/index.html avec un contenu différent. J’ai pu voir le contenu différent lorsque j’ai demandé les fichiers:

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

Vous devrez append ces entrées à votre fichier /etc/hosts pour pouvoir effectuer les requêtes:

 127.0.0.1 www.example.com www.another.com