Archive for the ‘Operating Systems’ Category.

How to install subversion 1.6.6 on FreeBSD 7.2

How to install Subversion 1.6.6 on FreeBSD 7.2.
The basic overivew.

  1. Install FreeBSD.
    How do I install FreeBSD?

  2. Update FreeBSD and download the ports tree.
    What are the first commands I run after installing FreeBSD

  3. Then install Subversion.

I have previous documents about installing each of the steps above installing Subversion. This document will only cover Subversion.

Installing Subversion on FreeBSD from ports

  1. Go to /usr/ports/devel/subversion and run make install.

    ServerName#
    ServerName#
    cd /usr/ports/devel/subversion
    make install

    NOTE: If you get a failure due to apr already being installed but not being built correctly, then uninstall apr and reinstall it with the default settings. Then go back and try to install subversion again.

    ServerName#
    ServerName#
    ServerName#
    cd /usr/ports/devel/apr
    make deinstall
    make BATCH=yes install

  2. Configure Subversion to start at bootup.

    #
    #
    echo # Subversion >> /etc/rc.conf
    echo 'svnserve_enable="YES"' >> /etc/rc.conf

  3. Create an svn user using the adduser command line wizard. This command will walk you through creating an svn user. Make sure to use the nologin shell and a random password so the user cannot login.

    # # adduser
    Username: svn
    Full name: svn
    Uid (Leave empty for default):
    Login group [svn]:
    Login group is svn. Invite svn into other groups? []:
    Login class [default]:
    Shell (sh csh tcsh nologin) [sh]: nologin
    Home directory [/home/svn]:
    Home directory permissions (Leave empty for default):
    Use password-based authentication? [yes]:
    Use an empty password? (yes/no) [no]:
    Use a random password? (yes/no) [no]: yes
    Lock out the account after creation? [no]:
    Username : svn
    Password :
    Full Name : svn
    Uid : 1002
    Class :
    Groups : svn
    Home : /home/svn
    Home Mode :
    Shell : /usr/sbin/nologin
    Locked : no
    OK? (yes/no): yes
    adduser: INFO: Successfully added (svn) to the user database.
    adduser: INFO: Password for (svn) is: /2CZct48a
    Add another user? (yes/no): no
    Goodbye!

  4. Make a repos directory in the svn user's home directory.

    # mkdir /home/svn/repos

  5. Create a repository.

    #
    #
    #
    #
    cd /home/svn
    mkdir repos
    cd repos
    svnadmin create MyApp

    This will create a MyApp folder and populate it with the files needed to start a repository.

    This is default subversion repository folder structure:

    /home/svn/repos/MyApp/README.txt
    /home/svn/repos/MyApp/format
    /home/svn/repos/MyApp/conf
    /home/svn/repos/MyApp/confauthz
    /home/svn/repos/MyApp/conf/passwd
    /home/svn/repos/MyApp/confsvnserve.conf
    /home/svn/repos/MyApp/db
    /home/svn/repos/MyApp/db/current
    /home/svn/repos/MyApp/db/format
    /home/svn/repos/MyApp/db/fs-type
    /home/svn/repos/MyApp/db/fsfs.conf
    /home/svn/repos/MyApp/db/min-unpacked-rev
    /home/svn/repos/MyApp/db/rep-cache.db
    /home/svn/repos/MyApp/db/revprops
    /home/svn/repos/MyApp/db/revs
    /home/svn/repos/MyApp/db/transactions
    /home/svn/repos/MyApp/db/txn-current
    /home/svn/repos/MyApp/db/txn-current-lock
    /home/svn/repos/MyApp/db/txn-protorevs
    /home/svn/repos/MyApp/db/uuid
    /home/svn/repos/MyApp/db/write-lock
    /home/svn/repos/MyApp/db/revprops/
    /home/svn/repos/MyApp/db/revprops/0
    /home/svn/repos/MyApp/db/revprops/0/0
    /home/svn/repos/MyApp/db/revs/
    /home/svn/repos/MyApp/db/revs/0
    /home/svn/repos/MyApp/db/revs/0/0
    /home/svn/repos/MyApp/db/transactions/
    /home/svn/repos/MyApp/db/txn-protorevs/
    /home/svn/repos/MyApp/hooks/
    /home/svn/repos/MyApp/hooks/post-commit.tmpl
    /home/svn/repos/MyApp/hooks/post-lock.tmpl
    /home/svn/repos/MyApp/hooks/post-revprop-change.tmpl
    /home/svn/repos/MyApp/hooks/post-unlock.tmpl
    /home/svn/repos/MyApp/hooks/pre-commit.tmpl
    /home/svn/repos/MyApp/hooks/pre-lock.tmpl
    /home/svn/repos/MyApp/hooks/pre-revprop-change.tmpl
    /home/svn/repos/MyApp/hooks/pre-unlock.tmpl
    /home/svn/repos/MyApp/hooks/start-commit.tmpl
    /home/svn/repos/MyApp/locks/
    /home/svn/repos/MyApp/locks/db-logs.lock
    /home/svn/repos/MyApp/locks/db.lock
  6. To configure a Repository and add users, edit the following file:
    /home/svn/repos/MyApp/conf/svnserve.conf

    # ee /home/svn/repos/MyApp/conf/svnserve.conf

    Uncomment lines below or just create a new svnserve.conf file with these lines:

    [general]
    anon-access = read
    auth-access = write
    password-db = /home/svn/userdb

    Now edit the following file:
    /home/svn/repos/MyApp/passwd

    # ee /home/svn/repos/MyApp/passwd

    Add users. For example, to add a user allen1 with a password of P@sswd! and another user jared with a password of My$ecre+1, the file would look like this:

    [users]
    allen1 = P@sswd!
    jared = My$ecre+1
  7. Now start the svn server.

    # /usr/local/etc/rc.d/svnserve start

  8. Now you should be able to connect to your repository with an svn client. TortoiseSVN is a popular windows tool that you can use to connect to your repository.

    Use the following to connect:

    svn://allen1:P@sswd!@ServerName/MyApp

Now i have to figure out a bunch more steps...
How to populate an SVN repository?
How to configure Subversion to use Cyrus-SASL2 to authenticate to a MySQL database?
How to configure Subversion to use Cyrus-SASL2 to authenticate to a MySQL database where the password is stored in a hash? So you can have SVN share Bugzilla users?
How to get Tortoise SVN to connect to an SVN repository?
How to install WebSVN as a web interface to the SVN repository?


Copyright ® Rhyous.com - Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.

Windows 7 hangs when creating a new folder and hangs again when renaming it

Ok, so I am using Windows 7 64 bit and while I have overall been pleased with Wndows 7, I must be unbiased and post the problems too, right.

Well, I have a problem that is frustrating.

PROBLEM
Windows 7 hangs when creating a new folder and hangs again when renaming it

How it happens
The problem occurs when I create a New Folder. Explorer hangs for about 45 seconds. I am not sure what the problem is, but there is no excuse for taking 45 seconds to create a new folder.

To make the problem worse, the first thing I do when I make a new folder is I rename it. So if I try to rename the folder, it hangs another 45 seconds.

Cause

Unknown…

Could it be my hardware? Maybe. I have a Lenovo T61p with 4 GB of RAM and a 160 GB hard drive that is just shy of two years old.

Could it be some application? Maybe. But I don’t have any of the most likely culprits such as Antivirus installed. I a a developer, but I don’t have MySQL or SQL Server Express running or anything.

How is my processor and memory utilization when this occurs? Fine.
CPU: I don’t have 100% CPU, and I have almost no CPU usage, under 10% (moving between 3 and 9% and once hit 16%).
RAM: 1.3 GB used, 2.7 available.

So this is a the first big fat negative for windows 7. If you have seen this, then that would confirm that it is a wide spread issue and not just an issue on my single machine.

update: 2/20/2010
The cause is obviously something to do with going to full hibernate mode and returning.

Possible Resolutions

Do a clean reboot.
Or restart Explorer.
Or disable Windows Search??

How to install Bugzilla on a FreeBSD 7.2 with Apache + SSL and MySQL?

How to install Bugzilla 3.4.2 on FreeBSD 7.2.

The basic overivew.

  1. Install FreeBSD.
    How do I install FreeBSD?

  2. Update FreeBSD and download the ports tree.
    What are the first commands I run after installing FreeBSD

  3. Then install Apache + SSL.
    Installing an Apache + SSL on FreeBSD using the ports tree

  4. Then install MySQL.
    How to install MySQL on FreeBSD 7.2 or on Red Hat 5.4?

  5. Configure MySQL to be Unicode.
    How to create a UTF-8 Unicode Database on MySQL and make UTF-8 Unicode the default?

  6. Then install Bugzilla

I have previous documents about installing each of the steps above installing Bugzilla. This document will over cover bugzilla.

Installing Bugzilla From Ports

You can install easily from Ports. Make sure your ports tree is up to date:

$

su

Password:

ServerName#
ServerName#
ServerName#
portsnap fetch
portsnap extract
portsnap udpate

Then just do this to install Bugzilla 3.4.2 on FreeBSD 7.2.

ServerName#
ServerName#
cd /usr/ports/devel/bugzilla
make BUGZILLADIR=/usr/local/www/apache22/data/bugzilla install

Note: Make sure you choose the correct install directory for the BUGZILLADIR parameter. By default Apache 2.2 is only serving up files in /usr/local/www/apache22/data/ so by install bugzilla there, you will be able to access bugzilla with this url: http://www.YourWebSite.com/bugzilla

You will be asked to select your compile options throughout. If you don’t want to be promtped, and you want to accept the defaults, use this command.

ServerName# make BATCH=yes install

Now that you have Bugzilla 3.4.2 on your FreeBSD 7.2 server, you are not finished. We now need to connect to connect it to a database, which I am assuming is MySQL but could just as easily be Postgresql.

Resetting the file ownership recursively on the bugzilla folder

Make sure that the bugzilla folder and all subfolders are owned by www:www.

ServerName# chown -R www:www /usr/local/www/apache22/data/bugzilla

Creating a MySQL Database

  1. Log into mysql. I use the command line and type in mysql -p, enter my password when prompted.
  2. Create a database for Bugzilla.
  3. Create a user that can access Bugzilla.
  4. I use the followiing SQL commands for these steps:

    CREATE DATABASE BugDB
    
    GRANT SELECT, INSERT, UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES,
               CREATE TEMPORARY TABLES, DROP, REFERENCES
               ON BugDB.* TO BugDBUser@localhost
               IDENTIFIED BY 'P@sswd!';
    FLUSH PRIVILEGES;
    

