Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Friday, February 17, 2012

Allow remote connections to MySQL server

To enable remote access for MySQL server:

$ sudo vim /etc/mysql/my.cnf
### edit my.cnf
### set bind address and comment out or remove skip-networking (if exists)

[mysqld]
...
bind-address=SERVER-EXTERNAL-IP
# skip-networking

$ /etc/init.d/mysql restart

Now it works.

Friday, February 3, 2012

Setup Apache2's mod_wsgi on Ubuntu

If you get this when restarting Apache2 on Ubuntu
Invalid command 'WSGIDaemonProcess', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
it means you don't have mod_wsgi module installed.

These commands install and enable it.
sudo apt-get install libapache2-mod-wsgi
sudo a2enmod mod-wsgi
sudo /etc/init.d/apache2 restart

Perl warning about locale in Ubuntu

If you get this warning
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
 LANGUAGE = (unset),
 LC_ALL = (unset),
 LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

it can be fixed with
locale-gen en_US.UTF-8
dpkg-reconfigure locales

Get Graphite run for a Django project

This post is intended first of all to memorize my experience of getting the Graphite system work.

Wednesday, February 1, 2012

Install RabbitMQ

install server itself (using port)

MacOs X:
sudo port install rabbitmq-server

Ubuntu:
sudo apt-get install rabbitmq-server

create user, vhost and set some permissions:
rabbitmqctl add_user username password
rabbitmqctl add_vhost /vhost
rabbitmqctl set_permissions -p /vhost username ".*" ".*" ".*"

done.

OSError: [Errno 38] Function not implemented

Server: Ubuntu 11.04

Run celeryd with info log level

$ ./manage.py celeryd -l info
[2012-02-01 01:16:45,779: ERROR/MainProcess] Unrecoverable error: OSError(38, 'Function not implemented')
Traceback (most recent call last):
  File "/var/www/th4x/.env/lib/python2.7/site-packages/celery/worker/__init__.py", line 268, in start
    component.start()
  File "/var/www/th4x/.env/lib/python2.7/site-packages/celery/concurrency/base.py", line 72, in start
    self.on_start()
  File "/var/www/th4x/.env/lib/python2.7/site-packages/celery/concurrency/processes/__init__.py", line 43, in on_start
    self._pool = self.Pool(processes=self.limit, **self.options)
  File "/var/www/th4x/.env/lib/python2.7/site-packages/celery/concurrency/processes/pool.py", line 520, in __init__
    self._setup_queues()
  File "/var/www/th4x/.env/lib/python2.7/site-packages/celery/concurrency/processes/pool.py", line 695, in _setup_queues
    self._inqueue = SimpleQueue()
  File "/usr/lib/python2.7/multiprocessing/queues.py", line 354, in __init__
    self._rlock = Lock()
  File "/usr/lib/python2.7/multiprocessing/synchronize.py", line 147, in __init__
    SemLock.__init__(self, SEMAPHORE, 1, 1)
  File "/usr/lib/python2.7/multiprocessing/synchronize.py", line 75, in __init__
    sl = self._semlock = _multiprocessing.SemLock(kind, value, maxvalue)
OSError: [Errno 38] Function not implemented
[2012-02-01 01:16:45,780: INFO/MainProcess] process shutting down

Python's _multithreading requires /dev/shm to work. In Ubuntu /dev/shm points to /run/shm by default. Rename (or delete, I doubt it is necessary anymore) existing /dev/shm.

Create /dev/shm directory
$ sudo -i  # get root
$ mkdir /dev/shm

Add to /etc/fstab mounting of /dev/shm command
tmpfs /dev/shm    tmpfs   defaults,noexec,nosuid     0     0

Mount all unmounted filesystems from /etc/fstab.
$ mount -a
There should be no errors.

Run again
$ ./manage.py celeryd -l info

It starts normally.

Thursday, April 7, 2011

Python's virtual environment

You probably would like to use separate sets of packages for your projects and whilst not to spoil your system's environment. This problem can be solved by using virtual environments.

