Name Based VHost
-
1. Accessing Shell
Open a Terminal Shell emulator window
(Press “Enter” to Execute Commands)In case first see: Terminal QuickStart Guide.
-
2. Adding Domain
Add Domain to the hosts Config File
Crating it with the nano Editor:sudo nano /etc/hosts
And append:
127.0.0.1 [myDomainName.com]
Just Replace your real Domain Name to “[myDomainName.com]” :)
Ctrl+Shift+v to Paste Content on nano
Ctrl+x to Save and Exit from nano Editor -
3. Making Directory
Create the VHost Target Directory
Running:sudo mkdir /var/www/html/[mySite]
Again Replace [mySite] in the above!
And may be also a Testing index.html:su -c 'echo "My New WebSite is Working! :)" > /var/www/html/[mySite]/index.html'
The above is just a siple Testing Content.
Last, Set the Folder’s Ownership with:sudo chown -R www-data:www-data /var/www/html/[mySite]
-
4. Making VHost Config File
Now Create a VHost Config File
Again with nano:sudo nano /etc/apache2/sites-available/[myDomainName].conf
Append at Least:
<VirtualHost *:80> ServerName[myDomainName.com] ServerAliaswww.[myDomainName.com] DocumentRoot /var/www/html/[mySite] </VirtualHost>
To get a little More Insight may look:
cat /etc/apache2/sites-available/000-default.conf
-
5. Enabling Virtual-Host
Next to Enable the New Virtual-Host
Access the Target Folder:cd /etc/apache2/sites-enabled
And make a Symlink:
sudo ln -s ../sites-available/[myDomainName].conf .
-
6. Restarting Apache
Restart Apache2 Web Server
Simply play:sudo service apache2 restart
How to Enable Apache2 mod_rewrite Module on Deepin.
Contents