Run Install Check Script

  1. In a command prompt go to /usr/local/www/data/bugzilla
    ServerName# cd /usr/local/www/data/bugzilla
  2. Run the setup checking script.
    ServerName# ./checksetup.pl
  3. Now you are ready to open and edit the localconfig file.
    ServerName# ee localconfig
  4. Change the following values:

    $webservergroup = ‘www’
    $db_name = ‘BugDB’
    $db_user = ‘BugDBUser’
    $db_pass = ‘P@sswd!’

    Then close and save the localconfig file.

  5. Run ./checksetup.pl again.
  6. Note: If you have installled everything including MySQL using the defaults, you will see this warning:

    WARNING: You need to set the max_allowed_packet parameter in your MySQL configuration to at least 3276750. Currently it is set to 1048576. You can set this parameter in the [mysqld] section of your MySQL configuration file.

    Resolve this using the MySQL configuration file called my.cnf. I discussed the my.cnf earlier in this article, so you should already be familiar with it.
    How to create a UTF-8 Unicode Database on MySQL and make UTF-8 Unicode the default?

    Find the max_allowed_packet settings and change it to 4M.

    max_allowed_packet = 4M

    Restart MySQL.

    ServerName# /usr/local/etc/rc.d/mysql-server restart
  7. Run checksetup.pl again.

    I got this error:

    Creating ./lib/.htaccess…
    No such file or directory at Bugzilla/Install/Filesystem.pm line 445, line 275.

    I had to manually create the /usr/local/www/apache22/data/bugzilla/lib directory then this error disappeared when I ran checksetup.pl again.

  8. Now create an Apache configuration file for bugzilla and put it in /usr/local/etc/apache22/Includes. I name it bugzilla.conf.

    bugzilla.conf

    <Directory "/usr/local/www/apache22/data/bugzilla">
      Options +ExecCGI
      AllowOverride Limit
      DirectoryIndex index.cgi
      AddHandler cgi-script .cgi
    </Directory>
    

    Restart Apache

    ServerName# /usr/local/etc/rc.d/apache22 restart
  9. You should now be able to connect to your server: http://YourServer/bugzilla


    Copyright ® Rhyous.com – Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.

How to install PHP5 and PHP5 Extensions on FreeBSD?

Note: Article updated for FreeBSD 9

Step 1 – Install FreeBSD

  1. First install FreeBSD. Instructions for installing FreeBSD is contained in one of these article.
    How I install FreeBSD 9?
    How I install FreeBSD? (versions before FreeBSD 9)
  2. Second update FreeBSD and install the ports tree. Instructions for this are in this article.
    What are the first commands I run after installing FreeBSD?

Step 2 – Install PHP

How to install PHP on FreeBSD from Ports

You can install easily from Ports.

  1. Go to the php5 directory in the ports tree.
    # cd /usr/ports/lang/php5
  2. Run ‘make config’ and select the desired options.
    # cd /usr/ports/lang/php5

    Note: If you want to integrate with Apache, you must select the Apache option.

  3. Run ‘make BATCH=yes install’ to install PHP5.
    # make BATCH=yes install

    PHP5 and its dependencies will download, compile, and install automagically for you.

    Note: If you want to script this, including the selecting to use Apache, use this command.

    # make WITH_APACHE=yes BATCH=yes install

How to install PHP on FreeBSD from Packages

  1. You can also install easily as a binary package with this simple command.
    # pkg_add -r php

Step 3 – Installing PHP5 Extensions on FreeBSD

You may now want to install PHP5 extensions for integration with your web server, such as Apache. There is a meta port that allows for installing all PHP5 extensions and we will use this for this example, though later we will demonstrate how to install a single extensions.

How to install php5-extensions from Ports

  1. Change to the php5-extensions ports directory.
    # cd /usr/ports/lang/php5-extensions
  2. Run ‘make config’ and select the php5-extensions you want to install when prompted.
    # make config

    Note 1: If you aren’t sure what to select, use the default, you can always come back and add more extensions later.

    Note 2: It may be important to you to make sure certain extensions are installed, such as extensions for MySQL, MySQLi, or Postgresl, especially if you are installing an Apache, MySQL, PHP server or a variant of such.

    Note 3: The extensions usually link to the release version of MySQL or PostgreSQL unless a new version is already installed. So if you want a later version, you may want to install the desired database port first.

  3. Run ‘make BATCH=yes install’ to install the selected php5-extensions.
    # make BATCH=yes install

    The PHP5-extensions and their dependencies will download, compile, and install automagically for you.

How to install PHP Extensions from Packages

  1. You can also install easily as a binary package with this simple command.
    # pkg_add -r php5-extensions

    Note: The package may not have all the extensions you desire. If not, use ports.

Step 4 – Integrating with Apache 2.x

  1. Change to the apache configuration directory.
    # cd /usr/local/etc/apache22
    
  2. Edit the httpd.conf with your favority edit. I use ‘ee’.
    # ee httpd.conf
  3. Search for “DirectoryIndex” to find the section where the directory index is configured.
  4. Add index.php as the first item as shown:
    DirectoryIndex index.php index.html
  5. Save and close the httpd.conf file.
  6. Change to the “Includes” directory.
    # cd /usr/local/etc/apache22/Includes
  7. Create a file with a name ending in .conf. I used php5.conf.
    # ee php5.conf
  8. Add the following two lines to the file.
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    
  9. Save and close the php5.conf file.

    Note: You could script this as follows:

    # # echo AddType application/x-httpd-php .php > /usr/local/etc/apache22/Includes/php5.conf echo AddType application/x-httpd-php-source .phps >> /usr/local/etc/apache22/Includes/php5.conf
  10. Restart apache.
    # /usr/local/etc/rc.d/apache22 restart

Step 5 – Test the PHP5 extensions integration with the web server

  1. Go to the web server’s root directory
    # cd /usr/local/www/apache22/data
  2. Create a file called phpinfo.php.
    # ee phpinfo.php
  3. Add the following lines to the file.
    <?php
      phpinfo();
    ?>
    

    Note: the phpinfo() function will automatically create a page full of information about the php configuration and the extensions installed and more.

  4. Save and close the phpinfo.php file.
  5. Now from another machine, browse to the server.

    You can connect using name, fqdn, or IP and see which work.

    • http://servername/phpinfo.php
    • http://www.YourDomain.com/phpinfo.php
    • http://192.168.0.100/phpinfo.php

    You can also try to connect with SSL.

    • https://servername/phpinfo.php
    • https://www.YourDomain.com/phpinfo.php
    • https://192.168.0.100/phpinfo.php
  6. You can now analyze the results of the phpinfo() function on this page.

    Note: Don’t forget to delete this file before putting the server in production. You wouldn’t want such an information disclosure vulnerability available for anyone to see.

Adding or Removing PHP5 extensions

You may find yourself needing to add another PHP5 extension. Maybe you didn’t install the database extensions and you need to add it and you can tell from phpinfo() that it is definitely not installed.

