Httpd on Mac: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(20 intermediate revisions by the same user not shown)
Line 3: Line 3:
=Installation=
=Installation=
{{Internal|Httpd Installation on Mac|Httpd Installation on Mac}}
{{Internal|Httpd Installation on Mac|Httpd Installation on Mac}}
=Compilation=
{{Internal|Httpd_Compilation_on_Mac|<tt>httpd</tt> Compilation on Mac}}
=Start=
<syntaxhighlight lang='bash'>
/opt/brew/opt/httpd/bin/httpd -D FOREGROUND
</syntaxhighlight>
=Start at Boot=
=Start at Boot=
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
sudo brew services start httpd
brew services start httpd
</syntaxhighlight>
</syntaxhighlight>
=Directory Layout=
=Directory Layout=


Line 13: Line 22:
   └── brew
   └── brew
       ├── Cellar
       ├── Cellar
       │
       │     └── httpd
       └── opt
      │          └── 2.4.58
             └── httpd
      │              └── bin
                  └──  bin
      │                    └── httpd
      ├── etc
      │    └── httpd
      │        ├──  httpd.conf <font color=teal># Main configuration file</font>
      │        └──  extra
       │              └── httpd-ssl.conf
      ├── opt
      │    └── httpd
      │        └──  bin
      │             └── httpd
      └── var
            ├── www  <font color=teal># Document root</font>
            │    └──  index.html
            │
            └── homebrew
                └──  linked
                      └──  httpd
</font>
 
=Configuration=
 
==Configure PHP==
Install as shown here: {{Internal|PHP#Mac|PHP Installation on Mac}}
 
Add the following to <code>httpd.conf</code> and restart Apache:
<syntaxhighlight lang='xml'>
LoadModule php_module /opt/brew/opt/php/lib/httpd/modules/libphp.so
 
<FilesMatch \.php$>
  SetHandler application/x-httpd-php
</FilesMatch>
</syntaxhighlight>
 
Check DirectoryIndex includes index.php
<syntaxhighlight lang='xml'>
<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>
</syntaxhighlight>
 
==Miscellaneous==
 
Set <code>ServerName</code> to localhost:8080.
=Troubleshooting=
 
* [[Mac_launchd#System_httpd_keeps_starting_in_foreground|System httpd keeps starting in foreground]]

Latest revision as of 23:35, 29 December 2023

Internal

Installation

Httpd Installation on Mac

Compilation

httpd Compilation on Mac

Start

/opt/brew/opt/httpd/bin/httpd -D FOREGROUND

Start at Boot

brew services start httpd

Directory Layout

/opt
 └── brew
      ├── Cellar
      │     └── httpd
      │          └── 2.4.58
      │               └── bin
      │                    └── httpd
      ├── etc
      │    └── httpd
      │         ├──  httpd.conf # Main configuration file
      │         └──  extra
      │               └──  httpd-ssl.conf
      ├── opt
      │    └── httpd
      │        └──  bin
      │              └──  httpd
      └── var
           ├── www   # Document root
           │    └──  index.html
           │ 
           └── homebrew
                └──  linked
                      └──  httpd

Configuration

Configure PHP

Install as shown here:

PHP Installation on Mac

Add the following to httpd.conf and restart Apache:

LoadModule php_module /opt/brew/opt/php/lib/httpd/modules/libphp.so

<FilesMatch \.php$>
  SetHandler application/x-httpd-php
</FilesMatch>

Check DirectoryIndex includes index.php

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

Miscellaneous

Set ServerName to localhost:8080.

Troubleshooting