Author Topic: Create httpd template to automatically add admin subdomain  (Read 2259 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
I want to create a httpd template that automatically add a "admin" subdomain and want that the SSL create the certificates to the main domain and to the subdomain.

I'm working with Yii2 framework for website development and I have the code separated in 2 folders frontend and backend, I want to install the website with a domain like example.com and use a template to automatically create the admin.example.com that will point to the backend folder.

I already have a template for this type of structure but usualy I access like example.com/backend but this client want to use admin.example.com, how can I manage to do that. This website will required to have ssl from Let's Encrypt.

This is my current template without the admin subdomain
Code: [Select]
<VirtualHost %ip%:%apache_port%>
ServerName %domain_idn%
%domain_aliases%
ServerAdmin webmaster@%domain%
DocumentRoot %docroot%/frontend/web
UseCanonicalName Off
ScriptAlias /cgi-bin/ %docroot%/cgi-bin/
    Alias /backend/ %docroot%/backend/web/

CustomLog /usr/local/apache/domlogs/%domain%.bytes bytes
CustomLog /usr/local/apache/domlogs/%domain%.log combined
ErrorLog /usr/local/apache/domlogs/%domain%.error.log

# Custom settings are loaded below this line (if any exist)
# IncludeOptional "/usr/local/apache/conf/userdata/%user%/%domain%/*.conf"

<IfModule mod_setenvif.c>
SetEnvIf X-Forwarded-Proto "^https$" HTTPS=on
</IfModule>

<IfModule mod_userdir.c>
UserDir disabled
UserDir enabled %user%
</IfModule>

<IfModule mod_suexec.c>
SuexecUserGroup %user% %group%
</IfModule>

<IfModule mod_suphp.c>
suPHP_UserGroup %user% %group%
suPHP_ConfigPath %home%/%user%
</IfModule>

<IfModule mod_ruid2.c>
RMode config
RUidGid %user% %group%
</IfModule>

<IfModule itk.c>
AssignUserID %user% %group%
</IfModule>

<Directory "%docroot%/frontend/web">
Options -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
</Directory>
    <Directory "%docroot%/backend/web">
Options -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
</Directory>

</VirtualHost>