There are two ways to add or remove an extension. First, you could reinstall the meta port (though I wouldn’t recommend it). Second, you can find the specific PHP5 extensions you need and run ‘make install’ or ‘make deinstall’ for that specific port.

Note: Specific PHP5 extensions might take you a moment to locate. The php5-extensions meta port is under /usr/ports/lang but specific ports for extensions are not located there. The MySQLi extension, for example, is found under /usr/ports/databases.

Adding the MySQLi extension

  1. Change to the location of the MySQLi php5 extension.
    # cd /usr/ports/databases/php5-mysqli
  2. Run ‘make BATCH=yes install’ to install the extensions.
    # make BATCH=yes install

    The php5-mysqli extensions downloads and compiles automagically.

Removing the MySQLi extension

  1. Change to the location of the MySQLi php5 extension.
    # cd /usr/ports/databases/php5-mysqli
  2. Run ‘make deinstall’ to uninstall the extensions.
    # make deinstall

    The php5-mysqli extensions is removed.

Installing an Apache + SSL on FreeBSD using the ports tree

Installing Apache + SSL is very easy on FreeBSD.

Note: Tested on FreeBSD 9

  1. First install FreeBSD. Instructions for installing FreeBSD is contained in this article.
    How I install FreeBSD?
    How I install FreeBSD 9?
  2. Second update FreeBSD and install the ports tree. Instructions for this are in this article.
    What are the first commands I run after installing FreeBSD?
  3. Install the latest version of Apache, which is Apache 2.2 as of writing this.
    #
    #
    cd /usr/ports/www/apache22
    make BATCH=yes install

    This will download the Apache 2.2 source and compile and install it. A few other dependencies will be installed as well.

    Apache will not start automatically which is fine because we are not ready to start it yet.

  4. Configure Apache to automatically start when the FreeBSD system boots up. This is done using the /etc/rc.conf file.
    #
    #
    echo # Apache 2.2 >> /etc/rc.conf
    echo 'apache22_enable="YES"' >> /etc/rc.conf
  5. In order for Apache to use SSL, you must create a certificate. Now you may or may not know how to create one. I have made it easy for you by doing everything in a shell script. I have used SHA-256, because in this day an age, you need higher security than MD5 or SHA1.

    makesha256key.sh

    #!/bin/sh
    mkdir -p /root/mycert
    cd /root/mycert
    
    mkdir -p /usr/local/etc/apache22/ssl.key
    mkdir -p /usr/local/etc/apache22/ssl.crt
    chmod 0400 /usr/local/etc/apache22/ssl.key
    chmod 0400 /usr/local/etc/apache22/ssl.crt
    
    openssl genrsa -des3 -out $1.key 1024
    openssl req -new -x509 -nodes -sha256 -days 365 -key $1.key -out $1.crt
    
    cp $1.key $1.key.orig
    openssl rsa -in $1.key.orig -out $1.key
    
    cp $1.key /usr/local/etc/apache22/ssl.key/
    cp $1.crt /usr/local/etc/apache22/ssl.crt/
    chmod 0400 /usr/local/etc/apache22/ssl.key/$1.key
    chmod 0400 /usr/local/etc/apache22/ssl.crt/$1.crt
    

    This is NOT a fully functional shell script that shows you the command line options and everything. It is really just a list of commands to make this easier for you. Copy this to a shell script and run it. It takes one parameter, the cert name and you should call it like this:

    ./makesha256key.sh certname

    IMPORTANT: The commands in the script will prompt you for a Certificate password, and your Certification information. The only thing you need to make certain of is that when prompted for the “Common Name” you use the URL. For example, if your web site is www.rhyous.com, then www.rhyous.com is your Common Name.

    Or you can run the commands from the shell script manually one at a time if you want (replacing $1 with your desired certificate name).

    Note: In this script, the certificate will be a self-signed certificate, but you can get a signed certificate free here: http://cert.startcom.org

  6. Now configure Apache to read the httpd-ssl.conf file when it starts.

    Open the /usr/local/etc/apache22/httpd.conf using the easy editor or ee.

    # ee /usr/local/etc/apache22/httpd.conf

    Near the end of the file, remove the comment symbol, the # sign, from the following line:

    Include etc/apache22/extra/httpd-ssl.conf

    Note: While you are in this file you may want to remove the comment from the line for enabling Virtual Hosts too if you are going to have multiple URLs hosted at this page.

  7. Configure the httpd-ssl.conf.
    # ee /usr/local/etc/apache22/extra/httpd-ssl.conf

    I only change the two lines to point to the correct certificate. Here is an sample httpd-ssl.conf without the comments.

    Listen 443
    AddType application/x-x509-ca-cert .crt
    AddType application/x-pkcs7-crl    .crl
    SSLPassPhraseDialog  builtin
    SSLSessionCache        "shmcb:/var/run/ssl_scache(512000)"
    SSLSessionCacheTimeout  300
    SSLMutex  "file:/var/run/ssl_mutex"
    <VirtualHost _default_:443>
      DocumentRoot "/usr/local/www/apache22/data"
      ServerName www.example.com:443
      ServerAdmin you@example.com
      ErrorLog "/var/log/httpd-error.log"
      TransferLog "/var/log/httpd-access.log"
    
      SSLEngine on
    
      SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    
      SSLCertificateFile "/usr/local/etc/apache22/ssl.crt/server.crt"
    
      SSLCertificateKeyFile "/usr/local/etc/apache22/ssl.key/server.key"
    
      <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
      </FilesMatch>
      <Directory "/usr/local/www/apache22/cgi-bin">
        SSLOptions +StdEnvVars
      </Directory>
    
      BrowserMatch ".*MSIE.*" \
             nokeepalive ssl-unclean-shutdown \
             downgrade-1.0 force-response-1.0
    
      CustomLog "/var/log/httpd-ssl_request.log" \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    
    </VirtualHost>
    

  8. Now start or restart Apache.
    # /usr/local/etc/rc.d/apache22 start

