Trying to enable "web sharing" from terminal

I am using phproxy on my mac. I would like to be able to enable / disable web sharing from the command line, so I can turn it on only when I need it(remotely). I remember reading that the "screen sharing" can be set on/off in /Library/Preferences
I don't see any obvious preferences for "web sharing" Does anyone know a way to do this?

man -k sharing
InternetSharing(8) - simple NAT/router configuration daemon
threads::shared(3pm) - Perl extension for sharing data structures between threads

man InternetSharing

man defaults

It appears the com.apple.nat.plist is not created until internet sharing is turned on, so you might want to turn it on through the GUI and examine the resulting plist file.

defaults read /Library/Preferences/SystemConfiguration/com.apple.nat

Note that the defaults command reads plist files, but fails if you specify the plist file extension ".plist"
Leave the file extension off when accessing a plist file with the defaults command.

Good luck. :slight_smile:

There may be a simpler way, so examine the other SystemConfiguration/ plist files after enabling the internet sharing feature...

1 Like

Thanks for your replies [MA]Flying Meat,
This is a bit more involved than I was hoping. My unix knowledge is still pretty basic. The more I read about it, the idea of running a phproxy on my home computer probably isn't the best solution for me.

not sure about previous versions, but OSX Lion simply passes a name to apache when web sharing is enabled from system prefs to load the "web sharing" configs.

to start apache with web sharing enabled from terminal:

sudo /usr/sbin/httpd -k start -D WEBSHARING_ON

in httpd.conf you will find this block:

<IfDefine WEBSHARING_ON>
# Multi    -language error messages
#Include /private/etc/apache2/extra/httpd-multilang-errordoc.conf

# Fancy directory listings
Include /private/etc/apache2/extra/httpd-autoindex.conf

# User home directories
Include /private/etc/apache2/extra/httpd-userdir.conf

# Real-time info on requests and configuration
#Include /private/etc/apache2/extra/httpd-info.conf

# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual
#Include /private/etc/apache2/extra/httpd-manual.conf

# Distributed authoring and versioning (WebDAV)
#Include /private/etc/apache2/extra/httpd-dav.conf

</IfDefine>

i've tested this and i'm pretty sure that's all there is to it.