M HYPE SPLASH
// news

Change apache port number on virtual host configuration file

By Abigail Rogers

I am trying to change the port number on which apache runs on Ubuntu 20.04.I have configured docker to run on port 80.So I am trying to make apache run on port 8081.I have followed this tuitorial and managed to change the port on the Apache server configuration file.But when I try to change it on the virtual host configuration file with sudo vi /etc/apache2/sites-enabled/000-default.confI cant since the file is not editable. When I open it via GUI I can edit the port but I can not save the changes. Been stuck on this for a while. I will appreciate any help

1

1 Answer

This is because /etc/apache2/sites-available/ files are only editable by sudoer users (regarding security issues which may happen). From the terminal, you can run sudo nano /etc/apache2/sites-available/000-default.conf and you will be able to save the file with ctrl + s.

On the other hand, it is not quite recommended to edit the same 000-default.conf file and keep it as the one running for apache, as it can be used later as a template for other virtual hosts. So what I recommend you is copying this file to a file called domain.conf (replacing domain for your actual domain) with sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/domain.conf and configuring this .conf vhost instead of the default one.

Also remember to enable the site once created with the command sudo a2ensite domain.conf. It is also important to execute this command being on the path in which de .conf is, so first run cd /etc/apache2/sites-available/ and then enable the site with sudo a2ensite domain.conf.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy