Apache Setup

His Website Will Outfrown Yours

Apache is remarkably easy to get running.  It is all governed by the service daemon “httpd” and can be installed easily with a yum or apt-get install command if it didn’t come packaged with your distribution.  Any repository that was preinstalled should have it easily available.  The yum command in CentOS would be:

yum install httpd

The configuration file is easy to edit with the command:

vim /etc/httpd/conf/httpd.conf

Almost everything you could need for a simple webserver is already set up for you, and already configured.  The two simplest edits you can change would be the port(s) Apache listens on and the DocumentRoot setting that tells the service what local directory on the server itself will act as the root directory for web pages.

You can change it from listening from port 80 to any other valid TCP port by finding the line that says “Listen 80″  and changing it to “Listen <xxx>” where <xxx> would just be whatever port you want to try.  If you wanted port 3005 you would change the line to say, “Listen 3005″ and save the file.
Just as a side note for alternate ports, the assumed port for http url browsing is port 80.  It’s implied in all standard browsers that when you access a url or an ip of a webserver that it is to be done over port 80, unless directly told otherwise.  The method for accessing a url or ip over a specific port is to enter the url/ip like so http://<ip_or_url>:<port>

For example, accessing your loopback ip over port 3005 would work as such in a browser:

http://127.0.0.1:3005

This will access your DocumentRoot folder on the webserver, and will normally allow you to access any file inside that directory that the Apache service has access to.  The browser used to access the file will in large measure determine how that file is accessed.

DocumentRoot configuration is just as simple.  The default directory for CentOS is /var/www/html but you may want to change that for whatever reason.  It’s easy to change that by doing the same vim command as above and changing the line that starts with DocumentRoot “/var/www/html” to use whatever directory you prefer that Apache has access to.

For example, if you wanted Apache to access /home/myuser/webfiles you would change the line to look like so:

DocumentRoot “/home/myuser/webfiles”

Any time you make a change to the http.conf file and you want to see its effects, you’ll need to restart the httpd service like so:

service httpd restart

Once the service is restarted, you should see any changes immediately when you access it from a browser.

Owncloud Part 2

After some research it became pretty clear that getting SSL to work with a private key would be simple.  You must make sure that openssl is installed, and yum installing it should do everything required to get that working.
# Generate private key
openssl genrsa -out ca.key 1024

# Generate CSR
openssl req -new -key ca.key -out ca.csr

# Generate Self Signed Key
openssl x509 -req -days 999 -in ca.csr -signkey ca.key -out ca.crt

# Copy the files to the correct locations
cp ca.crt /etc/pki/tls/certs
cp ca.key /etc/pki/tls/private/ca.key
cp ca.csr /etc/pki/tls/private/ca.csr
Then you have to tell Apache to use the new keys by editting the ssl.conf file.
vi +/SSLCertificateFile /etc/httpd/conf.d/ssl.conf

Add in lines:
SSLCertificateFile /etc/pki/tls/certs/ca.cr
SSLCertificateKeyFile /etc/pki/tls/private/ca.key

Once the correct SSL Certificates were installed, and the Apache service was restarted, the SSL kicked in.  Using a browser to access OwnCloud over https just started working.  All you have to do is accept the untrusted certificate when accessing the page. Once you tell your client to accept using that key, all functionality of the site will now operate the same, but will now use https, including downloading files through encrypted means.

The trouble, however, is that it is a private key, and therefore is automatically not trusted.  In order for any windows OwnCloud client to work, it has to be a trusted certificate.

The easiest way to trust a certificate in windows is to open Internet Explorer to the https url and click on the “Continue to webpage” option.  Once it’s using that certificate, it will say something along the lines of “Certificate Error” in the URL line.  Click on that, and it should allow you to “View Certificates” from which you can install the certificate and place it into a specific “store” called something along the lines of “Trusted Root Certificate Authorities” which will basically allow any kind of SSL communication using that certificate.
Once that’s installed on the windows client as a trusted certificate, the windows OwnCloud client was able to sync with the https URL.

Owncloud Part 1

