I'm using php to create a built-in web server in my Mac, so I can access my webpage files and route them through a file. In order to do this, I'm using the terminal command php -S localhost:8080 routing.php.

When I'm with my Mac, I can access http://localhost:8080 and I can successfully see my application, but if I go into another machine in my network and access http://myip:8080 or http://my-Mac-adress.local:8080, I can't access my application...
So, my question is: how can I access my application with another computer in the same network?

And also, is it possible to configure apache so I don't have to start my server with php -S localhost:8080 routing.php every time I want to access it? The problem is that I'm using silex to accomplish a routing and a clean-url system, so I have to route the access to the routing.php file...

Finally, I'm sorry if I haven't explained myself clearly; I'm really a begginer with all these things of web servers.

  • which -a php are running on your Mac? I ask, because Silex depends on php5. This will effect the path of libphp.so in my answer below. – Marco M. von Hagen Jun 27 '15 at 16:07

As long as you’re telling the PHP built-in webserver to listen on localhost, it won’t be accessible remotely. Try or * instead of localhost.

Apache isn’t involved in your current setup at all, or you left that part out in your question.

Using Apache is certainly possible, typically you’d use mod_php. There are plenty of guides available on how to set it up.

Silex most likely ships with a .htaccess for use with Apache and mod_rewrite. Having it in your web application’s top level directory should ensure proper routing functionality.

| improve this answer | |

Enable Websites

Easiest way to share your Sites: Enable Web Sharing in System Preferences.

There is a build-in Apache running on your Mac.

Config your apache

To configure your Apache, you should check the files located at /etc/apache2/.

  • /etc/apache2/httpd.conf will configure the apache in general

  • /etc/apache2/users/ contain files for per-user configuration

    Inside of file yourname.conf you would add

    <IfModule mime_module>
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

To enable php on your Apache, you would need to add a file like /etc/apache2/others/php55.conf

Inside this file you will load the php-module like this

LoadModule php5_module    libexec/apache2/libphp5.so

control your apache

besides System Preferences from commandline invoke

    sudo apachectl { start | restart | stop }
| improve this answer | |

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.