Pages

Thursday, 25 October 2012

How to configure Symfony 2.0 on Ubuntu Server 12.04

Download the framework from the Symfony website. Here's a link.
Either download the package directly to your /var/www directory or move it there yourself.
# cd /var/www
# wget -O symfony.tgz http://symfony.com/download?v=Symfony_Standard_Vendors_2.0.0BETA1.tgz
# tar xfz symfony.tgz
You'll now have a directory labelled Symfony in your /var/www directory.
Now navigate to http://localhost/Symfony/web/config.php.
Some comman requirements and warnings :
1. Install and enable the SQLite or PDO_SQLite extension. Just run these two commands. It doesn't matter what directory you're in.
#apt-get install php5-sqlite
#sudo apache2ctl restart
2. Change the permissions of the app/cache/ directory so that the web server can write into it.
#sudo chmod -R 777 /var/www/Symfony/app/cache
3. Change the permissions of the app/logs/ directory so that the web server can write into it.
#sudo chmod -R 777 /var/www/Symfony/app/logs
4. Set the date.timezone setting in php.ini. (like Europe/Paris).
#sudo vim /etc/php5/apache2/php.ini
Find the line with ;date.timezone = under the [Date] section, and set it to your timezone based on PHP's list of timezones. I chose America/New_York because sometimes I wish I lived there. Also, make sure to remove the semicolon at the beginning of the line!
#sudo service apache2 restart
5. Install and enable a PHP accelerator like APC (highly recommended).
#sudo apt-get install php-apc
#sudo apache2ctl restart
6. Install and enable the intl extension.
#sudo apt-get install php5-intl
#sudo apache2ctl restart
7. Set short_open_tag to off in php.ini.
#sudo vim /etc/php5/apache2/php.ini
Find the line with short_open_tag = On and change it to short_open_tag = Off

Configure

  1. At the end of the configuration script, it will try to write to /var/www/Symfony/app/config/parameters.ini, so we have to make sure it's writable.
    #Sudo chmod 777 /var/www/Symfony/app/config/parameters.ini

Wednesday, 24 October 2012

script to take a photo of my screen every five minute



sudo apt-get install scrot
#!/bin/bash
# ^This first line just tells linux which script language to use.
# We're using bash
# Because this script runs as a Cron-job, it runs as root and doesn't
# necessarily know which user you're logged in as.  For me, this says "use
# the default display, ie the first person logged in on the computer"
DISPLAY=:0
HOME=/home/vose
export DISPLAY
export HOME
# Create the screenshots directory in case it doesn't exist yet
mkdir -p /home/vose/Pictures/Screenshots/
# Delete any screenshots more than 7 days old.
find /home/vose/Pictures/Screenshots/ -type f -mtime +7 -delete
# Launch the browser (I use firefox for normal, so I'll use chrome for this)
# The "sudo -u vose ..." means "run the command as user `vose`". You'll
# You'll need to put your username in there...
# The "&" at the end means 'launch in the background', so the script
# can keep going.
echo "Opening the browser"
sudo -u vose chromium-browser http://google.com &
# This records the ProcessID (pid) of the last opened program
# (chromium) so we can kill it later
pid=$!
# Wait 10 seconds for the browser to open and page to load
# On a slow computer/connection/webpage you may need to wait longer
sleep 10
# Take the screenshot using scrot.  Save it to this file
scrot /home/vose/Pictures/Screenshots/screenshot_`date +%F-%H-%M-%S`.jpg
echo "Created screenshot_`date +%F-%H-%M-%S`.jpg"
# Kill the browser
kill $pid
Before you try go too far, stop and see if this works.
First, save the script above as takeScreenshot.sh.
Then from a terminal, type chmod +x takeScreenshot.sh (Chmod changes the permissions on a file, and '+x' means we're giving it permission to "execute" the script.)
Run ./takeScreenshot.sh from a command line - this will run the script manually. See if the file shows up in your pictures folder after doing this.
If that worked, we need to now add it to Cron.
At a command line, type sudo crontab -e. (If it asks you which editor, choose Nano. If you haven't used it before, ask around for some help).
In the file, you want to add a line at the bottom, like this:
# m h dom mon dow command
*/5 * * * * /home/vose/Scripts/takeScreenshot.sh
What this says:
Every 5 minutes
Every hour, every day-of-month, every month, every day-of-week
Run "/home/vose/Scripts/takeScreenshot.sh"