0

I am setting up a local environment with php and an Apache server on my macOs High Sierra 10.13. Strangely, my Apache server won't read php files despite following various tutorials on how to set it up.

I have been installing php 7 with homebrew.

When I run php -S localhost:8000 I get the following info:

PHP 7.1.7 Development Server started at Wed Oct 11 18:47:39 2017
Listening on http://localhost:8000
Document root is /Users/username/Sites
Press Ctrl-C to quit.

So I guess my php version is correctly installed with my local server. apachectl configtest gives me:

Syntax ok

and httpd -v

Server version: Apache/2.4.27 (Unix)
Server built:   Jul 15 2017 15:41:46

Can someone here help me??

Tripduc
  • 31
  • 1
  • 11
  • Apache needs a module or program installed to use PHP. Typically `mod_php` or `FastCGI`. For local usage on your mac I'd recommend installing `MAMP` which does all this for you. – Cfreak Oct 11 '17 at 16:57
  • Thanks for the answer. I don't really want to use MAMP bc I want to understand the logic behind what I do... I guess then I would need to uncomment a LoadModule line in the Apache httpd.conf file. But which one? – Tripduc Oct 11 '17 at 17:04

1 Answers1

1

Alright I found what wasn't correct.

I needed to insert AddType application/x-httpd-php .php in my httpd.conf file to enable MIME PHP.

I hope this will help other people with similar issues in the future.

Tripduc
  • 31
  • 1
  • 11