114 | | We are going to install moodle under lms subdomain. For other two domains we will create dummy web pages for each. |
| 112 | For the web subdomain we will later create dummy a web site with just a single web page. In the wp subdomain we will install wordpress which is a content management system. We are going to install moodle as well under the lms subdomain. |
| 113 | |
| 114 | Now we are done with creating web site directories. Now we need to do the actual apache server configurations for the virtual hosting. |
| 115 | |
| 116 | On Ubuntu systems, Apache Virtual Hosts configuration files are located in /etc/apache2/sites-available directory. They can be enabled by creating symbolic links to the /etc/apache2/sites-enabled directory, which Apache read during the startup. Here we need to create a seperate configuration file for each domain/sub-domain as below. |
| 117 | |
| 118 | {{{ |
| 119 | sudo nano /etc/apache2/sites-available/web.your_domain.com.conf |
| 120 | }}} |
| 121 | |
| 122 | And add the below configurations, |
| 123 | |
| 124 | {{{ |
| 125 | <VirtualHost *:80> |
| 126 | ServerName web.dhammikalalantha.com |
| 127 | ServerAlias web.dhammikalalantha.com |
| 128 | ServerAdmin webmaster@dhammikalalantha.com |
| 129 | DocumentRoot /var/www/web.dhammikalalantha.com/public_html |
| 130 | |
| 131 | <Directory /var/www/web.dhammikalalantha.com/public_html> |
| 132 | Options -Indexes +FollowSymLinks |
| 133 | AllowOverride All |
| 134 | </Directory> |
| 135 | |
| 136 | ErrorLog ${APACHE_LOG_DIR}/web.dhammikalalantha.com-error.log |
| 137 | CustomLog ${APACHE_LOG_DIR}/web.dhammikalalantha.com-access.log combined |
| 138 | </VirtualHost> |
| 139 | }}} |
| 140 | |
| 141 | Similarly do the necessary configurations for the domain sales. |
| 142 | |
| 143 | {{{ |
| 144 | sudo nano /etc/apache2/sites-available/sales.your_domain.com.conf |
| 145 | }}} |
| 146 | |
| 147 | {{{ |
| 148 | <VirtualHost *:80> |
| 149 | ServerName sales.dhammikalalantha.com |
| 150 | ServerAlias sales.dhammikalalantha.com |
| 151 | ServerAdmin webmaster@sales.dhammikalalantha.com |
| 152 | DocumentRoot /var/www/sales.dhammikalalantha.com/public_html |
| 153 | |
| 154 | <Directory /var/www/sales.dhammikalalantha.com/public_html> |
| 155 | Options -Indexes +FollowSymLinks |
| 156 | AllowOverride All |
| 157 | </Directory> |
| 158 | |
| 159 | ErrorLog ${APACHE_LOG_DIR}/sales.dhammikalalantha.com-error.log |
| 160 | CustomLog ${APACHE_LOG_DIR}/sales.dhammikalalantha.com-access.log combined |
| 161 | </VirtualHost> |
| 162 | }}} |
| 163 | |
| 164 | Once we do the configurations we have to enable the created sites as below, |
| 165 | |
| 166 | {{{ |
| 167 | sudo a2ensite web.dhammikalalantha.com |
| 168 | sudo a2ensite sales.dhammikalalantha.com |
| 169 | }}} |
| 170 | |
| 171 | Once done, test the configuration for any syntax errors with. |
| 172 | {{{ |
| 173 | sudo apachectl configtest |
| 174 | }}} |
| 175 | |
| 176 | Restart the Apache service for the changes to take effect. |
| 177 | {{{ |
| 178 | sudo systemctl restart apache2 |
| 179 | }}} |
| 180 | |
| 181 | Now we are done with configurations of apache virtual hosting. |
141 | | Now we are done with creating web sites and directories. Now we need to do the actual apache server configurations for the virtual hosting. |
142 | | |
143 | | On Ubuntu systems, Apache Virtual Hosts configuration files are located in /etc/apache2/sites-available directory. They can be enabled by creating symbolic links to the /etc/apache2/sites-enabled directory, which Apache read during the startup. Here we need to create a seperate configuration file for each domain/sub-domain as below. |
144 | | |
145 | | {{{ |
146 | | sudo nano /etc/apache2/sites-available/web.your_domain.com.conf |
147 | | }}} |
148 | | |
149 | | And add the below configurations, |
150 | | |
151 | | {{{ |
152 | | <VirtualHost *:80> |
153 | | ServerName web.dhammikalalantha.com |
154 | | ServerAlias web.dhammikalalantha.com |
155 | | ServerAdmin webmaster@dhammikalalantha.com |
156 | | DocumentRoot /var/www/web.dhammikalalantha.com/public_html |
157 | | |
158 | | <Directory /var/www/web.dhammikalalantha.com/public_html> |
159 | | Options -Indexes +FollowSymLinks |
160 | | AllowOverride All |
161 | | </Directory> |
162 | | |
163 | | ErrorLog ${APACHE_LOG_DIR}/web.dhammikalalantha.com-error.log |
164 | | CustomLog ${APACHE_LOG_DIR}/web.dhammikalalantha.com-access.log combined |
165 | | </VirtualHost> |
166 | | }}} |
167 | | |
168 | | Similarly do the necessary configurations for the domain sales. |
169 | | |
170 | | {{{ |
171 | | sudo nano /etc/apache2/sites-available/sales.your_domain.com.conf |
172 | | }}} |
173 | | |
174 | | {{{ |
175 | | <VirtualHost *:80> |
176 | | ServerName sales.dhammikalalantha.com |
177 | | ServerAlias sales.dhammikalalantha.com |
178 | | ServerAdmin webmaster@sales.dhammikalalantha.com |
179 | | DocumentRoot /var/www/sales.dhammikalalantha.com/public_html |
180 | | |
181 | | <Directory /var/www/sales.dhammikalalantha.com/public_html> |
182 | | Options -Indexes +FollowSymLinks |
183 | | AllowOverride All |
184 | | </Directory> |
185 | | |
186 | | ErrorLog ${APACHE_LOG_DIR}/sales.dhammikalalantha.com-error.log |
187 | | CustomLog ${APACHE_LOG_DIR}/sales.dhammikalalantha.com-access.log combined |
188 | | </VirtualHost> |
189 | | }}} |
190 | | |
191 | | Once we do the configurations we have to enable the created sites as below, |
192 | | |
193 | | {{{ |
194 | | sudo a2ensite web.dhammikalalantha.com |
195 | | sudo a2ensite sales.dhammikalalantha.com |
196 | | }}} |
197 | | |
198 | | Once done, test the configuration for any syntax errors with. |
199 | | {{{ |
200 | | sudo apachectl configtest |
201 | | }}} |
202 | | |
203 | | Restart the Apache service for the changes to take effect. |
204 | | {{{ |
205 | | sudo systemctl restart apache2 |
206 | | }}} |
207 | | |