OwnCloud is a DropBox-type file-sync system that is open source and free for use.
Implementing OwnCloud was troublesome for me at first, as it had moments where it was easy as pie, and moments where I lost the will to continue living in a world where I couldn’t control my own Linux machine.
The initial setup was fairly simple.  Getting the OwnCloud tar package and dropping it into the Apache DocumentRoot was simple enough.  Then I had to give Apache permissions for it with the ‘chown -r apache: /apache/document/root/owncloud’ command.
The PHP pages guide you the rest of the way, and with the newest version of OwnCloud handles everything with SQLite instead of giving you any options, which actually makes things easier
The problem came with me trying to fiddle with settings of OwnCloud once I had it installed.
For example, on my first installation attempt, I hadn’t really hammered out where I was planning on storing the files uploaded through OwnCloud, assuming that I could change it later.  When I attempted to switch that file location later through some mild config changing, the world collapsed in on itself and I suddenly could no longer log into the OwnCloud admin interface at all.
Despite my attempts to drop any SQLite tables associated with OwnCloud, I actually was not able to get OwnCloud working again until I reinstalled the operating system and started from scratch.  There may be tools associated with OwnCloud that can do this easily, but it was a serious keyboard pounding moment for me.
Owncloud is limited in its file size capabilities by your system’s PHP configuration.  You can change that configuration by editing the /etc/php.ini file and editing the upload_max_filesize and post_max_size variables to a larger size.  These are both usually limited to 10 megabytes and will usually show up as two separate lines like so:
upload_max_filesize = 10M
post_max_size = 10M
You should change these to be the maximum size that you expect for files that you will be syncing.  If you wanted to change it to one gigabyte limit you would use 1G instead of the 10M.  I arbitrarily set these to 4 gigabytes, and have had no issues with syncing xvid video files or other semi-large files.
Once that was complete, however, syncing directories with windows clients has been a snap.  The only other issue I had was getting everything working over SSL…

Rolling Out WordPress

WordPress’s Gritty Reboot

Rolling out WordPress was actually the last of the administrative acts I have accomplished on this server, and it was by far the easiest of the implementations.  I feel sheepish even calling it an implementation.  It was almost embarrassingly easy to get it up and running. I downloaded the latest version of WordPress from the WordPress download sections into my /usr/src directory.  This I did with:
cd /usr/src
wget http://wordpress.org/latest.tar.gz
After it completed its download, I untarred it, then copied it in its entirety to my apache document root directory.
tar xvf latest.tar.gz
cp -r wordpress /my/apache/documentroot/
Then, I gave apache ownership of the whole directory with:
chown -R apache: /my/apache/documentroot/wordpress
Then opening up a web browser to the WordPress index I followed the install methods.
But wait, a snag!  Mysqld wasn’t working!  WordPress alerted me to the fact that my PHP installation didn’t have the proper Mysql integration!  Oh no!  All is lost, and life is meaningless!
Except, all that was required, as I already had PHP installed was to make sure that the php-mysql package was installed.  The CentOS community repos make this available as a yum install.  So I went ahead an did that with:
yum install php-mysql
After getting php-mysql installed, WordPress held my hand the rest of the way, and it was up and running within seconds.  It was remarkable.  Bless open source web development and the heroes that keep it moving forward.  Bless them one and all.

Mission Statement

I’ve seldom blogged about anything on a regular basis with any kind of regularity or otherwise.  This is in large measure just an exercise in web administration.  My writing skills and ability to ENTICE and EXCITE are both rancidly rotten and ignored to the point of being rusted to complete impotent dullness.
However, I enjoy attempting new administration and the rolling out of PHP stuff.  It’s absurd how easy it gets after a little while.  PHP and Mysql combined has made things remarkably modular in website administration, and yet rolling out a wordpress or a wiki is always exciting to me, and somehow still gives me a sense of accomplishment, regardless of how easy the developers have made it..  I can always count on the chance of something going slightly wrong, and somehow making me feel intelligent for getting around it.  Even though it is usually as something as silly as a service not running on the webserver.
I’m going to document each of my attempts for web administration, and to the best of my ability enumerate my mistakes in the hopes it will help you avoid the same pitfalls.

Second Time Around

This is another go around for doing site administration.

I’m doing this via a virtual server, so we’ll see how well it translates.

It’s definitely exciting, and I feel like it should work out well, VirtualBox allows for snapshots and backing up as easy as setting a Belvedere timed copy command.