LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-03-2018, 02:32 AM   #1
Dylan_Oscar
LQ Newbie
 
Registered: Nov 2017
Location: Sydney, Australia
Distribution: Ubuntu, Mint
Posts: 16

Rep: Reputation: Disabled
Access localhost from iPhone


I'm asking this here, because it does not appear to belong in the networking section. I am attempting to access the site I am creating from my iPhone. The site is on my Linux laptop, in /var/www/html/<subdirectory>/index.php
I have followed several online guides and Stack Overflow. When I type ifconfig, my inet address under wlp2s0 is 192.168.0.5
I have tried typing this address with and without http:// with a / on the end of the address, with the subdirectory containing my website on it, and Safari cannot connect to any of them. I am using Mint, so I opened the Firewall Configuration GUI program, and the firewall there is turned off.
I have examined the logs for Apache2 and firewalld and there is no evidence of an attempt to access the computer. Both devices are on the same wireless network.
What else can I try to access this?
Thanks in advance.
 
Old 02-03-2018, 04:29 AM   #2
baldur_1
Member
 
Registered: Sep 2010
Posts: 200

Rep: Reputation: 20
well, first of all, if this is from a laptop then your first check would be to make sure the site it working. opening a browser to from the laptop to http://localhost should open to the website otherwise you have a configuration issue there. my guess is you dont have it configured right so i would definitely start there.

if that is not the issue and the webpage opens fine then i would do is make sure you have the firewall down and selinux disabled. if by taking them down you get access then you know it is one of those two.

oh, also in your website configuration file, set loglevel debut inside your site directive section with custom logs...that will give you a lot more info on what is going on.

start with that and you should start down the right path.
 
Old 02-03-2018, 06:10 AM   #3
Dylan_Oscar
LQ Newbie
 
Registered: Nov 2017
Location: Sydney, Australia
Distribution: Ubuntu, Mint
Posts: 16

Original Poster
Rep: Reputation: Disabled
The site works without any problems on my laptop, the same machine the server is running from.
The firewall is turned off, at least in the GUI program Firewall Configuration, and I have disabled apparmor. I still cannot connect from my iPhone.
I have added debug as the loglevel in apache2.conf, but /var/log/apache2/apache2.log still has no entries in it. Is there anything else I can try?
 
Old 02-04-2018, 05:49 AM   #4
baldur_1
Member
 
Registered: Sep 2010
Posts: 200

Rep: Reputation: 20
okay, so if the site is being served to localhost then we know apache is configured correctly to serve and the build is not wrong. in the apache configuration file, did you allow access using like

Code:
<virtualhost *:80>
    ServerName
    ServerAlias
  <Directory "location">
    Require all granted
  </Directory>
</virtualhost>
if you have a line that is allowing only "Require localhost" then it would allow localhost and reject all else. you need to have Require all granted to allow anyone access to the website.

plus, like i said before, you should add in your configuration file site directive to set...

Code:
<virtualhost>
...
loglevel debug
errorlog "/some/location"
customlog "/some/location" combined

</virtualhost>
then visit the site with your laptop and then with the phone and put the results in here.
 
Old 02-04-2018, 06:20 AM   #5
Dylan_Oscar
LQ Newbie
 
Registered: Nov 2017
Location: Sydney, Australia
Distribution: Ubuntu, Mint
Posts: 16

Original Poster
Rep: Reputation: Disabled
I have debug loglevel. The error.log and access.log only contain references to visits from the laptop. I have also attempted visiting from my desktop with no success.
The directories /usr/share, /srv and /var/www all contain the following entries:
Code:
Options Indexes FollowSymLinks
	AllowOverride None
        Require all granted
I am able to visit the localhost on my desktop, which is running Debian, from my iPhone, but I compared the configuration files, and there appears to be no difference between them.
Is it related to the firewall? As I mentioned, this appears to be turned off, but perhaps there is another setting on this laptop that is blocking traffic?
 
Old 02-04-2018, 07:51 AM   #6
baldur_1
Member
 
Registered: Sep 2010
Posts: 200

Rep: Reputation: 20
okay, so you, a relative novice looking at the logs may say there is nothing is different than me a person with over 20 years of running an apache webserver. so if you refuse to put your logs on here, for whatever reason i dont know, if the website is being served locally and you have require all granted within the site configuration then the issue is almost certainly that the firewall OR selinux is blocking it.

now, while you are running mint, and i am not as familiar with mint, it does seem to be an offshoot of the debian/ubuntu tree so i would say this. first in a command window as su (or using sudo) do

Code:
# ufw disable
# setenforce 0
that will take down the firewall and take down selinux. then try and visit the site. if it is successful then it is simply one of the two. if it does not then you clearly have a configuration error and since you will not put any information up here i cant help you with that.

if that is it one of the two, then do

Code:
#  ufw enable
#  setenforce 1
and go to the logs, it looks like it is /var/log/audit/audit.log for selinux or /var/log/ufw for the firewall and verify which one. then take the necessary corrective action.
 
Old 02-04-2018, 08:36 AM   #7
baldur_1
Member
 
Registered: Sep 2010
Posts: 200

Rep: Reputation: 20
here is a guide you can use to understand how to control the mint firewall since it is ufw...

managing ufw
 
Old 02-04-2018, 02:06 PM   #8
Dylan_Oscar
LQ Newbie
 
Registered: Nov 2017
Location: Sydney, Australia
Distribution: Ubuntu, Mint
Posts: 16

Original Poster
Rep: Reputation: Disabled
First of all, thank you very much for your help and your patience. The reason I didn't post the logs is that they appeared to be ordered by time of entry, and the latest entry was prior to the changes I made. I will post error.log here. I have included only results after I started the machine again at 10pm last night, as I cannot post a larger amount.

error.log:

