Adding new website to ubuntu server
To add a new website to an Ubuntu server, you'll need to follow these steps:
Step 1: Create a new directory for the website
Create a new directory for your website in the /var/www/
directory, which is the default document root for Apache on Ubuntu. For example:
sudo mkdir /var/www/mynewwebsite
Step 2: Create the website files
Create the necessary files for your website, such as index.html
, style.css
, and script.js
, inside the new directory:
sudo nano /var/www/mynewwebsite/index.html
Add your website content to the file, then save and exit.
Step 3: Create a new Apache configuration file
Create a new configuration file for your website in the /etc/apache2/sites-available/
directory:
sudo nano /etc/apache2/sites-available/mynewwebsite.conf
Add the following content to the file:
<VirtualHost *:80>
ServerName mynewwebsite.com
DocumentRoot /var/www/mynewwebsite
</VirtualHost>
Replace mynewwebsite.com
with your website's domain name.
Step 4: Enable the new Apache configuration file
Enable the new configuration file by creating a symbolic link to the /etc/apache2/sites-enabled/
directory:
sudo ln -s /etc/apache2/sites-available/mynewwebsite.conf /etc/apache2/sites-enabled/
Step 5: Restart Apache
Restart the Apache service to apply the changes:
sudo service apache2 restart
Step 6: Configure DNS (optional)
If you want to access your website by its domain name, you'll need to configure your DNS settings. This may involve updating your domain registrar's DNS records or creating a new A record pointing to your server's IP address.
Step 7: Test your website
Open a web browser and navigate to your website's domain name or IP address to test if it's working correctly.
That's it! You should now have a new website up and running on your Ubuntu server.