I'm currently using LAMP (MySQl + PhP + PhpMyAdmin) for web development class, but I'm kinda scared that someone could access to my data trough it.

How can i ensure that my server isn't available to the public? i want it only for me, i don't want to share it over the net or the Internet.

I'm currently using Ubuntu 14.04.5

I'm using Apache 2.4, PHP5.


Will you only be accessing it locally via the localhost address?

You could use iptables firewall to allow only outgoing connections from your computer (and incoming traffic related to that):

iptables -I OUTPUT -o eth0 -d -j ACCEPT
iptables -I INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

where eth0 would be your network interface (could be wlan0 in case you're using a wireless, check with ifconfig).

| improve this answer | |

You can simply deny except your local network and localhost

sudo vi /etc/apache2/apache2.conf

In there you need to add/change

<Directory /var/www/html/>
  Order allow,deny
  Allow from 127


Everything else will be denied by default.

After you changed the file you need to restart apache

sudo service apache2 restart

| improve this answer | |
  • Will it work if I do it in etc/apache2/apache2 conf? The path you specified you take me to a blank file – IutbaZion Sep 28 '16 at 8:50
  • Yes of course, that is the conf file, sorry. I changed my answer. – Kev Inski Sep 28 '16 at 8:55
  • Thanks mate I will add those lines in the morning and I will come back as soon as I can to give you feedback about it – IutbaZion Sep 28 '16 at 8:56
  • But it only restricts the access to your apache webserver not to your database. Maybe it would be better to use iptable to restrict the access to the whole system, as @mr_mezz pointed out! – Kev Inski Sep 28 '16 at 8:57
  • But AFAIK mysql remote access is disabled by default, plus I don't know how to configure iptables – IutbaZion Sep 28 '16 at 8:58

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.