For local development testing a self-signed certificate is adequate. You can generate one with the OpenSSL kit like so:
Generating the private key:
openssl genrsa -des3 -out server.key 1024
output:
Generating RSA private key, 1024 bit long modulus
.........................................................++++++
........++++++
e is 65537 (0x10001)
Enter PEM pass phrase:
Verifying password - Enter PEM pass phrase:
enter a passphrase for your private key.
Generating the CSR (certificate signing request):
openssl req -new -key server.key -out server.csr
it will request details like this:
Country Name (2 letter code) [GB]:
State or Province Name (full name) [Berkshire]:
Locality Name (eg, city) [Newbury]:
Organization Name (eg, company) [My Company Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
it's fairly straightforward, the common name is your server's hostname as it says in brackets.
Generating the self signed certificate:
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Configuring SSL in httpd.conf for Apache:
SSLEngine on
SSLCertificateFile /path/to/generated/server.crt
SSLCertificateKeyFile /path/to/generated/server.key
(replace path appropriately with the path to your certificate and key)
Restart Apache:
apachectl restart
Apache will ask you for the passphrase to your key. If you think you will be shutting the server down a lot, you may want to remove the passphrase from the key so you can avoid entering it each time. If not, don't worry about it. If so, complete this step after step 2 (Generating the CSR):
cp server.key server.key.copy
openssl rsa -in server.key.copy -out server.key
Try to put the directory tag, that match the DocumentRoot path like this :
<VirtualHost *:80>
DocumentRoot /home/user1/htdocs
ServerName hostname.com
<Directory /home/user1/htdocs>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Best Answer
Your question states you want to remove Apache2 from Mac OS X, but it’s not clear how you installed it or even if you did a custom install. If it’s the Apache that is installed with Mac OS X you don’t want to remove it from the OS, but just deactivate it so it’s not running.
By default Apache comes bundled with Mac OS X but it’s deactivated. So my assumption is you simply started Apache on the system and even set it to come up automatically when the system starts up or reboots. I’m guessing that since your output of
sudo lsof -i:80
shows Apache running under the user_www
.Anyway to stop the built-in Apache server in Mac OS X is by using this command:
Then just enter your administrator password. And to prevent Apache from coming up again on if your system reboots/restarts just run this
launchctl unload
command; you’ll need your administrator password again:When that’s all done, check the output of
sudo lsof -i:80
and the built-in Apache web server in Mac OS X should be completely stopped and disabled.