Now just open a browser (on another system of course) and connect to your new FreeBSD installed web server. You can connect using name, fqdn, or IP and see which work.

  • http://servername
  • http://www.YourDomain.com
  • http://192.168.0.100

You can also try to connect with SSL.

  • https://servername
  • https://www.YourDomain.com
  • https://192.168.0.100

Common Errors

  1. Performing sanity check on apache22 configuration:
    httpd: apr_sockaddr_info_get() failed for F9
    httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
    Syntax OK
    Starting apache22.
    httpd: apr_sockaddr_info_get() failed for F9
    httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
    /usr/local/etc/rc.d/apache22: WARNING: failed to start apache22
    

    If you get this error, you need to update your /etc/hosts file and make sure the system’s hostname there.

    ::1                     localhost YourServerNameHere
    127.0.0.1               localhost YourServerNameHere
    

Install other software

It is now very common to install a database server and a scripting language, such as MySQL and PHP. I have separate documents for each install:

How to install MySQL FreeBSD?

How to install PHP5 and PHP5 Extensions on FreeBSD?

How to change the system date from the shell on FreeBSD?

The system date and time can be changed with the date command.

Set Date only

date YYMMDD

or

date YYYYMMDD

Set Date and Time

date YYMMDDHHMM

or

date YYYYMMDDHHMM

Set Time only

date HHMM

Example
So for example, if you want to set the date to Nov. 6, 2009 and the time to 8:58, you would use this command:

# date 0911060858

See man date for more information.

How to start, stop, restart MySQL on FreeBSD or Red Hat?

FreeBSD

Starting MySQL


/usr/local/etc/rc.d/mysql-server start

Stopping MySQL


/usr/local/etc/rc.d/mysql-server stop

Restarting MySQL


/usr/local/etc/rc.d/mysql-server restart

Red Hat

Starting MySQL


/etc/init.d/mysql start

or


/sbin/service mysql start

Stopping MySQL


/etc/init.d/mysql stop

or


/sbin/service mysql stop

Restarting MySQL


/etc/init.d/mysql restart

or


/sbin/service mysql restart

How to install MySQL on FreeBSD 7.2 or on Red Hat 5.4?

FreeBSD
There are two easy ways on FreeBSD:

From Ports

You can install easily from Ports. Make sure your ports tree is up to date:

$ su

Password:

ServerName#

ServerName#

ServerName#

portsnap fetch

portsnap extract

portsnap udpate

Then just do this to install MySQL on FreeBSD.

ServerName#

ServerName#

cd /usr/ports/databases/mysql51-server

make install

Or if you want to use utf8 by default, run this command:

ServerName# make WITH_CHARSET=utf8 install

MySQL 5.1 Server (and MySQL 5.1 client) will download, compile, and install automagically for you.

From Packages

You can also install easily as a binary package with this simple command.

ServerName# pkg_add -r mysql51-server

Make sure to secure you MySQL installation.
http://dev.mysql.com/doc/mysql-security-excerpt/5.1/en/default-privileges.html

Red Hat
Using RPM

You have to go to the MySQL site and download the MySQL 5.1 server RPM and install it.
http://dev.mysql.com/downloads/

It does not automatically install the MySQL client, you have to download that as a separate RPM and install it.

Using yum

Since I didn’t have a MySQL license, yum didn’t work, so I don’t know if it can be installed using yum.

Make sure to secure you MySQL installation.
http://dev.mysql.com/doc/mysql-security-excerpt/5.1/en/default-privileges.html


Copyright ® Rhyous.com – Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.

How to create a UTF-8 Unicode Database on MySQL and make UTF-8 Unicode the default?

How to create a UTF-8 Unicode Database on MySQL?

I am not going to cover installing, I have done that here:
How to install MySQL on FreeBSD 7.2 or on Red Hat 5.4?

So when you open MySQL using the command line MySQL client, you can see what Character Set your server is configured to use with this command:

show variables like 'character_set_server';

Often the default is Latin-1. I wish UTF-8 was the default but it is not.

You can see the language your database is created with by using this command:

show create database dbname

Again, usually the default is Latin-1 and again, I wish the default were UTF-8 but it is not.

So how do I make my MySQL database UTF-8?
How do I make UTF-8 the default?

I am going to find out…

Ok, so I have MySQL installed on two different platforms:
FreeBSD 7.2 x64.
Red Hat 5.4 x64.

My question are these:
What level do you set the Unicode setting at? Install instance, database, or column type.

MySQL – Looks like it can be configured globally in the my.cnf or it can be database specific.

To configure globally

Add the following to the my.cnf file:

[mysqld]
init_connect=’SET collation_connection = utf8_general_ci’
init_connect=’SET NAMES utf8′
default-character-set=utf8
character-set-server=utf8
collation-server=utf8_general_ci
skip-character-set-client-handshake

Note: There are other options for collation besides utf8_general_ci such as utf8_unicode_ci. See this article:
http://dev.mysql.com/doc/refman/5.1/en/charset-unicode-sets.html

Do I have to create the database in a special way?

Not if you configure the setting globally. However, if you don’t configure unicode support globally then yes you have to create your database in a specific way.

I found this post that is for an applications that uses a MySQL Unicode database. I don’t care about the application, just the MySQL data.
http://dev.mysql.com/doc/refman/5.1/en/create-database.html
http://dev.mysql.com/doc/refman/5.1/en/charset-applications.html

So the syntax will be:

CREATE DATABASE mydb   DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;

Do I have to compile differently to get unicode support?

I didn’t have to recompile on either FreeBSD or Red Hat.

Is there differences for each platform?

Slight differences.

FreeBSD

FreeBSD has the MySQL client as a dependency so it gets installed with the server with out any extra work.

