Archive
Install Adobe Flash for Firefox properly
Let’s see how to install Adobe Flash under Ubuntu for Firefox properly.
Visit the official site (http://get.adobe.com/flashplayer/) and download the .tar.gz file. Create a temporary directory (e.g. /tmp/flash) and save the file there. This archive is a tarbomb, that’s why we put it in a dedicated folder.
Unzip the archive. There is a “usr” subfolder whose owner and group must be set before copying it to “/usr“. Switch to root (with “su“) and perform the following actions:
chown -R root:root usr(where “usr” is the subfolder from the archive, not the system folder)- copy this “
usr” folder to “/usr“, i.e. copy it to the system folder
(Of course, you can also do these steps with “sudo” too.)
Finally, copy the file “libflashplayer.so” to the directory “$HOME/.mozilla/plugins/“. It’s very likely that this folder doesn’t exist yet so create it first.
Restart Firefox and enjoy the ultimate Flash experience :)
Installing a LAMP server
Problem
You want to play with Linux + Apache + MySQL + PHP. How to install all the necessary stuff easily?
Solution
There is a tool called tasksel that can install multiple related packages as a co-ordinated “task”. Launch tasksel as root and choose the task you need. There is an option called LAMP server. The packages phpmyadmin and mysql-admin are not part of this collection, you need to install them separately.
In short:
sudo apt-get install tasksel sudo tasksel sudo apt-get install phpmyadmin sudo apt-get install mysql-admin
Then visit http://localhost to test if it works. To learn more on how to install LAMP, refer to this page.
Enabling user directories
My home directory is located at /home/jabba. Here I want to create a directory called public_html and I want to play with PHP in this folder. The contents of this directory is accessible via http://localhost/~jabba. However, by default it’s not enabled.
Steps to follow:
First, create the directory $HOME/public_html. Then enable user directories:
cd /etc/apache2/mods-enabled sudo ln -s ../mods-available/userdir.conf userdir.conf sudo ln -s ../mods-available/userdir.load userdir.load
Update (20110107): There is a script called a2enmod to create and manage these symlinks. Its opposite is a2dismod, which disables Apache modules. See man a2enmod. (credits go to Jesse)
And restart Apache2:
sudo /etc/init.d/apache2 restart
This tip is from here. Now HTML files are enabled in the user directory, but PHP files are still disabled!
Open the file /etc/apache2/mods-enabled/php5.conf and locate these lines:
# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_value engine Off
</Directory>
</IfModule>
As the comments suggest, you need to put those five lines in comments. Then restart the web server again:
sudo /etc/init.d/apache2 restart
This tip is from here. Now it should work. If it doesn’t work, you will have to delete the browser cache! Now it should really work :)
If you get the error message “You don’t have permission to access … on this server“, then it means there is a problem with file permissions. Directories (from public_html inwards) must have have permission 755, files 644. Make sure that /home and /home/user (where user is your user name) are also accessible! Check out this script, it sets rights correctly in your ~/public_html directory.
PHP: no error messages, just a blank page
By default, PHP is configured for production, thus error messages are disabled. This is not good for development, so you will have to modify your php.ini file a bit (located at /etc/php5/apache2/php.ini). Find these variables and change their values:
error_reporting = E_ALL & ~E_NOTICE | E_STRICT display_errors = On
Restart Apache and you are done. This tip is from here. It is also possible to change these values from a .php file (see the code below), but it didn’t work for me on PHP5.
This line had no effect in my case:
ini_set('display_errors',1);
Update: as pointed out here in a comment, this line doesn’t catch any parsing errors “because the entire script is parsed before any of it is executed”. So the best solution is to modify php.ini. However, the following line should work from a script:
error_reporting(E_ALL);
Fatal error: Maximum execution time of 30 seconds exceeded
By default, your PHP scripts shouldn’t run longer than 30 seconds, otherwise the scripts will be terminated and you get this error message. This time limit can be increased in php.ini. Modify this variable:
; Maximum execution time of each script, in seconds ; http://php.net/max-execution-time ; Note: This directive is hardcoded to 0 for the CLI SAPI #max_execution_time = 30 # setting 3 minutes for instance: max_execution_time = 180
After this modification, don’t forget to restart Apache.
This tip is from here.
Requirements for Symfony
If you want to use Symfony, you should install these packages too (otherwise Symfony will complain):
sudo apt-get install php5-xsl sudo apt-get install php-apc
Restart Apache. Then edit /etc/php5/apache2/php.ini and perform this modification:
# set it to "Off" value short_open_tag = Off
Restart Apache.
Symfony provides a PHP script that checks all these requirements. It can be run from the web browser and from the command line. However, the command line version uses a different php.ini file (in my case the CLI version is located at /etc/php5/cli/php.ini). So run check.php in the command-line and in the browser too.
Requirements for Yii
For Yii you might need to install these packages to pass all the tests:
sudo apt-get install php5-sqlite sudo apt-get install php5-memcache sudo apt-get install php5-pgsql
Installing VirtualBox
Problem
Under Ubuntu you want to use another OS (like Windows) in a virtualized environment.
Solution
As a free solution you can use VirtualBox. Be aware that it has two versions! A proprietary (also free) and an open-source edition (OSE). Some features are missing from the OSE, so I suggest using the other one.
Installation:
- visit the download page and fetch the install file that matches your host system
- when the installation is done, launch the application with the command
VirtualBox(pay attention to the capital ‘V’)
Other Products
There is another great (though proprietary) product called VMware Workstation. It also runs on Linux.
Troubleshooting
When I wanted to increase the number of processors available to a guest system, I got this error message: VERR_VMX_MSR_LOCKED_OR_DISABLED. It means that virtualization is disabled in the BIOS. Steps to follow (under Dell):
- Restart the machine and enter the BIOS by pressing F2.
- Go to Performance -> Virtualization, and set it On.
- Go to Security -> Execute Disable, and set it On.
Install multiple programs at once with Ninite [Win]
Under Ubuntu we have apt-get. Moreover, after a fresh installation we already have lots of pre-installed programs. But after installing a Windows box, what do we have? An unusable Internet Explorer…
Thank God, there is an excellent service called Ninite to help us. It contains lots of useful and free software grouped in categories. The programs are always the latest versions. Just choose what you need and download the installer which is about 200K. Launch it and it will download and install all the selected programs in just a few minutes. It doesn’t ask any questions, it will install everything with the default options. It uses threads, so while installing a software it is downloading the next one. Installing 10 programs takes no more than 10 minutes. Imagine how much time it would require if you should install all these programs manually… Ninite saves lots of time.
If you just finished installing your Windows, start IE and visit http://ninite.com immediately! Make sure that Firefox is in the list :)