Workaround for Mac to open Apach but cannot access localhost

Source: Internet
Author: User

Y because the Mac system comes with PHP and Apach by default,

So you can start the Apach service directly with sudo apachectl start,

At this time in the browser input http://localhost , will appear it works!, that Apach open success.

However things didn't go so well when I followed the steps as above and entered Apach after the Google browser opened,

It's the following!

Troubleshoot the problem:

1. I checked the port take-up situation:

Use Lsof (list open files) under Mac to view port occupancy, lsof is a tool that lists open files for the current system.

Using Lsof lists all the ports that are occupied:

$ lsof

Use less to display pagination, such as:

$ leof | Less

You can also use-I to see if a port is occupied, such as:

$ leof-i:8080

If the port is occupied, the relevant information is returned and no information is returned if it is not occupied.

2, directly with Nginx instead of Apach

First I close Apach

$ sudo appachectl-s stop

Turn on Apachsudo apachectl stop

and started the Nginx.

$ sudo nginx

Find out or can't open localhost

Close Nginx

$ sudo nginx-s stop

  

Finally found in Safari browser input localhost can actually open!

Only found that the original Google browser opened the agent, the agent can be closed.

Mac os php www folder/library/webserver/documents/

Detailed Configuration link: https://www.jianshu.com/p/2fb9a3bb12f6

Workaround for Mac to open Apach but cannot access localhost

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.