问题
I need to create subdomains on a web server with apache 2.0, CentOS 6.4, PageSpeed + Apc. I have no DNS server. I need to use VirtualHost. My code:
NameVirtualHost xx.xx.xx.xx
<VirtualHost xx.xx.xx.xx>
ServerName www.sub.domain.com
ServerAlias sub.domain.com
DocumentRoot /var/www/html/sub
</VirtualHost>
<VirtualHost xx.xx.xx.xx>
ServerName www.domain.com
ServerAlias domain.com
DocumentRoot /var/www/html
</VirtualHost>
I have put this code in: /etc/httpd/conf.d/somename.conf
and it does not work.
Also in: httpd.conf
, does not work.
回答1:
I'm doing the following:
<VirtualHost *:80>
DocumentRoot "/storage/www/domain.com"
ServerName domain.com
ServerAlias www.domain.com
CustomLog /var/log/httpd/access_domain.com_log combined
ErrorLog /var/log/httpd/error_domain.com_log
</VirtualHost>
回答2:
To me it looks like this
<Directory /var/www/xxxxx/data/www/domain.com>
Options -Includes +ExecCGI
php_admin_value open_basedir "/var/www/xxxxxxxxx/data:."
php_admin_flag engine on
</Directory>
<VirtualHost 155.155.255.152:80 >
ServerName domain.com
CustomLog /dev/null combined
DocumentRoot /var/www/xxxxxxxxx/data/www/domain.com
ErrorLog /dev/null
ServerAdmin webmaster@domain.com
ServerAlias www.domain.com
SuexecUserGroup xxxxxxxxx xxxxxxxxx
ScriptAlias /cgi-bin/ /var/www/xxxxxxxxx/data/www/domain.com/cgi-bin/
AddType application/x-httpd-php .php .php3 .php4 .php5 .phtml
AddType application/x-httpd-php-source .phps
php_admin_value open_basedir "/var/www/xxxxxxxxx/data:."
php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f webmaster@domain.com"
php_admin_value upload_tmp_dir "/var/www/xxxxxxxxx/data/mod-tmp"
php_admin_value session.save_path "/var/www/xxxxxxxxx/data/mod-tmp"
</VirtualHost>
<VirtualHost 155.155.255.152:443 >
SSLCertificateFile /var/www/httpd-cert/xxxxxxxxx/domain.crt
SSLCertificateKeyFile /var/www/httpd-cert/xxxxxxxxx/domain.key
SSLEngine on
ServerName domain.com
CustomLog /dev/null combined
DocumentRoot /var/www/xxxxxxxxx/data/www/domain.com
ErrorLog /dev/null
ServerAdmin webmaster@domain.com
ServerAlias www.domain.com
SuexecUserGroup xxxxxxxxx xxxxxxxxx
ScriptAlias /cgi-bin/ /var/www/xxxxxxxxx/data/www/domain.com/cgi-bin/
AddType application/x-httpd-php .php .php3 .php4 .php5 .phtml
AddType application/x-httpd-php-source .phps
php_admin_value open_basedir "/var/www/xxxxxxxxx/data:."
php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f webmaster@domain.com"
php_admin_value upload_tmp_dir "/var/www/xxxxxxxxx/data/mod-tmp"
php_admin_value session.save_path "/var/www/xxxxxxxxx/data/mod-tmp"
</VirtualHost>
来源:https://stackoverflow.com/questions/16843925/creating-subdomain-in-virtualhost-in-apache-2-0-on-centos-6-4