Section I: Apache Setup
1. Change DocumentRoot in the apache config file
- vi /etc/apache2/httpd.conf
- Replace default – DocumentRoot “/Library/WebServer/Documents”
- with – DocumentRoot “/Users/your_user/Sites”
- Similarly change the path with in the <Directory> block.
- Inside the <Directory> block, replace AllowOverride None with AllowOverride All
- Provide proper ServerName and ensure its DNS entry is updated. Can use for local development purpose –
ServerName localhost
2. Change default Apache user and group to yours.
- Comment out lines – User _www and Group _www
- Add User your_user and Group staff
3. Create DocumentRoot as mentioned in the config file
- mkdir ~/Sites
- Add your application or a simple index.html for the time being to test out apache setup
4. Test by browsing to http://localhost
Section II – Passenger Setup
1. brew install passenger
2. Per the step 1. output, create /etc/apache2/other/passenger.conf:
LoadModule passenger_module /usr/local/opt/passenger/libexec/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/opt/passenger/libexec/lib/phusion_passenger/locations.ini
PassengerDefaultRuby /usr/bin/ruby
3. If you are not using system ruby, update the PassengerDefaultRuby in step 2 accordingly.
I am using rbenv, hence –
which ruby
$/Users/user_name/.rbenv/shims/ruby
4. No need for the command –
passenger-install-apache2-module
Section III – Apache Passenger Integration
1. Update /etc/apache2/httpd.conf
-
Include Passenger.conf created in section II by adding following line at the end of httpd.conf-
/private/etc/apache2/other/*.conf
- UnComment the following line since we would be creating our site specific virtual host –
Include /private/etc/apache2/extra/httpd-vhosts.conf
2. Site specific virtual host can be created by including blocks as given below –
vi /private/etc/apache2/extra/httpd-vhosts.conf
<Virtualhost *:80>
ServerName localhost
DocumentRoot /Users/your_user/Sites/blog/public/
RailsEnv development
LogLevel warn
CustomLog /var/log/apache2/blog-production-access.log "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" \"%{Host}i\" %D"
ErrorLog /var/log/apache2/blog-production-error.log
UseCanonicalName Off
<Directory "/Users/your_user/Sites/blog/public">
Allow from all
Options -MultiViews
Options FollowSymLinks
</Directory>
3. Check for syntax errors and rectify any typos if any-
4. If all good, start Apache.
Verify the installation by checking the apache logs and passenger stats –
sudo apachectl start
tail -f /var/log/apache2/error_log
sudo passenger-memory-stats.
This would show GUI with separate sections for Apache, nginx and Passenger processes.
If the installation is successful, Apache and Passenger processes section would be non-empty and show some processes.
References: