{"id":81,"date":"2009-12-23T23:30:06","date_gmt":"2009-12-24T06:30:06","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=81"},"modified":"2009-12-23T23:30:06","modified_gmt":"2009-12-24T06:30:06","slug":"getting-apache-installed","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2009\/12\/23\/getting-apache-installed\/","title":{"rendered":"Getting Apache installed"},"content":{"rendered":"<p>Installing Apache2.2<\/p>\n<p>Make sure you update ports and then run the following commands:<\/p>\n<p># cd \/usr\/ports\/www\/apache22<br \/>\n# make install clean<br \/>\nThat will install apache2.2<br \/>\nConfiguring apache2<br \/>\nLets edit the httpd.conf file:<\/p>\n<p># vi \/usr\/local\/etc\/apache22\/httpd.conf<br \/>\nScroll down and change the following settings. The optional settings I will put OPTIONAL before the setting:<\/p>\n<p>OPTIONAL: Listen 80 &#8211; You can change this default option if you have more than one apache server running on your network<\/p>\n<p>User www &#8211; Changes what user apache runs as<\/p>\n<p>Group www &#8211; Changes what group apache runs as<\/p>\n<p>ServerAdmin you@example.com- change you@example.comto your email address.<\/p>\n<p>DocumentRoot &#8220;\/usr\/local\/www\/apache22\/data&#8221; &#8211; I don&#8217;t usually use the default path. I put my www documents on a seperate drive.<\/p>\n<p>Directory &#8220;\/usr\/local\/www\/apache22\/data&#8221; &#8211; Change this to the same path as DocumentRoot (See above)<\/p>\n<p>&lt;Directory \/usr\/local\/www\/apache22\/&gt; Change this to the root of your vhosts folder<\/p>\n<p>DirectoryIndex index.html index.html.var &#8211; add any pages you would use. For instance, add index.php if you use php pages<\/p>\n<p>OPTIONAL: #CustomLog \/var\/log\/httpd-access.log combined &#8211; I usually leave this commented unless you want to use this to track users looking at your site<\/p>\n<p>ScriptAlias \/cgi-bin\/ &#8220;\/usr\/local\/www\/cgi-bin\/&#8221; &#8211; change this to your cgi-bin path<\/p>\n<p>Directory &#8220;\/usr\/local\/www\/cgi-bin&#8221;&gt; &#8211; change this to the same path as ScriptAlias \/cgi-bin above<\/p>\n<p>Now lets tell apache to start:<\/p>\n<p># apachectl start<br \/>\nand hit Enter on your keyboard<br \/>\nWe now need to tell Apache to run on startup. Please run the following command:<\/p>\n<p># echo &#8216;apache22_enable=&#8221;YES&#8221;&#8216; &gt;&gt; \/etc\/rc.conf<br \/>\nIf you get no errors, apache should be running. Look at the page by opening a browser to http:\/\/localhost or replace localhost with the IP or the actual hostname of the box. If you went with the DocumentRoot defaults, You will see an apache test page until you get your site up and going. If you are behind a router or firewall, make sure you forward the apache port (Port 80) to the FreeBSD box otherwise you won&#8217;t be able to get there from here. \ud83d\ude42<\/p>\n<p>Configuring SSL<\/p>\n<p>Let&#8217;s get SSL Configured and Installed:<\/p>\n<p>(FROM http:\/\/www.bsdguides.org\/guides\/freebsd\/webserver\/apache_ssl_php_mysql.php)<\/p>\n<p># mkdir \/usr\/local\/etc\/apache22\/ssl.key<br \/>\n# mkdir \/usr\/local\/etc\/apache22\/ssl.crt<br \/>\n# chmod 0700 \/usr\/local\/etc\/apache22\/ssl.key<br \/>\n# chmod 0700 \/usr\/local\/etc\/apache22\/ssl.crt<br \/>\nCreate Certificate<br \/>\nNow, you need to understand that one server can hold multiple certificates, but only one per listening IP address. So, if your server is listening on one IP address, you can only have one certificate for the server. Follow me so far? All of your virtual domains can share the same certificate, but clients will get warning prompts when they connect to a secure site where the certificate does not match the domain name. If your server is listening on multiple IP addresses, your virtual hosts have to be IP-based &#8212; not name-based. This is something to consider when creating your certificate. \ud83d\ude42<\/p>\n<p>Change to your root dir by typing in the following command. We want to save this configuration there as a backup.<\/p>\n<p># cd \/root<br \/>\n# openssl genrsa -des3 -out server.key 1024<br \/>\nYou will now be prompted to enter in a password. Write this down as you will need it later. We need to make a Certificate Signing Request (CSR):<\/p>\n<p># openssl req -new -key server.key -out server.csr<br \/>\nEnter your password when it asks for it. Make sure you enter your FQDN for the &#8220;Common Name&#8221; portion.<br \/>\nSelf-signing your Certificate<br \/>\nYou could always pay money to Verisign or Thawte for this but it costs $$$. Here is the way to do it:<\/p>\n<p># openssl x509 -req -days 365 -in \/root\/server.csr -signkey \/root\/server.key -out \/root\/server.crt<br \/>\nNow your cert is good for 365 days. If you want to make it longer, go right ahead and do so \ud83d\ude42<br \/>\nIf you would like more information about SSL Certs, go to http:\/\/httpd.apache.org\/docs-2.0\/ssl\/ssl_faq.html#aboutcerts<\/p>\n<p>Now we need to copy the certs to the right place:<\/p>\n<p># cp \/root\/server.key \/usr\/local\/etc\/apache22\/ssl.key\/<br \/>\n# cp \/root\/server.crt \/usr\/local\/etc\/apache22\/ssl.crt\/<br \/>\nNow to give them the right permissions as well:<\/p>\n<p># chmod 0400 \/usr\/local\/etc\/apache22\/ssl.key\/server.key<br \/>\n# chmod 0400 \/usr\/local\/etc\/apache22\/ssl.crt\/server.crt<br \/>\nWe will now want to copy the default httpd-ssl.conf from the extras folder to the Includes folder:<\/p>\n<p># cd \/usr\/local\/etc\/apache22\/extra<br \/>\n# vi httpd-ssl.conf<br \/>\nNow modify the following:<\/p>\n<p>DocumentRoot &#8220;\/usr\/local\/www\/data&#8221; &#8211; Change the path to your httpd.conf document root.<\/p>\n<p>ServerName www.example.com:443 &#8211; Change www.example.com to your domain name.<\/p>\n<p>ServerAdmin you@example.com\u00a0 Change this to your email address<\/p>\n<p>ErrorLog \/var\/log\/httpd-error.log &#8211; You can leave this or comment it out.<\/p>\n<p>TransferLog \/var\/log\/httpd-access.log &#8211; You can leave this or comment it out.<\/p>\n<p>SSLCertificateFile &#8220;\/usr\/local\/etc\/apache22\/ssl.crt\/server.crt&#8221;<\/p>\n<p>SSLCertificateKeyFile &#8220;\/usr\/local\/etc\/apache22\/ssl.key\/server.key&#8221;<\/p>\n<p>One additional thing you will need to do is open up\u00a0 \/usr\/local\/etc\/apache22\/httpd.conf and comment out the following line:<br \/>\nInclude etc\/apache22\/extra\/httpd-ssl.conf<br \/>\nNow run the following:<\/p>\n<p># apachectl stop<br \/>\n# apachectl start<br \/>\nThe start means it will start in ssl mode to serve both http:\/\/ and https:\/\/ addresses. This used to be apachectl sslstart but that command has been depreciated.<br \/>\nThe URL below includes instructions on how to remove the pass phrase prompt when apache starts<br \/>\nhttp:\/\/httpd.apache.org\/docs\/2.0\/ssl\/ssl_faq.html#removepassphrase<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Installing Apache2.2 Make sure you update ports and then run the following commands: # cd \/usr\/ports\/www\/apache22 # make install clean That will install apache2.2 Configuring <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2009\/12\/23\/getting-apache-installed\/\" title=\"Getting Apache installed\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[36,39,149,257],"class_list":["post-81","post","type-post","status-publish","format-standard","hentry","category-misc","tag-amit","tag-apache","tag-install","tag-truelogic"],"_links":{"self":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/81","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/comments?post=81"}],"version-history":[{"count":0,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/81\/revisions"}],"wp:attachment":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media?parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}