Code:
[Sun Feb 04 22:16:22.325207 2018] [mpm_prefork:notice] [pid 2060] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Sun Feb 04 22:16:22.325749 2018] [mpm_prefork:info] [pid 2060] AH00164: Server built: 2017-09-18T15:09:02
[Sun Feb 04 22:16:22.325770 2018] [core:notice] [pid 2060] AH00094: Command line: '/usr/sbin/apache2'
[Sun Feb 04 22:16:22.325778 2018] [core:debug] [pid 2060] log.c(1546): AH02639: Using SO_REUSEPORT: yes (1)
[Sun Feb 04 22:16:22.325787 2018] [mpm_prefork:debug] [pid 2060] prefork.c(1032): AH00165: Accept mutex: none (default: sysvsem)
[Sun Feb 04 22:17:24.836518 2018] [authz_core:debug] [pid 2148] mod_authz_core.c(809): [client 127.0.0.1:48516] AH01626: authorization result of Require all granted: granted
[Sun Feb 04 22:17:24.836571 2018] [authz_core:debug] [pid 2148] mod_authz_core.c(809): [client 127.0.0.1:48516] AH01626: authorization result of <RequireAny>: granted
[Sun Feb 04 22:17:24.838101 2018] [deflate:debug] [pid 2148] mod_deflate.c(853): [client 127.0.0.1:48516] AH01384: Zlib: Compressed 11321 to 3168 : URL /index.html
[Sun Feb 04 22:17:24.991769 2018] [authz_core:debug] [pid 2148] mod_authz_core.c(809): [client 127.0.0.1:48516] AH01626: authorization result of Require all granted: granted, referer: http://127.0.0.1/
[Sun Feb 04 22:17:24.991793 2018] [authz_core:debug] [pid 2148] mod_authz_core.c(809): [client 127.0.0.1:48516] AH01626: authorization result of <RequireAny>: granted, referer: http://127.0.0.1/
[Sun Feb 04 22:17:25.154846 2018] [authz_core:debug] [pid 2148] mod_authz_core.c(809): [client 127.0.0.1:48516] AH01626: authorization result of Require all granted: granted
[Sun Feb 04 22:17:25.154873 2018] [authz_core:debug] [pid 2148] mod_authz_core.c(809): [client 127.0.0.1:48516] AH01626: authorization result of <RequireAny>: granted
[Sun Feb 04 22:17:25.154902 2018] [core:info] [pid 2148] [client 127.0.0.1:48516] AH00128: File does not exist: /var/www/html/favicon.ico
[Sun Feb 04 22:17:31.145647 2018] [authz_core:debug] [pid 2154] mod_authz_core.c(809): [client 127.0.0.1:48540] AH01626: authorization result of Require all granted: granted
[Sun Feb 04 22:17:31.145696 2018] [authz_core:debug] [pid 2154] mod_authz_core.c(809): [client 127.0.0.1:48540] AH01626: authorization result of <RequireAny>: granted
[Sun Feb 04 22:17:31.146282 2018] [authz_core:debug] [pid 2154] mod_authz_core.c(809): [client 127.0.0.1:48540] AH01626: authorization result of Require all granted: granted
[Sun Feb 04 22:17:31.146304 2018] [authz_core:debug] [pid 2154] mod_authz_core.c(809): [client 127.0.0.1:48540] AH01626: authorization result of <RequireAny>: granted
[Sun Feb 04 22:17:31.153813 2018] [deflate:debug] [pid 2154] mod_deflate.c(853): [client 127.0.0.1:48540] AH01384: Zlib: Compressed 1476 to 796 : URL /codinglinguist/index.php
[Sun Feb 04 22:17:31.320555 2018] [authz_core:debug] [pid 2154] mod_authz_core.c(809): [client 127.0.0.1:48540] AH01626: authorization result of Require all granted: granted, referer: http://127.0.0.1/codinglinguist/
[Sun Feb 04 22:17:31.320584 2018] [authz_core:debug] [pid 2154] mod_authz_core.c(809): [client 127.0.0.1:48540] AH01626: authorization result of <RequireAny>: granted, referer: http://127.0.0.1/codinglinguist/
[Sun Feb 04 22:17:31.320802 2018] [authz_core:debug] [pid 2150] mod_authz_core.c(809): [client 127.0.0.1:48542] AH01626: authorization result of Require all granted: granted, referer: http://127.0.0.1/codinglinguist/
[Sun Feb 04 22:17:31.320844 2018] [authz_core:debug] [pid 2150] mod_authz_core.c(809): [client 127.0.0.1:48542] AH01626: authorization result of <RequireAny>: granted, referer: http://127.0.0.1/codinglinguist/
[Sun Feb 04 22:17:31.321180 2018] [deflate:debug] [pid 2154] mod_deflate.c(853): [client 127.0.0.1:48540] AH01384: Zlib: Compressed 642 to 281 : URL /codinglinguist/CSS/style.css, referer: http://127.0.0.1/codinglinguist/
[Sun Feb 04 22:17:31.321343 2018] [deflate:debug] [pid 2150] mod_deflate.c(853): [client 127.0.0.1:48542] AH01384: Zlib: Compressed 132 to 110 : URL /codinglinguist/JS/main.js, referer: http://127.0.0.1/codinglinguist/
[Sun Feb 04 22:17:31.322059 2018] [authz_core:debug] [pid 2159] mod_authz_core.c(809): [client 127.0.0.1:48544] AH01626: authorization result of Require all granted: granted, referer: http://127.0.0.1/codinglinguist/
[Sun Feb 04 22:17:31.322091 2018] [authz_core:debug] [pid 2159] mod_authz_core.c(809): [client 127.0.0.1:48544] AH01626: authorization result of <RequireAny>: granted, referer: http://127.0.0.1/codinglinguist/
[Sun Feb 04 22:19:21.845227 2018] [core:info] [pid 2060] AH00096: removed PID file /var/run/apache2/apache2.pid (pid=2060)
[Sun Feb 04 22:19:21.845338 2018] [mpm_prefork:notice] [pid 2060] AH00169: caught SIGTERM, shutting down
[Sun Feb 04 22:58:11.766439 2018] [mpm_prefork:notice] [pid 2653] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Sun Feb 04 22:58:11.766963 2018] [mpm_prefork:info] [pid 2653] AH00164: Server built: 2017-09-18T15:09:02
[Sun Feb 04 22:58:11.766980 2018] [core:notice] [pid 2653] AH00094: Command line: '/usr/sbin/apache2'
[Sun Feb 04 22:58:11.766986 2018] [core:debug] [pid 2653] log.c(1546): AH02639: Using SO_REUSEPORT: yes (1)
[Sun Feb 04 22:58:11.766999 2018] [mpm_prefork:debug] [pid 2653] prefork.c(1032): AH00165: Accept mutex: none (default: sysvsem)
[Sun Feb 04 23:21:15.203147 2018] [core:info] [pid 2653] AH00096: removed PID file /var/run/apache2/apache2.pid (pid=2653)
[Sun Feb 04 23:21:15.203186 2018] [mpm_prefork:notice] [pid 2653] AH00169: caught SIGTERM, shutting down
[Mon Feb 05 06:39:57.968145 2018] [mpm_prefork:notice] [pid 2135] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Mon Feb 05 06:39:57.968633 2018] [mpm_prefork:info] [pid 2135] AH00164: Server built: 2017-09-18T15:09:02
[Mon Feb 05 06:39:57.968653 2018] [core:notice] [pid 2135] AH00094: Command line: '/usr/sbin/apache2'
[Mon Feb 05 06:39:57.968662 2018] [core:debug] [pid 2135] log.c(1546): AH02639: Using SO_REUSEPORT: yes (1)
[Mon Feb 05 06:39:57.968670 2018] [mpm_prefork:debug] [pid 2135] prefork.c(1032): AH00165: Accept mutex: none (default: sysvsem)
The logs also contain error.log.1 and access.log and access.log.1, as well as other_vhosts_access.log. Are these relevant?
I have disabled firewall and apparmor. Mint does not have SELinux installed. This has not made a difference. I also saw that in my Mint configuration file there is a line,
Code:
Mutex file:${APACHE_LOCK_DIR}
default, which is commented out in the Debian file, while the Debian file contains the line,
Code:
DefaultRuntimeDir ${APACHE_RUN_DIR}
I have tried changing the Mint file to match, but this made no difference, so I changed it back again.
Please let me know if you need any more information.
 