Make initial setup:


To configure virtualenvwrapper:

  1. Create a directory for the virtual environments:
    mkdir ~/projects/.envs
  2. Add to ~/.bashrc:
    export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
    export WORKON_HOME=~/projects/.envs
    export PROJECT_HOME=~/projects
    
    source /usr/local/bin/virtualenvwrapper.sh
  3. Run:
    source ~/.bashrc

Initial setup has been done. Now let's create a new virtual enviroment for Test project in ~/projects/test
mkvirtualenv test
workon test
Now you're in the 'test' environment. To install new packages you can use, for instance, pip.

Saturday, October 23, 2010

Run GAE SDK for Python and Django on Ubuntu Maverick

First, I make the following structure in my project's directory:
~/projects/gae/ - directory for GAE's projects
~/projects/gae/google_appengine/ - downloaded GAE sources
~/projects/gae/google_appengine/test/ - test project using GAE

So, to run this test project as well as other further projects that use GAE
  1. Download Google App Engine SDK for Python and unpack it to ~/projects/gae/.
  2. Install python-2.5
    sudo add-apt-repository ppa:fkrull/deadsnakes
    sudo apt-get update
    sudo apt-get install python2.5
    
  3. Install easy_install for Python 2.5
    cd /tmp
    wget http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-py2.5.egg
    sh setuptools-0.6c11-py2.5.egg
    
  4. Install Django 1.1 for Python 2.5
    easy_install-2.5 django==1.1.1
    
  5. Put into ~/projects/gae/google_appengine/test file
    echo "#!/bin/bash
    
    python2.5 ../google_appengine/dev_appserver.py ./" > run
    chmod a+x run
    

When you need to run development server for the Test project you should do
cd ~/projects/gae/google_appengine/test/
./run

Friday, October 22, 2010

Default opening software

This file ~/.local/share/applications/mimeapps.list contains all overridden openers for particular MIME types.

Google Chrome and Flash player

Having installed new Ubuntu 10.10 I found that Google Chrome cannot display flash content and asks to install flash player. But at flash player download website it says that I have already installed one.
Googling a bit gives me an advise. I made the step below and it gets work.
$ sudo apt-get install flashplugin-installer
$ sudo locate libflashplayer.so
/usr/lib/flashplugin-installer/libflashplayer.so
/usr/share/ubufox/plugins/npwrapper.libflashplayer.so
/var/lib/flashplugin-installer/npwrapper.libflashplayer.so
$ ln -s libflashplayer.so /usr/lib/flashplugin-installer/libflashplayer.so

Clock widget hangup

If you are very annoyed by system hangup when you have clicked clock widget to watch calendar or whatever in your Ubuntu 10.10 I can advise to do the following:
sudo apt-get purge evolution-data-server evolution-couchdb evolution evolution-exchange
That's all. After this you are avoided such unpleasant behavior.
It, however, removes Evolution mail client but if you don't use it as me that is not a problem.

Sunday, September 5, 2010

Monday, August 16, 2010

Play WMV, MP3 and other restricted formats in Ubuntu

Some audio and video formats are not included into Ubuntu by default. And to enable them in your system you must do it by your own.

Install them

Original Post

Fix mouse clicks in Flash-player in Ubuntu

In /usr/lib/nspluginwrapper/i386/linux/npviewer add
export GDK_NATIVE_WINDOWS=1
so, the content in this file become
#!/bin/sh
TARGET_OS=linux
TARGET_ARCH=i386
export GDK_NATIVE_WINDOWS=1
. /usr/lib/nspluginwrapper/noarch/npviewer
Restart browser and that's all.

Thursday, July 22, 2010

Restore grub2 after Windows installation

To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.
ubuntu@ubuntu:~$ sudo fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x14311431

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       29089   233657361    7  HPFS/NTFS
/dev/sda2           29090       32129    24418800   83  Linux
/dev/sda3           60304       60801     4000185   82  Linux swap / Solaris
/dev/sda4           32130       60303   226307655   83  Linux