The Database folder is /var/db/mysql.

For the global configuration there is not a my.cnf file created by default.

FreeBSD has example my.cnf files located here:

/usr/local/share/mysql
/usr/local/share/mysql/my-huge.cnf
/usr/local/share/mysql/my-innodb-heavy-4G.cnf
/usr/local/share/mysql/my-large.cnf
/usr/local/share/mysql/my-medium.cnf
/usr/local/share/mysql/my-small.cnf

You can create your own my.cnf or you can copy one of the examples.

In order to get the my.cnf to work, you should copy it and change the owner and add the [mysqld] settings.

#
#
#
?
?
?
?
?
?
?
?
#
cp /usr/local/share/mysql/my-medium.cnf /var/db/mysql/my.cnf
chown mysql:mysql /var/db/mysql/my.cnf
cat << EOF >> /var/db/mysql/my.cnf
[mysqld]
init_connect=’SET collation_connection = utf8_general_ci’
init_connect=’SET NAMES utf8′
default-character-set=utf8
character-set-server=utf8
collation-server=utf8_general_ci
skip-character-set-client-handshake
EOF

Red Hat

Red Hat does not have the MySQL client installed with the server, you have to download a separate RPM and install it. But it is really easy. Download both RPMs and install them.

The Database folder is /var/lib/mysql.

For the global configuration there is not a my.cnf file created by default.

Red Hat has example my.cnf files located here:

/usr/share/mysql
/usr/share/mysql/my-huge.cnf
/usr/share/mysql/my-innodb-heavy-4G.cnf
/usr/share/mysql/my-large.cnf
/usr/share/mysql/my-medium.cnf
/usr/share/mysql/my-small.cnf

Same as FreeBSD, there isn’t one used by default and you have to copy one and use it.
You can create your own my.cnf or you can copy one of the examples.

In order to get the my.cnf to work, you should copy it and change the owner and add the [mysqld] settings.

#
#
#
?
?
?
?
?
?
?
?
#
cp /usr/share/mysql/my-medium.cnf /var/lib/mysql/my.cnf
chown mysql:mysql /var/lib/mysql/my.cnf
cat << EOF >> /var/lib/mysql/my.cnf
[mysqld]
init_connect=’SET collation_connection = utf8_general_ci’
init_connect=’SET NAMES utf8′
default-character-set=utf8
character-set-server=utf8
collation-server=utf8_general_ci
skip-character-set-client-handshake
EOF

Copyright ® Rhyous.com – Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.

How do I install FreeBSD 8?

See the updated version here:
How to install FreeBSD 9

