Skip to content →

Category: web

math2.0-setup : final comments

Last time I promised to come back explaining how to set-up LaTeX-support, figuring I had to tell you about a few modifications I had to make in order to get Latexrender run on my mac…

A few google searches made it plain how out of touch I am on these matters (details below). But first, there was this comment to this series by Link Starbureiy :

“I took part in Gowers’ blog discussion. My input was to move things over to Google collaboration tools, like Google Knol, and perhaps Google Sites. However, those tools for large-scale collaboration may not be the best solution anymore. I like the NSN idea, but worry about it’s very long-term stability. Would you consider porting the project over to the Google App Engine so that it can be played with in the orkut sandbox (http://sandbox.orkut.com)?”

I thought I made it clear from the outset that I didn’t want to spend the rest of my life web-mastering a site such as NSN. All I wanted to show is that the technology is there free for the taking, and show that you do not have to be a wizard to get it running even on a mac…

I would really love it when some groups, or universities, on institutes, would set up something resembling this dedicated to a single arXiv-topic. Given our history, Antwerp University might be convinced to do this for math.RA but (a) I’m not going to maintain this on my own and (b) there may very well be a bandwidth problem if such a thing would become successful… (although, from past experiences and attempts I’ve made over the years, this is extremely unlikely for this target-group).

So please, if your group has some energy to spare, set-up your own math2.0-network, port it to Google Apps, Knol, Orkut or whatever, and I’d love to join and contribute to it.

As to LaTeX-support : this is trivial these days. First you need a working LaTeX-system on your virgin macbook. The best way is to download The MacTeX-2008 Distribution at work (it is a huge 1.19Gb download…). Next, install the fauxml-wordpress plugin (that is, download it to YourHome/Downloads and then drag the file faux-ml.php to the Library/WebServer/Documents/wp-content/plugins/ directory. Next, install likewise the WP-LateX plugin following the instructions, go to the configuring page and set the directory for latex and dvipng (if you follow my instructions they should be located at /usr/texbin/latex and /usr/texbin/dvipng), fill in the text color and background color you desire and clip your default latex-documentstyle/includepackages/newcommands section from your latest paper into the LaTeX Preamble window and believe me, you’re done!!!



One Comment

math2.0-setup : WpMU and BuddyPress

Last time we took a clean mac os x 10.5.6 installation and upgraded it to a MySQL and Apache-PHP+ server. This hour we’ll turn it into a math2.0-test environment. That is, we will install WordPressMU (the ‘multiple user’ version of WordPress which can host 10 or 100 or thousands of blogs on your computer). Then, we’ll turn this potential into a FaceBook-like social network.

Probably it is best to test this just on your ‘localhost’ before going worldwide. Therefore, I’ll describe here the test-environment-version (the changes to make for going www I’ll describe later, but, they are minor). Here’s the first problem : WordPressMu doesn’t recognize ‘localhost’ as a valid domain, so we’ll have to use something like ‘localhost.localdomain’ and tell our server to recognize this new address.

Open TextWrangler, under File/Open File by Name type /etc/hosts and add (again you’ll be asked to unlock the file as it is owned by ‘root’ and you’ll have to provide your sudo-password when you want to save it) to the end of that file (it’s short) the line

127.0.0.1 localhost.localdomain

Save it.Your file should now look like this



You can verify this by opening Safari and pointing it to http://localhost.localdomain. You should now see the default Apache-page (no need to restart the WebServer). Next, within TextWrangler do again a File/Open File by Name and type /etc/apache2/httpd.conf and under Search/Go to Line… say 211. The highlighted line reads

AllowOverride None

change it to (again the root and sudo routine as before)

AllowOverride All

and save it. Restart the WebServer (that is, open SystemPreferences go to Sharing, unmark and remark again after a tiny delay WebSharing). Okay, I think we are set


WordPress MU :

We need a database to store everything. If your database-root password set last time is myRootPassword then do the following (change to whatever it really is). Open Terminal and type to the prompt

mysql -u root -p

and provide MyRootPassword when asked. Now we have to tell MySQL to create a database, set a database-user and password (for safety reasons it better be a new user and password, but as this is merely a test-environment…). So, to the mysql-prompt we type the following string of commands

mysql> CREATE DATABASE mywordpressMU;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON mywordpressMU.* TO root@localhost IDENTIFIED BY “MyRootPassword”;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> SET PASSWORD FOR root@localhost = OLD_PASSWORD(“MyRootPassword”);
Query OK, 0 rows affected (0.01 sec)

mysql> EXIT
Bye

The OLD_PASSWORD-command seems odd, but is needed as WordPress doesn’t like the password-structure of MySQL 5. If you forget this, you’ll get database-errors.

Open Safari and download the latest WordPressMU here. Open two Finder windows, one pointing to YourHome/Downloads (in which a new folder “wordpress-mu” is created and another one pointing to “Macintosh HD/Library/WebServer/Documents. You may as well drop the content of this Documents-directory into the Trash (the file test.php we created last time excluded).

Select everything in the first-window wordpress-mu directory and drag all of it to the second-window Documents directory.



Open Terminal and type these to the prompt

$ cd /Library/WebServer
$ sudo chmod 777 Documents
Password: (fill in your sudo password)
$ cd Documents
$ sudo chmod 777 wp-content

Point your Safari to http://localhost.localdomain/index.php and you should get a WordPress mu install page. Make sure to choose the Sub-directories option (instead of the default sub-Domain option) and fill out the required info



You should get a success-page giving you the first password to login as admin. (In case you get a database-error, remove the wp-config.php file, redo the OLD_PASSWORD command given above and repeat the install. Everything should work!). Do this, go to the Users-tab and edit your admin-account to change the password (at the bottom) to something you can remember easily.

Remember to change the directory permissions again to 755. That is, open Terminal and do

$ cd /Library/WebServer
$ sudo chmod 755 Documents
Password: (fill in your sudo password)
$ cd Documents
$ sudo chmod 755 wp-content

We now have a working WordPressMU, you can create new users and they can start new blogs, but there isn’t yet any interaction between these users and your site looks, well…



Let’s spice it up a bit with

BuddyPress :

BuddyPress is a set of WordPress MU specific plugins, each plugin adding a distinct new feature. BuddyPress contains all the features you’d expect from WordPress but aims to let members socially interact.”

We start by getting the BuddyPress Combo Download (say the .zip file) which will create a buddypress-combo directory in YourHome/Downloads. Open this directory and as before drag its entire content to /Library/WebServer/Documents/wp-content/mu-plugins.

In the buddypress-theme directory there are two subdirectories which need to be put elsewhere. The subdirectory buddypress-home must be dragged to the wp-content/themes directory (containing at the moment only the classic, default and home theme) and the subdirectory member-themes must be dragged to the wp-content directory



Log in again as admin in your WpMU via http://localhost.localdomain/wp-admin/ under Site Admin/Themes activate the BuddyPress Home Theme and press the ‘Update Themes’ button.



Similarly, in Site Admin/Options mark under ‘Allow new registrations’ the option ‘Enables. Blogs and user accounts can be created’ and update these options via the button at the bottom. Finally, under Appearance click on the BuddyPress Home Theme and activate it (top right).

Now, visit your site and change it to your liking via adding widgets. For example, add ‘Welcome’, ‘Recent Blog Posts’ and ‘Site Wide Activity’ to the left column, ‘Who’s Online’ and ‘Members’ to the center column and ‘Groups’ and ‘Meta’ to the right column.

Next, create new users (via Site Admin/Users and not via signup as this is just an offline test-version and signup sends out activating emails…), create groups, blogs and posts, let users befriend one another and send wires, etc. etc. all the things people do in a web2.0 environment.

One further comment : if you want to have avatars uploaded you’ll have to open Terminal and type the following :

$ cd /Library/WebServer/Documents
$ sudo mkdir avatars
$ sudo chown _www:admin avatars

Finally, if your iMac is a proper web-server (that is, has its own URL) you can take your math2.0-network worldwide repeating the above procedure with obvious modifications (that is, replacing localhost.localdomain by the URL of your machine). In order to get the signup/email system going you may need to install the Swift-SMTP-Mailer plugin and feed it your outgoing mail-server (also you’ll have to enable plugins in the SiteAdmin/Options).

An embryonal version of your site may then look like this one



While this may already be good enough for the rest of the world, mathematicians talk LaTeX to each other, so we’d better include LaTeX-support (and perhaps also some Wiki-support). This we will do another time…

Leave a Comment

math2.0-setup : mysql and php+

Last time I wondered whether a set-up like WordPress.com meets FaceBook with add-ons (such as wiki- and latex-support) might be a usable environment for people working in a specific arXiv-topic.

I’ve used WordPressMU and BuddyPress to create such an embryonal environment. At first I thought I’d extend it a bit before going online but I fail to have the energy right now so I might as well make the link available. If you are into math.QA and/or math.RA you are invited to join the experiment. But, please use this site gently as I’ll have to drop it otherwise.

I’ve no desire to maintain this site indefinitely but would welcome others to set up something similar. For this reason I’ll write a couple of posts explaining how you can build it yourself when you’d have a free afternoon and a spare Mac around. Each post should not take you longer than 1 hour. Today, we’ll provide the boring but essential basics : we must get a MySQL-server and a WebServer running. Next time, I’ll take you through the WordPressMU (MU for multi-users) and BuddyPress installation. After that, we’ll add extra functionality.

We will start from a vanilla 10.5.6 installation. We will often need to edit files, so we’d better grab a good, free  texteditor : TextWrangler, drag it to Applications and place it in the Dock. We’ll also type in commands so we want the TerminalApp (to be found in Applcations/Utilities) in the Dock. SystemPreferences and Safari are already in the Dock and as we will need these tools a lot we might rearrange the Dock to look like



From left to right : the Finder, Terminal, Safari, TextWrangler and System Preferences. From now on we will mean by ‘Open …’ that you click on the ‘…’ icon. In the end we want our computer to become a web-server, so we don’t want it to go to sleep. Open SystemPreferences and look for the ‘Energy Saver’-icon, click on the ‘Show details’ button and set the ‘Put the computer to sleep when it is inactive for:’ to Never and unmark the ‘Put the hard disk(s) to sleep when possible’ at the bottom.

We will need to start or stop the WebServer so here’s how that’s done : open SystemPreferences and look for the ‘Sharing’-icon. Marking the ‘Web Sharing’ option is equivalent to starting your webserver (you can verify this by opening Safari and pointing it to http://localhost/ and you should see the default Apache-screen), unmarking it stops the webserver (check this by repeating the previous, now you should get a ‘Safari can’t connect to the server’ message).

All of this was probably trivial to you so let’s do something a bit more advanced : setting up a database-server. OSX doesn’t come with MySql, so we need to download and install it.

MySQL :

Get the latest version : choose the Mac OS X 10.5 (x86)-package and download it (they ask you to register but you can bypass this by clicking on the ‘No thanks, just take me to the downloads’-link). It is a 55.3 Mb file so this may take a couple of minutes. If all goes well this window should pop-up



Click on the mysql-5.0.67-osx10.5-x86.pkg icon and follow the instruction (defaults suffice, you’ll be asked to give your sudo password and in all it will take less than a minute). Repeat this procedure with MySQLStartupItem.pkg. Done!

To verify it, Open Terminal and type this to the prompt

sudo /Library/StartupItems/MySQLCOM/MySQLCOM start

You’ll get a scary warning message but type in your sudo-password and the Mysql-server will start. You can access it by typing

/usr/local/mysql/bin/mysql

and type exit to the mysql-prompt to leave.
In all, your interaction with the terminal should look something like this



Clearly, you do not want to type all of this every time, so we will add the mysql-location to our ‘PATH’. To do this, open TextWrangler and add this line to the blank document

export PATH=$PATH:/usr/local/mysql/bin

and save the file as .profile in your home-directory (the one with the ‘House’-icon, usually given your name). You will get a warning that .-files are reserved but go ahead anyway by clicking the use . – button). Now, open Terminal and type this

source ~./profile
echo $PATH

if all went well you should now see the mysql-location at the end of your path. From now on you’ll only have to type

mysql

to the terminal-prompt to open MySql. At the moment the root-user of your mysql has no password which isnt safe so we’d better set one. Open terminal and type

mysqladmin -u root password NEWPASSWORD

where, of course, you replace NEWPASSWORD with your choice (use only letters and numbers). From now on you can access your mysql-server by opening Terminal and typing

mysql -u root -p

and giving your password. Okay, so we’ve established our first goal, we have a working Mysql. Take a break if you need one.

better PHP

Mac 10.5 comes equipped with php5 but unfortunately it isn’t quite up to what we need. So, we need to install a better one and tell the mysql-server and the webserver to use the new one instead of the standard one.

Open Safari and grab the better php-version by going to

http://www2.entropy.ch/download/php5-5.2.5-6-beta.tar.gz

It is a 85.2 Mb file, so have a bit of patience. The file gets unzipped automatically and downloaded in the Downloads-directory. Open Finder and go there. At the moment your Downloads-directory will look like



Doubleclick on the php5-5.2.5-6-beta.tar file and a new directory will be created called php5. We will now move this directory and lay some symbolic links. Open a new Terminal window and type the following commands (and provide your sudo-password when asked)

cd Downloads
sudo mv php5 /usr/local
sudo ln -sf /usr/local/php5/entropy-php.conf /etc/apache2/other/+entropy-php.conf
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Next, we have to tell the webserver to use this new php-version instead of the old one. This information is contained in the apache-configuration file : httpd.conf. Open TextWrangler and under ‘File’ choose the option ‘Open File by Name’. Type /etc/apache2/httpd.conf in the field that appears. The file will now appear in the main window. Under ‘Search’ choose the ‘Go to Line’ option and fill in 114 and hit the Go To button. The follwing line should now be highlighted

#LoadModule php5_module libexec/apache2/libphp5.so

immediately under it add the following line (TextWrangler will tell you that the file is owned by root and ask you whether you want to open it, click yes and make the changes)

LoadModule php5_module local/php5/libphp5.so

(observe that line 114 is commented out, that is, starts with a #, whereas your added line is not).
Save the file (Textwrangler will ask you to provide the sudo-password).

Next, we will have to tell php to communicate with the mysql-server. Again, open TextWrangler, under ‘File’ choose ‘Open File by Name’ and type in /usr/local/php5/lib/php.ini-recommended. When the file appears, under ‘Search’ choose ‘Go to Line’ and type in 810. It will read

mysql.default_socket =

Change it as follows (that is, add to it)

mysql.default_socket = /var/mysql/mysql.sock

and now choose under ‘File’ the ‘Save as…’ option. In the window change php.ini-recommended to php.ini and click Save. Done!

Testing…

Restart your webserver. Recall that this means: open SystemPreferences, choose ‘Sharing’, unmark ‘Web Server’, wait 5 seconds and then mark it again.

Open TextWranger, make a new Text document containing just one line (remove the white space between the ?-signs and the brackets) :

< ?php phpinfo() ? >

Choose ‘File’ and ‘Save as…’ and in the window that appears navigate to YourHardDisk/Library/WebServer/Documents, name the file ‘test.php’ and click the ‘Save’ button



Finally, open Safari and point it to http://localhost/test.php. Cross your fingers and if you get a screen like the one below treat yourself to something nice!



Leave a Comment