<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>david winter &#187; mysql</title>
	<atom:link href="http://davidwinter.me.uk/articles/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://davidwinter.me.uk</link>
	<description>you were expecting someone else?</description>
	<lastBuildDate>Mon, 28 Jun 2010 20:37:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Installing MySQL for PHP with MacPorts</title>
		<link>http://davidwinter.me.uk/articles/2010/02/28/installing-mysql-for-php-with-macports/</link>
		<comments>http://davidwinter.me.uk/articles/2010/02/28/installing-mysql-for-php-with-macports/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 13:38:02 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/?p=162</guid>
		<description><![CDATA[In my other howto, I installed Apache, PHP and MongoDB. I now need to setup MySQL so that I can develop a WordPress theme and plugin on my local machine. Here are the few steps I used: sudo port install mysql5-server sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist sudo -u _mysql mysql_install_db5 sudo chown -R _mysql:_mysql /opt/local/var/db/mysql5/ [...]]]></description>
			<content:encoded><![CDATA[<p>In my other howto, I installed Apache, PHP and MongoDB. I now need to setup MySQL so that I can develop a WordPress theme and plugin on my local machine. Here are the few steps I used:</p>

<p><span id="more-162"></span></p>

<pre><code>sudo port install mysql5-server
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
sudo -u _mysql mysql_install_db5
sudo chown -R _mysql:_mysql /opt/local/var/db/mysql5/ 
sudo chown -R _mysql:_mysql /opt/local/var/run/mysql5/ 
sudo chown -R _mysql:_mysql /opt/local/var/log/mysql5/
</code></pre>

<p>I then add the following aliases to make it easy to start, stop and restart MySQL:</p>

<pre><code>mate ~/.bashrc

alias mysql-start="sudo /opt/local/share/mysql5/mysql/mysql.server start"
alias mysql-restart="sudo /opt/local/share/mysql5/mysql/mysql.server restart"
alias mysql-stop="sudo /opt/local/share/mysql5/mysql/mysql.server stop"

source ~/.profile
</code></pre>

<p>You can then use the following to start MySQL:</p>

<pre><code>mysql-start
</code></pre>

<p><em>Note: I had errors when I first tried starting MySQL. This was because I&#8217;d installed a version of MySQL previously from the official site and it was conflicting. Removing the old version of MySQL did the trick &#8211; instructions <a href="http://tomkeur.net/39/how-to-remove-mysql-completely-mac-os-x-leopard.html">here</a>.</em></p>

<p>When you start the server, it&#8217;s best to set the <code>root</code> user password:</p>

<pre><code>mysqladmin5 -u root password mysupersecretpassword
</code></pre>

<p>Then to setup PHP to work with MySQL:</p>

<pre><code>sudo port install php5-mysql
</code></pre>

<p>Then update the php.ini file:</p>

<pre><code>sudo nano /opt/local/etc/php5/php.ini
</code></pre>

<p>And ensure this line is in there:</p>

<pre><code>mysql.default_socket = /opt/local/var/run/mysql5/mysqld.sock
</code></pre>

<p>Restart Apache, and then you&#8217;re all set.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2010/02/28/installing-mysql-for-php-with-macports/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu 5.10 web server howto</title>
		<link>http://davidwinter.me.uk/articles/2006/02/05/ubuntu-5-10-web-server-howto/</link>
		<comments>http://davidwinter.me.uk/articles/2006/02/05/ubuntu-5-10-web-server-howto/#comments</comments>
		<pubDate>Sun, 05 Feb 2006 08:58:40 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/articles/2006/10/13/ubuntu-5-10-web-server-howto/</guid>
		<description><![CDATA[I reinstalled my home server today (well, I actually started yesterday, but today I finished from scratch again) and wrote down what I did. My aim was to have a web server set up using Apache that I could use to host this blog which uses Ruby on Rails. Also, I wanted to set-up Webmin [...]]]></description>
			<content:encoded><![CDATA[<p>I reinstalled my home server today (well, I actually started yesterday, but today I finished from scratch again) and wrote down what I did. My aim was to have a web server set up using Apache that I could use to host this blog which uses Ruby on Rails. Also, I wanted to set-up Webmin and Bind so I could manage the DNS stuff from here.</p>

<p>So, here we go! If you find any errors, or have any problems, leave a comment and I&#8217;ll try and help.</p>

<p><span id="more-13"></span></p>

<h3>The headache begins</h3>

<p>I&#8217;m assuming that you&#8217;ve just completed a new default install of Ubuntu 5.10.</p>

<p>As my space PC/server is up in the loft, and it&#8217;s freezing up there, the first thing I did was to enable XDMCP on Ubuntu so I could connect to it from my Mac downstairs in my nice warm bedroom. You can read how to do that <a href="http://davidwinter.me.uk/articles/2005/12/08/xdmcp-for-mac" title="Setting up XDMCP for Mac">here</a>. </p>

<p>With XDMCP now running, before I can connect to it via my Mac, I set the IP address of the machine to 192.168.0.1 &#8211; a nice number that&#8217;s easy to remember.</p>

<p>Back in my room I&#8217;m connected to Ubuntu via XDMCP and it&#8217;s as if I&#8217;m sitting up in the loft.</p>

<p>If you&#8217;re not using XDMCP (and even if you are you should follow this step), you&#8217;ll want to connect via SSH. Install it using:</p>

<pre><code>sudo apt-get install ssh
</code></pre>

<p>There are some packages that are needed that aren&#8217;t in the default repositories for <code>apt</code>, so you have to enable them manually. Universe and Multiverse are needed.</p>

<p>To enable the Universe servers, I did</p>

<pre><code>sudo nano /etc/apt/sources.list
</code></pre>

<p>Inside that file, uncomment the two lines that look something like this:</p>

<pre><code>deb http://gb.archive.ubuntu.com/ubuntu breezy universe
deb-src http://gb.archive.ubuntu.com/ubuntu breezy universe
</code></pre>

<p>Hit Control O to save and press enter to use the same filename. Then press Control X to close Nano.</p>

<p>I could probably enable the Multiverse stuff in there too, but as I&#8217;ve not tested it like that, I&#8217;ll leave it to exactly how I did it.</p>

<p>Open up the Synaptic Package Manager
1. Settings
2. Repositories
3. Add
4. Check Multiverse
5. Click OK and let it rescan the servers.</p>

<p>You can then close Synaptic. <code>apt</code> is now all set up ready for installing the packages we need.</p>

<p>Before we start installing the packages we want, do a system update:</p>

<pre><code>sudo apt-get update
</code></pre>

<h4>Ruby</h4>

<p>All on one line:</p>

<pre><code>sudo apt-get install irb libdbm-ruby1.8 libfcgi-ruby1.8 libfcgi0 libgdbm-ruby1.8 libmysql-ruby1.8 libmysqlclient12 libopenssl-ruby1.8 libruby1.8-dbg mysql-common ri ri1.8 ruby1.8-dev ruby
</code></pre>

<h4>MySQL Server</h4>

<pre><code>sudo apt-get install mysql-server
</code></pre>

<p>During this install, a Postfix config screen will appear. Select OK and then &#8220;No configuration&#8221;.</p>

<h4>Ruby Gems &amp; Rails</h4>

<p>This is the standard way of installing ruby applications.</p>

<p>Need to download it directly from its web site:</p>

<pre><code>wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
</code></pre>

<p>Then extract it:</p>

<pre><code>tar xvfz rubygems-0.8.11.tgz
</code></pre>

<p>Move into the extracted directory:</p>

<pre><code>cd rubygems-0.8.11
</code></pre>

<p>Run the setu-p program:</p>

<pre><code>sudo ruby1.8 setup.rb
</code></pre>

<p>Update all installed gems on the system:</p>

<pre><code>sudo gem update --system
</code></pre>

<p>Now that Ruby Gems is installed, we can install Rails.</p>

<pre><code>sudo gem install rails -y
</code></pre>

<h4>Apache 2</h4>

<p>Next is the web server I&#8217;m using. Apache 2. The following command will install Apache 2, FastCGI, FCGI, PHP 5 with MySQL functionality. PHP isn&#8217;t needed for Ruby or Rails, but I&#8217;m including it so that I can run PHP apps&#8230;</p>

<pre><code>sudo apt-get install apache2 libapache2-mod-fcgid libapache2-mod-fastcgi libapache2-mod-php5 php5-mysql
</code></pre>

<p>Once that&#8217;s done, we&#8217;ll need to enable the Apache mods we&#8217;ll be using:</p>

<pre><code>sudo a2enmod fcgid
sudo a2enmod fastcgi
sudo a2enmod rewrite
</code></pre>

<p>You&#8217;ll notice I&#8217;ve installed two different types of Fast CGI. That&#8217;s because at some point I want to try them both out. However, at the moment, I&#8217;ve only had success with getting FastCGI working decently.</p>

<p>Restart Apache to make sure all is well.</p>

<pre><code>sudo /etc/init.d/apache2 restart
</code></pre>

<h4>FastCGI</h4>

<p>I thought FastCGI would have been installed after doing the libapache2-mod-fastcgi &#8211; but for some reason, you have to install it manually.</p>

<p>In order to configure and build from the source files, you need to download some basic files:</p>

<pre><code>sudo apt-get install build-essential
</code></pre>

<p>Then, grab the FastCGI files from the web site:</p>

<pre><code>wget http://fastcgi.com/dist/fcgi-2.4.0.tar.gz
</code></pre>

<p>Extract:</p>

<pre><code>tar xvfz fcgi-2.4.0.tar.gz
</code></pre>

<p>Move into the directory:</p>

<pre><code>cd fcgi-2.4.0
</code></pre>

<p>Configure the installer:</p>

<pre><code>./configure
</code></pre>

<p>Install:</p>

<pre><code>sudo make install
</code></pre>

<p>Now, that is all of the Apache and FastCGI files installed. Later, we&#8217;ll need to configure it all.</p>

<h4>Webmin</h4>

<p>Webmin is ugly, but it works, and it lets us configure Apache and the Nameserver easily.</p>

<p>Go to http://www.webmin.com/ and download the latest version of webmin in tar.gz format.</p>

<p>Once downloaded, extract it (filename may vary depending on the version you download):</p>

<pre><code>tar xvfz webmin-1.260.tar.gz
</code></pre>

<p>Move into the directory:</p>

<pre><code>cd webmin-1.260
</code></pre>

<p>Run the set-up program:</p>

<pre><code>sudo ./setup.sh /usr/local/webmin
</code></pre>

<p>You can use the default settings for this, or change them if you know what you&#8217;re doing. Be sure to set a password you can remember.</p>

<p>At the end of the set-up you&#8217;ll be given an address to use to connect to webmin. Remember this! and go to it straight away and login.</p>

<p>Do the following to configure Webmin to work with Apache:
1. At the top, click on the &#8220;Servers&#8221; link.
2. Select Apache Webserver.
3. Select Module Config.
4. Set the following values:
    * Apache Server Root &#8211; /etc/apache2
    * Path to httpd executable &#8211; /usr/sbin/apache2
    * Path to httpd.conf &#8211; /etc/apache2/httpd.conf
    * Command to start Apache &#8211; /etc/init.d/apache2 start
    * Command to stop Apache &#8211; /etc/init.d/apache2 stop</p>

<p>Save these settings.</p>

<h4>Nameserver</h4>

<p>I&#8217;m no DNS expert, so this is very vague and I suggest you go read a howto on DNS&#8230; <a href="http://rimuhosting.com/support/bindviawebmin.jsp">here&#8217;s one</a> I used to complete this part.</p>

<p>This will be different depending on your set-ups. For me, I have my domain name pointing to my web server in America that hosts http://commanderbond.net </p>

<p>On the server, there, I have the DNS pointing to my Internet IP at home, here in the UK.</p>

<p>The nameserver I&#8217;m using is Bind.</p>

<pre><code>sudo apt-get install bind9
</code></pre>

<p>Once that&#8217;s installed, we need to configure it in Webmin.
1. Click the &#8220;Servers&#8221; link.
2. Select BIND DNS Server.
3. A message will appear about a configuration file. Select the 3rd option &#8220;Setup as an internet name server, but use Webmin&#8217;s older root server information&#8221;
4. Create a Master Zone and enter the following details:
    * Domain Name &#8211; yourdomain.com
    * Email &#8211; you@anemail.com
5. Click on &#8220;Create&#8221;.
6. Click on the &#8220;Address&#8221; link.
7. Create a new Address record using the following:
    * Name &#8211; yourdomain.com. (including the trailing dot)
    * Address &#8211; your Internet IP address
8. Click on &#8220;Create&#8221;.
9. Go to the Module Index.
10. Click on &#8220;Apply Changes&#8221;.</p>

<h4>Set-up your web site</h4>

<p>You&#8217;ll need somewhere to store your web site files, so I suggest to first of all create a <code>public_html</code> directory in your user directory.</p>

<pre><code>mkdir ~/public_html
</code></pre>

<p>Now we&#8217;ll create a test HTML file to check all is working so far.</p>

<pre><code>nano ~/public_html/index.html
</code></pre>

<p>Inside it put the following:</p>

<pre><code>&lt;p&gt;Hopefully you can see this...&lt;/p&gt;
</code></pre>

<p>Save the file using Control O and then Control X to quit Nano.</p>

<p>Now, set the permissions of the file so it&#8217;s visible to the world:</p>

<pre><code>chmod 644 ~/public_html/index.html
</code></pre>

<p>In Webmin, go to the Apache configuration.</p>

<p>Create a new Virtual Server with the following:
* Document Root &#8211; home/yourusername/public_html
* Server Name &#8211; yourdomain.com</p>

<p>Save the settings. Now restart Apache:</p>

<pre><code>sudo /etc/init.d/apache2 restart
</code></pre>

<p>Now visit http://yourdomain.com/~yourusername/ and you should see:</p>

<blockquote>
  <p>Hopefully you can see this&#8230;</p>
</blockquote>

<p>If so, excellent! If not, hmmm&#8230; maybe you didn&#8217;t follow everything? or I made a mistake somewhere&#8230; leave a comment below.</p>

<p>Take a 5 minute break!</p>

<p>Refreshed? Right. Moving on&#8230;</p>

<h4>phpMyAdmin for MySQL management</h4>

<p>Go to http://www.phpmyadmin.net/home_page/index.php and download the latest stable release of phpMyAdmin in tar.gz format.</p>

<p>Extract:</p>

<pre><code>tar xvfz phpMyAdmin-2.7.0-pl2.tar.gz
</code></pre>

<p>Move the directory to some place helpful:</p>

<pre><code>mv phpMyAdmin-2.7.0-pl2 ~/phpmyadmin
</code></pre>

<p>Move into that directory:</p>

<pre><code>cd ~/phpmyadmin/
</code></pre>

<p>Create a new configuration file:</p>

<pre><code>cp config.default.php config.inc.php
</code></pre>

<p>Change the authentication mode to http</p>

<pre><code>gedit config.inc.php
</code></pre>

<p>Change this line:</p>

<pre><code>$cfg['Servers'][$i]['auth_type'] = 'config';
</code></pre>

<p>&#8230;to this line:</p>

<pre><code>$cfg['Servers'][$i]['auth_type'] = 'http';
</code></pre>

<p>Save the file.</p>

<p>Back in the command line, we need to set the root password, because by default, there isn&#8217;t one! </p>

<pre><code>mysql -u root
</code></pre>

<p>You&#8217;ll then enter the MySQL console. Enter the following:</p>

<pre><code>UPDATE mysql.user SET Password=PASSWORD('newpasswordhere') WHERE User='root';
</code></pre>

<p>This will set the root password. Now flush the privileges:</p>

<pre><code>FLUSH PRIVILEGES;
</code></pre>

<p>Now exit:</p>

<pre><code>exit
</code></pre>

<p>Now, we want phpMyAdmin accessible on the server &#8216;globally&#8217;. So that it doesn&#8217;t matter what address we&#8217;re using, we&#8217;ll still be able to access it.</p>

<p>In Webmin, under Apache Webserver:
1. Select &#8220;Default Server&#8221;
2. Aliases and Redirects
3. Under &#8220;Document directory aliases&#8221; enter <code>/phpmyadmin/</code> into the first text box, and <code>/home/davidwinter/phpmyadmin/</code> into the box to the right of that one.</p>

<p>Save, and in the Terminal restart apache:</p>

<pre><code>sudo /etc/init.d/apache2 restart
</code></pre>

<p>Go to http://yourdomain.com/phpmyadmin/</p>

<p>Login in using &#8220;root&#8221; and the password you set in the MySQL console.</p>

<p>You can do any MySQL configuration here. For me, I restored my Typo database for this blog from a backup.</p>

<h4>FastCGI configuration with a Rails application</h4>

<p>This part is what gets a Rails app running really fast.</p>

<p>You&#8217;ll need to configure the FastCGI config file:</p>

<pre><code>sudo nano /etc/apache2/mods-enabled/fastcgi.conf
</code></pre>

<p>Here is my config file:</p>

<pre><code>&lt;IfModule mod_fastcgi.c&gt;
  #FastCgiWrapper /usr/lib/apache2/suexec2
  FastCgiIpcDir /var/lib/apache2/fastcgi
  FastCgiConfig -maxClassProcesses 2 -maxProcesses 2 -minProcesses 2 -processSlack 2
  FastCgiServer /home/davidwinter/typo/public/dispatch.fcgi -idle-timeout 120 -processes 2 -initial-env RAILS_ENV=production
&lt;/IfModule&gt;
</code></pre>

<p>The following line of the above:</p>

<pre><code>FastCgiServer /home/davidwinter/typo/public/dispatch.fcgi -idle-timeout 120 -processes 2 -initial-env RAILS_ENV=production
</code></pre>

<p>Is important. You need to specifiy a line like this for each Rails app you&#8217;ll be using under FastCGI.</p>

<p>Now, in your Rails application directory check that in <code>public/.htaccess</code> has this line:</p>

<pre><code>AddHandler fastcgi-script .fcgi
</code></pre>

<p>And, that in the rewrite rules section, it has this:</p>

<pre><code>RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
</code></pre>

<p>&#8230;instead of:</p>

<pre><code>RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
</code></pre>

<p>Notice <code>.fcgi</code> instead of <code>.cgi</code></p>

<p>And that&#8217;s about it!</p>

<p>Give Apache one final restart:</p>

<pre><code>sudo /etc/init.d/apache2 restart
</code></pre>

<p>And you should now have everything working.</p>

<p>As I said, any problems, leave a comment and I&#8217;ll try and help.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2006/02/05/ubuntu-5-10-web-server-howto/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