Old 02-04-2018, 04:27 PM   #9
baldur_1
Member
 
Registered: Sep 2010
Posts: 200

Rep: Reputation: 20
okay, so what is the configuration of your network. this laptop, is it behind a router...? how are you getting the internet to the laptop and how is the internet getting to your phone and how is your phone getting to the laptop?

so, do you have a server that masquarades the network to a sub network or do you have a wifi router and both are connected via wifi to each other or the laptop is connected to the wifi and the phone is not?

the default runtime directory is the directory apache is configured to run out of. if that was messed up then it would not run properly at all and the lock dir probably is just for dav operations which would not effect here.
 
Old 02-04-2018, 04:50 PM   #10
Dylan_Oscar
LQ Newbie
 
Registered: Nov 2017
Location: Sydney, Australia
Distribution: Ubuntu, Mint
Posts: 16

Original Poster
Rep: Reputation: Disabled
I have actually just left the house. I am going away for a week. I will connect the laptop and phone to wifi this afternoon and test again. Before I left, both the laptop and phone were connected to the same wifi network, broadcast from a router. The desktop is also on the same network, but it is connected via Ethernet. Is that the difference? Could it be settings on the router?
Regarding the conf file, should I comment out the Mutex line and include the DefaultRuntimeDir line so that it matches the desktop settings?
Thanks
 
Old 02-04-2018, 08:53 PM   #11
baldur_1
Member
 
Registered: Sep 2010
Posts: 200

Rep: Reputation: 20
if you can reach the website via localhost the issue is NOT the apache configuration. if apache is putting up a website and from your logs, was working well...it is doing its job. if there is a failure then it is the phone's communication to the laptop. so, if you have them BOTH VIA WIFI (this is a must), then you get the laptops ip address and type into the browswer of the phone...

Code:
http://ipaddress.of.phone
and it should come up. if it does not come up one the SAME WIFI network served via your wifi then the ONLY thing it could be is a firewall blocking communication between since you have no selinux. that is literally it.