Partition table entries are not in disk order

ubuntu@ubuntu:~$ sudo mount /dev/sda2 /mnt
ubuntu@ubuntu:~$ sudo grub-install --root-directory=/mnt/ /dev/sda
Installation finished. No error reported.

Saturday, April 3, 2010

ATI driver problems after upgrading Ubuntu 9.10 to 10.04

I have upgraded my desktop Ubuntu 9.10 to 10.04. Everything was fine except ATI driver didn't want to be installed. An error was in fglrx-amdcccle package,After that, I've reported the bug to Ubuntu Bug Tracker, and today I got the decision of my problem:
apt-get remove xorg-driver-fglrx fglrx fglrx-amdcccle
dpkg-divert --remove /usr/lib/xorg/modules/extensions/libdri.so
dpkg-divert --remove /usr/lib/xorg/modules/extensions/libglx.so
apt-get install fglrx

I thank Jean-Baptiste Lallement for help!

Monday, February 22, 2010

Universal archive unpacking tool

###   Handy Extract Program

extract () {
    if [ -f $1 ] ; then
        case $1 in
            *.tar.bz2) tar xvjf $1   ;;
            *.tar.gz)  tar xvzf $1   ;;
            *.bz2)     bunzip2 $1    ;;
            *.rar)     unrar x $1    ;;
            *.gz)      gunzip $1     ;;
            *.tar)     tar xvf $1    ;;
            *.tbz2)    tar xvjf $1   ;;
            *.tgz)     tar xvzf $1   ;;
            *.zip)     unzip $1      ;;
            *.Z)       uncompress $1 ;;
            *.7z)      7z x $1       ;;
            *)         echo "'$1' cannot be extracted via >extract<" ;;
        esac
    else
        echo "'$1' is not a valid file"
    fi
}
Поместить в ~/.bashrc или profile

original

Thursday, February 4, 2010

Setting up a network adapter alias

sudo ifconfig eth0:[0-254] 192.168.1.2 up.

Instead of eth0 you can use any of existing interfaces

Monday, December 28, 2009

Django and Oracle support

To get work Django and Oracle client in Ubuntu:

Download cx_Oracle (choose for your system), Oracle InstantClient and Sql*Plus (in this page you can choose your OS and download the packages (in my case are oracle-instantclient11.2-basic-11.2.0.0.2-1.x86_64.rpm and oracle-instantclient11.2-sqlplus-11.2.0.0.2-1.x86_64.rpm).

Move the files into one directory for simplicity and run

alien -k *.rpm
dpkg -i *.deb
to convert all the downloaded packages to ubuntu deb-format and install them.

Then make symlink to lib, otherwise module won't be found by Django

cd /usr/lib/python2.6
ln -s site-packages/cx_Oracle.so

To avoid

Traceback (most recent call last):
  File "", line 1, in 
ImportError: libclntsh.so.10.1: cannot open shared object file: No such file or directory
add to ~/.bashrc (or /etc/bash.bashrc to system-wide apply)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle/11.2/client64/lib

If you see the message
Traceback (most recent call last):
  File "", line 1, in 
ImportError: libaio.so.1: cannot open shared object file: No such file or directory
run
sudo apt-get install -y libaio1

P.S. If you choose more modern (or older) version of Oracle IntstantClient you have to create symlinks for necessary version, e.g. you see the following error:

Traceback (most recent call last):
  File "", line 1, in 
ImportError: libclntsh.so.10.1: cannot open shared object file: No such file or directory
but in /usr/lib/oracle/11.2/client64/lib directory exists libclntsh.so.11.1. Just make it symbolic link with
ln -s libclntsh.so.11.1 libclntsh.so.10.1

Install RPM in Ubuntu

To install Rpm-package in Ubuntu Linux (to run commands needs to be a superuser or using sudo):
  1. install alien package:
    sudo apt-get install alien
  2. Convert Rpm to Deb (in current directory)
    alient -k <package-file>.rpm
  3. Install the new Deb package
    dpkg -i <package-file>.deb