Over the last couple of days I've been learning Apache and servers in general - I installed Apache, PHP and mySQL on my Ubuntu system and accessed my website with 'localhost'. I have always thought that when you run something as localhost, nothing ever leaves your computer and your server can't be accessed by computers in your WiFi network, let alone other computers connected to the Internet. However, I got scared when in a tutorial video I watched they told to turn off your Internet connection as soon as you install Apache. Is it justified? There are no sensitive information in the database or in /var/www, it's all dummy data just for learning purposes, but I'm worried that somebody could hack into my whole system.
Keeping in mind that I've been doing this for the last few days, should I consider myself hacked?
And to make it clear, when I run my server locally and can access it through localhost, is it available to people on the Internet?