First you need to install the Apache server in your server.
Then navigate to /var/www folder and create
sudo mkdir -p /var/www/example.com/
This will create a folder for our site example.com. Next we have to grant the permission to created folder.
sudo chown -R $USER:$USER /var/www/example.com/
sudo chmod -R 755 /var/www
Then we need to put our website files in that created example.com folder. After that we need to create a configuration file for that.
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
Inside the cofiguration file we need to create something like this.
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Some of the parts may already created so you don't need to create everything. Just make sure you will have a configuration file like this.
To enable the created configuration file you need to enter following command.
sudo a2ensite example.com.conf
After that you need to enter this command to activate.
sudo service apache2 restart
No comments:
Post a Comment