I do this:

  1. Download the DVD.
    1. Go to www.freebsd.org
    2. Click the yellow Get FreeBSD Now button
    3. Under your appropriate processor type (in my case it is usually i386 or amd64) click ISO.
    4. I download the DVD ISO. (You can download a bunch of CD ISOs if you want.)
    5. Note: There is also a boot only, which can download fast because it is small. I often use this option because of the way I install. However, it doesn’t have the install files, instead it just has the boot files. Once you get booted, it downloads the options you have chosen to install from FreeBSD’s website or a mirror. So while the download is faster, the install may take longer. However, if you are doing a minimal install, which I usually do, it could be faster than waiting for an entire DVD to download since the DVD includes a lot of data your won’t be using for a minimal install.

  2. Burn the ISO to disk. I am not going to explain how to do this but I will say this:
    Please make sure you don’t burn the ISO as a file on the disk, but instead you burn choose the option to burn a disk from the ISO.
  3. Boot from DVD.
    1. Put the DVD (or CD) in your drive.
    2. Turn on your system or if it is on, reboot it.
    3. Make sure you BIOS is configured to allow you to boot off the DVD or CD drive.
    4. Choose to boot from the DVD or CD drive.
  4. The first “gui-like screen you will see is the Country Selection screen. Choose your Country using the up and down arrows on your keyboard to highlight your country. Once your country is highlighted, hit Enter to choose OK.
  5. The next screen is the Main Menu. Again, use the up and down arrows on your keyboard to highlight Standard. Once Standard is highlighted, hit Enter to Select it.
  6. The following screen is an informational message. Read it if you like and hit enter to choose OK.
  7. The next screen appears like a DOS screen. It is asking how much of the disk you want to dedicate to FreeBSD. Dual-booting is actaully not common anymore because of virtualization such as VMWare, so I assume you are using the entire disk.

    Press “A” on the keyboard to select the Use Entire Disk option and then press “Q” to Finish.

  8. The next screen asks if you want a boot Manager. A boot manager is mostly likely used for dual booting, so choose Standard and hit enter.
  9. The following screen is a second informational message. Read it if you like and hit enter to choose OK.
  10. The next screen appears like a DOS screen and looks very similar to the previous DOS-like screen you saw, however it is not asking how much of the disk you are going to use for FreeBSD; instead, it is asking what partitions you want and how much space you want to allocate to each partition.

    Press “A” on the keyboard to select the Auto Defaults option and then press “Q” to Finish.

  11. The next screen is the Choose Distributions screen. So let’s choose your distributions.
    1. Use the down arrow to scroll all the way down to Custom and hit Enter. This brings up the “Select the distributions you wish to install” screen.
    2. Select base and hit Enter
    3. Select kernels and hit Enter and another screen appears.
      1. Select the GENERIC kernel and hit enter. This checks the box but does not continue.
      2. Press Tab to get the cursor over the OK button and hit enter. This takes you back to the “Select the distributions you wish to install” screen.
    4. Select games.

      You may want to skip this because you are thinking, this is my server, I don’t want games. But if you are reading this, then you are not a FreeBSD guru and you are problably a newbie. The “games” option includes simple command line only games and does not take up much space. The important thing is that it includes the feature where every time you log in, you get a nice tip. You can escape your newbie-ness by paying attention to these tips, so just select games already.

    5. Select man
    6. Press Tab to move the cursor over OK.
    7. Before hitting Enter, look at it one more time and make sure you have selected these options: base, kernels, games, man.

      Yes if you are NOT a newbie select whatever you want.

    8. Hit enter. This take you back to the Choose Distributions screen
  12. Just like the last screen, press Tab to move the cursor over OK and click enter.
  13. The next options is the Choose Installation Media screen. If you downloaded the CD or DVD, select CD/DVD (which is highligted by default) so just press enter.

    I am assuming you downloaded the DVD here. Screens may differ in order slightly if you used the Boot Only CD but you should be able to figure it out.

  14. The next screen is the User Confirmation Requested screen. Up until this point, nothing has been done to your system. You drive is untouched.

    Press Enter to choose Yes and install FreeBSD.

    The drive is formatted, configured to boot to FreeBSD, the partitions are created, and the base, kernels, games, man distributions are installed.

  15. The following screen is another informational message that tells you, “Congratulations! You now have FreeBSD installed on your system”. Read it if you like and hit enter to choose OK.
  16. Now you are at the Post-installation configuration screens. You will be asked a lot of questions, most of which you will say “No” too.

  17. Would you like to configure any Ethernet or SLIP/PPP network deices:

    Choose Yes.

    This opens the Network Interface screen.

    1. Select your Ethernet card and hit Enter. The card name is not always the same.
    2. Do you want to try IPv6 configuration of the interface?

      Choose No. (Maybe someday soon you will choose Yes here.)

    3. Do you want to try DHCP configuration of the interface?

      Choose No. (If you are not building a server then maybe you want DHCP but if you aren’t building a server, you should probably be installing PC-BSD.)

      The Network Configuration screen opens.

    4. Under Host enter you host name.
    5. Under Domain enter you domain name.
    6. Under IPv4 Gateway enter you default gateway’s IP address.
    7. Under Name server enter the DNS server’s IP address.
    8. Under IPv4 address enter the machine’s IP address.
    9. Under Netmask enter the subnet mask.
    10. Choose OK.
  18. Do you want the machine to function as a network gateway?

    Choose No.

  19. Do you want to configure inetd and the network services it provides?

    Choose No.

  20. Do you want to enable ssh login?

    Choose Yes.

  21. Do you want to have anonymous FTP access to this machine?

    Choose No.

  22. Do you want to configure this machine as an NFS server?

    Choose Yes.

  23. Do you want to configure this machine as an NFS client?

    Choose No.

  24. Would you like to customize your system console settings?

    Choose No.

  25. Would you like to set the machine’s time zone now?

    Choose Yes.

  26. Is this machine’s CMOS clock set to UTC?

    Choose No (unless you know that it is).

  27. Select a region.
  28. Select a Country.
  29. Select a time zone.
  30. Does the abreviation ‘MST’ look reasonable? (Your time zone acronym may be different.)

    Choose Yes.

  31. Would you like to enable Linux binary compatibility?

    Choose No.

  32. Does this system have a PS2, Serial, or bus mouse?

    Choose No if you have a USB mouse. Choose Yes if you have a PS2 mouse. (Usually a mouse that is not USB is uncommon these days, however, there are still plenty of PS2 mice around.)

  33. The FreeBSD package collection is a collection of thousands of ready to run applications, from text editors to games to WEB servers and more. Would you like to browse the collection now?

    Choose No.

  34. Would you like to add any initial user accounts to this system?

    Choose Yes.

    The User and Group Management screen appears.

  35. Select User and press Enter.

    The Add a new user screen appears.

    1. Under Login ID enter the user name.
    2. Leave the UID unchanged. By default is is 1001.
    3. Leave the Group field blank.
    4. Enter a password.
    5. Enter your full name.
    6. Under Member groups enter this group: wheel
    7. Leave the Home directory as is: /home/username
    8. Leave the Login shell as is: /bin/sh
    9. Tab to OK and press Enter.

      You are returned to the User and Group Management screen.

  36. Select Exit and press Enter.
  37. Now you must enter the systems management password.
    This is the password you’ll use to log in as root.

    Press Enter.

  38. Enter the new password.
  39. Retype the new password.
  40. Visit the general configuration menu for a chance to set any last options?

    You are returned to the sysinstall Main Menu.

  41. Tab to Exit Install and press Enter.
  42. Are you sure you wish to exit?

    Choose Yes. (Make sure to remove the bootable disk from the CD or DVD drive.

Your system will now reboot and FreeBSD should boot up.

Now check out my post about the updating FreeBSD.
What are the first commands I run after installing FreeBSD

This will tell you how to apply FreeBSD updates/patches and how to load the ports tree.


Copyright ® Rhyous.com – Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.

How do I install FreeBSD?

I have an article depending on the version you are trying to install

I also have aarticles for dual-booting.

What are the first commands I run after installing FreeBSD? Or How to patch FreeBSD? Or How to install ports on FreeBSD?

Ok, so you just installed FreeBSD, an maybe you are not familiar with it, so you think, “What now?”.

Well, think about what you do when you install any platform. You do three things:

  1. Apply patches/updates.
  2. Install software
  3. Post-installation configuration of system and software

For example, when you install a new windows operating system, it is common to go to Windows Update and update your server. Then you install software such as microsoft office, etc… The same for servers. You update the server, then maybe you add your server software. Then you configure it some more.

The order may vary for every install or you may even do this three step process multiple times.

Just because you are on FreeBSD does not mean the same three step process doesn’t apply. This three item process is operating system independent. It is the first thing I do on FreeBSD as well.

So here are the first commands that I run after logging into a new FreeBSD install.

$ su

Password:

ServerName#
ServerName#
ServerName#
ServerName#
freebsd-update fetch
freebsd-update install
portsnap fetch
portsnap extract

Same commands in a nice script/code box you can use to copy and paste.

freebsd-update fetch
freebsd-update install
portsnap fetch
portsnap extract

Let me explain what each command does:

  1. freebsd-update fetch – This download patches that have been released for the version of FreeBSD you have installed. It does not install the patches.
  2. freebsd-update install – This command installs the patches that were previously download.
  3. portsnap fetch – This download a compressed version of the ports tree. Ports means applications that have been ported or developed to compile and run on FreeBSD. So the ports tree is basically a database of available software that can be install on FreeBSD.
  4. portsnap extract – This extracts the compressed version of the ports tree.

So with these four commands you have your system updated/patched. You also have all the software that is available ready to be installed.

Update 1:

I am not sure why i didn’t know this before, but you can combine each pair of commands into one command:

ServerName#
ServerName#
freebsd-update fetch install
portsnap fetch extract
freebsd-update fetch install
portsnap fetch extract

Stay tuned for my article on searching the ports tree.

Update 2:

As you can read in the comments, it is good to know that you only have to “extract” the ports tree once and for every subsequent update to the ports tree, you should only run it with the “update” command as shown.

portsnap fetch update

Which Operating System release are you most excited about?

How long have you been using Windows 7?

So Windows 7 has been around in Release To Manufacturer (RTM) for since August 14, 2009.

Many have been using it in production since then. In fact, many have been using in Production since it was still in beta/release candidate form.

I have been using it for 1 month.

Quick Opinion
It is so much better than Vista and XP that it would take a novel to describe all the ways it is better. Most of them are simple things.

Anyway, please post comments on how long you have been using Windows 7 and why you like it.

Windows 7 64 bit VPN Client – ShrewSoft

Ok, so I couldn’t get Cisco’s VPN client to work for Windows 7 64 bit. So I went in search of another VPN solution that would be more compatible.

(UPDATE: I got ShrewSoft’s VPN Client working, so keep reading down below.)

I came across ShrewSoft’s VPN Client a while ago, but it originally blue screened my Windows 7 box, but it was a version that didn’t support Windows 7. However they have a new version that is out that is for Windows 7 64 bit. Actually they now have a release version on their download site but there is a beta of the next version (Update 3/05/2010)2.1.6-beta-6 that your may want to use (or a later version if you are reading this well after I wrote or updated it). See the comments on why.

I installed it and it requested a reboot so I rebooted, and the first good news is that I didn’t blue screen when my workstation booted up. Horray!!!

After installing, I tested undocking my laptop from its docking station and then docking my laptop, and again, no blue screens, so I think it is good to go. Now I just have to figure out how to configure it to connect here at work.

I like the license, they say:

The Shrew Soft Client for Windows is free for both commercial and private use. Please read below for complete license details. Click here…

Stay tuned for more testing….

Ok…I am back for more notes.

At work we are using a Cisco VPN solution, so it turns out that when my Cisco VPN would install on a 32 bit machine, it used a .pcf file. Well, guess what is awesome about ShrewSoft’s VPN Client? It can import a .pcf file.

I imported the .pcf file and I appear to connect, then disconnect. Not sure what is going on. I am at work, but I should be able to connect to the VPN while at work, at least that is what my IT staff said.

So hopefully it connects when I am at home.

Here is my log:

config loaded for site ‘MyConfig.pcf’
configuring client settings …
attached to key daemon …
peer configured
iskamp proposal configured
esp proposal configured
client configured
local id configured
pre-shared key configured
bringing up tunnel …
network device configured
tunnel enabled
session terminated by gateway
tunnel disabled
detached from key daemon …

I will try to debug later…

All right I am back again and I am trying to debug. I found this post:
http://lists.shrew.net/pipermail/vpn-help/2009-October/002282.html

There is a program under Start | All Programs | Shrew Soft VPN Client called “Trace Utility” that is installed with the Shrew Soft VPN Client can be used for debugging. However, it wouldn’t work for me. The buttons weren’t enabled.

I had to right-click on the “Trace Utility” shortcut and choose “Run as administrator” then I was able to turn on debugging.

Positives for Shrew Soft VPN Client
– It has a debugging utility.
– It supports Windows 7 64 bit
– It imports cisco .pcf files.
– There is a lot of documentation.

Negatives for Shrew Soft VPN Client
– I don’t have it working yet
– There is not really any clear failure reason for a user.

So I will keep at it. I think I am about going to email the developer, but I sure don’t want to bug him.

Hopefully for some of you, it worked first time for you when you imported the .pcf file.

Got it working

Another positive. The developer has a mailing list, as you saw with one of my links above. I found this link:
http://lists.shrew.net/pipermail/vpn-help/2009-October/002275.html

The key piece of information I needed was this:

If it gets to the ‘tunnel enabled’ point, that means you completed phase1, Xauth and modecfg negotiations. Its probably a phase2 option. As I mentioned to others on the list, try playing with the PFS setting or enabling the cisco-udp NAT-T option.

In the tool, after importing my .pcf file, I only had to make one configuration change. I had to change the PFS setting to “group 2”. See this screen shot.

VPN Setting

So I have this working now.

I have to say that I am very impressed with Shrew Soft. It took me some time to figure it out, but it works. Now the only question time will tell is how stable it is. Expect an update in a week or two about whether I think the Shrew Soft VPN Client is stable.

The steps are easy for me to connect to my VPN at work. Now every VPN is different so I am sorry if these steps don’t work for you:

  1. Use the correct (and latest) version: 2.1.6-beta-6 or later
  2. Install Shrew Soft VPN Client
  3. Reboot.
  4. Import the .pcf file.
  5. Modify the configuration and change the PFS setting to “group 2”.
  6. Apply the configuration.
  7. Click connect.
  8. Enter your domain user and password and you will connect.

Success!!!!

Also, I exported my configuration as a Shrew Soft VPN Client export, which is a .VPN file. When I import it, I don’t have to make a configuration change like I did with the Cisco .pcf file.

Key words: cisco vpn window 7 64 bit