13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 7 ■ WORKING WITH APACHEThen check that the certificate corresponds to the private key. The output of these two commandsshould match:openssl x509 -noout -modulus -in my.domain.org.pem | openssl sha1openssl rsa -noout -modulus -in my.domain.org.key | openssl sha1Now install my.domain.org.key and my.domain.org.crt into /etc/apache2/ssl, and set thepermissions correctly:cp my.domain.org.key my.domain.org.crt /etc/apache2/sslchown root:root my.domain.org.key; chmod og-r my.domain.org.keychown root:root my.domain.org.crt; chmod a+r my.domain.org.crtIt’s important to make sure that the server key is readable only by root, while the server certificateshould be world-readable but owned and writeable only by root. (If you already did this when yougenerated the certificate and key, you shouldn’t need those last two lines.)7-4. Compiling and Configuring Apache with SSLOnce you’ve set up your SSL certificate as in the previous recipe, the next step is to get SSL working inApache. The best bet for this is to use the package provided for your distro. With Debian/Ubuntu,Apache comes with the SSL module available, but it’s not automatically enabled. To enable it, use this:a2enmod ssl/etc/init.d/apache2 restartThe generic way to do this is to add this line to your /etc/apache2/apache2.conf or /etc/apache2/httpd.conf file:Include /etc/apache2/mod_ssl.confYou may need to edit this to give the correct location for mod_ssl.conf in your setup. Then restartApache2.For configuration, the following instructions assume that you want to run both a secure server (onport 443) and a regular server (on port 80). First, you need to configure the server to listen on both ports.In Debian/Ubuntu, edit /etc/apache2/ports.conf or directly edit /etc/apache2/apache2.conf to includethe lines:Listen 80Listen 443Next, edit /etc/apache2/sites-enabled/yoursite to use the SSL settings. The most maintainableoption is to separate the regular and secure server settings out with VirtualHosts.164Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!