...but they HAVE TO BE on the same network. if you were using your phones carrier signal rather than the wifi, it would not work because the router's firewall would likely block you accessing the website from the laptop. in order for you to communicate that way you would have to forward a port from the router to the laptop which i will not go into. there also would be no domain name here for the same reason, it is communication via ip address on the same subnet.
 
Old 02-04-2018, 10:18 PM   #12
Dylan_Oscar
LQ Newbie
 
Registered: Nov 2017
Location: Sydney, Australia
Distribution: Ubuntu, Mint
Posts: 16

Original Poster
Rep: Reputation: Disabled
Both the laptop and the phone are on the same wifi network. Apparmor is stopped. I have typed ufw disable. I searched http://192.168.15.113 in the search bar from Safari on my phone, which is the IP address right now for wlp2s0 when I run ifconfig, and Safari cannot connect. This is on a different wifi network to the one I used this morning, so it is not related to the network I run at home either.
To recap:
Both devices are on the same network;
No firewall is enabled;
I can access pages on my laptop, even using the external IP address mentioned above, not just 127.0.0.1;
Safari cannot connect to the laptop.
If there is anything else I can try, let me know, otherwise I may have to simply develop for mobile on the desktop, which can connect, but it would be great if I can fix this issue. I am out of ideas.
Thanks for all your help once again.
 
Old 02-04-2018, 10:53 PM   #13
Dylan_Oscar
LQ Newbie
 
Registered: Nov 2017
Location: Sydney, Australia
Distribution: Ubuntu, Mint
Posts: 16

Original Poster
Rep: Reputation: Disabled
By the way, I have just checked, and an Android phone is also unable to connect, so it should not be an issue with my iPhone. I also tested this with another laptop on the same network, and it was also unable to connect.
I have also attempted connecting the laptop via ethernet to the same network, and it did not work then either.
This would seem to suggest that the problem is with this laptop, however the firewall is down, SELinux is not installed, and apparmor is off, so I'm really not sure what else the problem might be.
 
Old 02-05-2018, 05:38 AM   #14
baldur_1
Member
 
Registered: Sep 2010
Posts: 200

Rep: Reputation: 20
okay, so it is this simple, something is interrupting communication between the phone and the laptop. it is clearly on the laptop side. the tools you are going to need are all available but you are going to have to figure this out.

i would start by getting a command line program for your phone or using another computer and ping the other laptop. if the pings are accepted then basic icmp communication exists buy my guess is it will not. if it does not, it is 100% ONLY a firewall blocking you.

if it does go through then you need a port scanner. you are going to use that to scan the ports of the laptop. it will tell you which ones are open. my guess is none will be. for a http server, you need port 80 open. if none are open, it is 100% a firewall blocking you.

then you need to go through your logs and see if that will tell you the program name or what. i would start with /var/log/messages. that is the default log for dumping location for firewalls. go to your phone and put in the address and try and hit your laptop like 10 times in a row then go to the logs and you should be looking for a group of lines now which is easier to spot that show the hit but it was dropped.
 
Old 02-05-2018, 06:11 AM   #15
Dylan_Oscar
LQ Newbie
 
Registered: Nov 2017
Location: Sydney, Australia
Distribution: Ubuntu, Mint
Posts: 16

Original Poster
Rep: Reputation: Disabled
Thanks for that advice. I will need my desktop to do that, so I will have to wait till next week, but that sounds promising.
I will make an update here when I have tried those steps.
 
  


Reply

Tags
iphone, localhost


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to access iPhone -- Unhandled Lockdown error (-16) ?? nixtr Linux - Newbie 13 03-22-2017 09:17 AM
Changed my root user access for mysql access to Any from localhost SSBN Linux - Server 2 03-14-2011 02:25 PM
How to access localhost ...... thomas2004ch Linux - Newbie 3 10-20-2009 09:06 AM
cannot access localhost Rick809 Linux - Networking 3 08-02-2006 11:27 AM
Not getting Localhost access for CUPS JaseP Linux - Networking 3 12-16-2002 12:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration