3

I hope someone can help me, I am trying to set up a VPS, i have a small VPS to learn on before i use my main VPS. Ok so, I have installed Apache without any problems and when i try " sudo service httpd status ", I am told that Apache is active and running and everything is fine. but when i go to my IP in the browser, i get told that the browser can not connect, no matter what browser i use. I did a " sudo service firewalld status " and found that i did not have a firewall no such file or folder. I then did " systemctl list-units --type=service " this did not show any firewall at all. this showed up with one problem, "systemd-v...le-setup.service loaded failed failed Setup Virtual Console"

So as i am very new to all this i have no idea what i have done wrong. If anyone knows how to solve this i would be happy. I am using a MacBook Pro and Terminal to connect via SSH I have tried Reinstalling CentOs 7 and starting again but i get the exact same problems. Thank you for all help in advance.

zimbert
  • 31
  • 1
  • 1
  • 3

2 Answers2

9

CentOS 7 uses firewalld by default. You could remove this and install iptables.

However if you want to do this the firewalld way, run the following commands:

sudo firewall-cmd --add-service=http
sudo firewall-cmd --add-service=https
eKKiM
  • 1,540
  • 9
  • 23
  • Hello Thank you very much i have tried that, but it did not work. According to the status of a fresh install of my CentOs 7 it has iptables by default and firewalld is not on the system. I have tried everything i can to get this to work and i have tried every trick offered but i still can not get this to work. no matter what i try i can not get apache to show up in the browser unless i disable iptables or if i have tried with firewalld it has to be disabled to view apache test page in the browser. i have to give up as it seems i will never get this done. – zimbert Apr 15 '18 at 10:51
1

Do things from the scratch, rather than depending on the commands only.

Check if apache is running

pgrep apache

Make sure apache is listening using:

netstat -ntap | grep LISTEN | grep ":80"

If not, check system and apache logs for any errors. (e.g. SELinux settings can be a possible cause: set it to disabled in /etc/selinux/config for now)

If works, then the following may give you some clues:

iptables -nL

You might have disabled its port during installation.

Make sure you are not bound by any sort NAT or Port Forwarding at the data center side. Check with their admins.

Update #1:

This is a quick workaround:

    yum install iptables-services
    systemctl start iptables
    systemctl enable iptables
    systemctl disable firewalld
    systemctl stop firewalld
    iptables -P INPUT ACCEPT
    iptables -F
    iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT
    iptables -A INPUT -m state --state RELATED -j ACCEPT
    iptables -A INPUT -p tcp --dport 22 -j ACCEPT
    iptables -A INPUT -p tcp --dport 80 -j ACCEPT
    iptables -A INPUT -p tcp --dport 443 -j ACCEPT # if need
    # add any other port you need, like above
    iptables -P INPUT DROP
    service iptables save
MTG
  • 193
  • 6
  • HelloIt was the iptables, once i disabled them i was able to see the Apache test page on my ip without a problem, Apache is working well the problem i am having now is that i can not use iptables or firewalld with Apache no matter what i try i get Warnings and Errors. I have reinstalled and started from scratch 30 times now, i had started from scratch about 14 times before i left the message above. – zimbert Apr 08 '18 at 12:48
  • I have tried and tried to set up a VPS i tried for over 20 hours yesterday, I bought courses and read books and googled but no matter what I try I just get errors and warnings. I can get the Apache to work but i can not get either iptables or firewalld to work without errors and yes they are not both on at the same time, as i say i have tried from scratch more than 30 times now. I have checked the ports they are fine not disabled. I have had to give up as I can not find a single tutorial that works without errors. Thank you – zimbert Apr 08 '18 at 12:59
  • edited. plz check if it works for you... – MTG Apr 08 '18 at 12:59
  • Thank you for all that above but i have already tried that in a previous tutorial. the workaround i mean – zimbert Apr 08 '18 at 12:59
  • Ok So reading back i can see that i am not explaining myself very well.I will try an explain exactly what i am trying to do – zimbert Apr 08 '18 at 13:04
  • Ok so i can install CentOs 7 to the VPS no Problem and i can install and run Apache 2.4, but i have to disable iptables to be able to see the apache in the browser. I can not use either iptables or firewalld as they both throw up warnings and i get a blank page on the browser. I have read all the documentation on both iptables and firewalld and i would prefer to use firewalld but no matter what i try, and belive me i have asked a lot of questions i can not get a firewall on my VPS. more below – zimbert Apr 08 '18 at 13:10
  • So i want to set up a new user banana and a new home folder and give that user access to the home folder where there will be a subfolder called public_html i will then add a one page html website that should show up on my ip in the browser, I understand how to do most of that, but i still can not get Apache to show up if i have either iptables or firewalld installed. I will just have to take a rest from it and try again at a later date. thank you – zimbert Apr 08 '18 at 13:15
  • Well, All I can say at this point is to check what default rules/behavior get in there when you install each of them. check their policy/status/rules/zones, then find and remove the obstacle. – MTG Apr 08 '18 at 13:41