01 octubre, 2013

Upgrading a VM Fedora 17 to Fedora18 on VirtualBox

Not that easy, but fully happy after doing it!

After doing some Google search and after following the steps written by some people, my walkthrough to achieve this task is as follows:


Happiness when I obtained the Login panel again after all the process

1- In the Virtual Machine, as root user :

yum update
yum clean all
reboot

yum install fedup
fedup-cli —network 18 —debuglog feduplog.log


In the guide said that it was better to put a permissive mode in SELinux but I don’t know if it is necessary. To do this:

setenforce 0
getenforce


2- After the reboot, select the System Update in the Grub menu.

3- A new reboot happened and in my case I obtained only a panel with the Fedora logo and the login panel didn’t appear at once. :( There is a solution !! :)

Reboot again the VM. In the new Fedora 18 entry on Grub click e to edit the boot options. Add the number 3 al the end of the linux line.F10 to continue. If everything goes well, you would login as root. Try lo launch X11 with startx command. Maybe you will obtain the following error at the end:

Failed to load module vboxvideo

To solve this problem, run this command:

/etc/init.d/vboxadd-x11 setup

Et Voilà!!!

After reboot, the login panel should appear again.

Hope this work for you.

RaC

Cómo revisar versiones de paquetes en los releases de Fedora?

Un importante dato de un sabio en Linux. Para verificar las versiones de cualquier paquete que se installa via YUM en Fedora, es recomendadísimo ver la página http://koji.fedoraproject.org/koji/packages. Aquí se puede validar si el paquete fue compilado para una distribución o un release específico de Fedora. Por ejemplo si django 1.5 existe en Fedora 18 (NO EXISTE :( ) Estos datos son importantes para desplegar/instalar aplicaciones en otras máquinas. A tener en cuenta!

13 septiembre, 2013

Extender favoritos de Fedora > 17 / GNOME 3

Para agregar una aplicación cualquiera (que no haga parte de las de base de Fedora) en la lista de aplicaciones, especialmente en la de favoritos.

Instalar alacarte

$ yum install alacarte

Buscar aplicación Main Menu y luego crear un nuevo item con el ejecutable de la aplicación. Finalmente, dar click derecho sobre la aplicación en la lista de programas disponibles y Agregar como favorito :)

12 septiembre, 2013

Deploying Django 1.5.3 application in Apache via mod_wsgi, on a Fedora 18 and using virtualenv and DB MySQL

This post is in English (finally!) and I would like to describe all what I have suffered configuring everything since ZERO. The only thing installed on my machine was the Fedora 18 with the graphical environment (GNOME). I hope I won’t loose any detail in order to be the most reproducible as possible. Let’s go to the configuration stuff !!

1- Install and configure ‘Web Server’ and MySQL Database


Using yum I installed the following packages:

$ sudo yum groupinstall “Web Server”
$ sudo yum install make automake gcc gcc-c++ kernel-devel
$ sudo yum install mysql-server mysql-devel


Enable services to be launched at system start-up and run them

$ sudo chkconfig httpd on
$ sudo chkconfig mysqld on
$ sudo service httpd start
$ sudo service mysqld start


Verify that everything is working

$ sudo service httpd status
$ sudo service mysqld status
$ mysql —user root —execute “select version()”


Configure database root password and basic stuff. Leave the test database in order to make tests with django.

$ sudo mysql_secure_installation

I wanted to put my applications in the $HOME/public_html of an user so I changed the config of the server to use the web user directories. For that:

$ getsebool -a | grep httpd
$ sudo setsebool -P httpd_enable_homedirs on
# Read and make the modifications in the file/etc/httpd/conf.d/userdir.conf and restart the web server
$ sudo service httpd restart


Create public_html folder and assign permissions

$ mkdir ~/public_html
$ chmod 711 ~username
$ chmod 755 ~/public_html


2- Install and configure Python, virtualenv, and Django


Normally, global things with yum and easy_install and local ones with pip

$ sudo yum install python
$ sudo yum install python-setuptools python-devel
$ sudo easy_install pip
$ sudo pip install virtualenv


Defining a virtualenv

$ mkdir ~/public_html/testAppDjango
$ cd ~/public_html/testAppDjango
$ virtualenv env —no-site-packages
$ source env/bin/activate
$ pip install django -U
$ django-admin.py startproject testproject
$ cd testproject
$ python manage.py runserver 8000


By now it should run. Stop the server and continue

3- Configuring connection to MySQL and the mod_wsgi

$ pip install MySQL-python
$ sudo yum install mod_wsgi
$ python manage.py startapp testapp


# Modify the settings.py as follows:

- In DATABASES > ‘ENGINE’ : ‘django.db.backends.mysql’, ‘NAME’ : ‘test’, ‘USER’ : ‘root’, ‘PASSWORD’ : ‘password’, ‘HOST’ ; ‘localhost’, ‘PORT’ : ”

- Activate admin in installed_apps (make the same change in the urls.py file).

The ones who knows a little bit of Django, knows what I’m talking about. Now, use your editor to create the following file. The most important one.

$ gedit /etc/httd/conf.d/testApp.conf

Insert the following text:

WSGIPythonPath /home/username/public_html/testAppDjango/testproject:/home/username/public_html/testAppDjango/env/lib/python2.7/site-packages

<VirtualHost *:80>

WSGIScriptAlias / /home/username/public_html/testAppDjango/testproject/testproject/wsgi.py
Alias /static/ /home/username/public_html/testAppDjango/testproject/testproject/static/
Alias /media/ /home/username/public_html/testAppDjango/testproject/testproject/media/

<Directory /home/username/public_html/testAppDjango/testproject>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>

<Directory /home/username/public_html/testAppDjango/testproject/testproject/static/>
Order deny,allow
Allow from all
</Directory>

<Directory /home/username/public_html/testAppDjango/testproject/testproject/media/>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>

Synchronize the database and see what happens in the browser http://localhost

$ python manage.py syncdb

NOW IT SHOULD WORK BUT …. A 500 HTTP ERROR APPEARED IN THE BROWSER :(. Look in the Apache error log:

$ sudo less /etc/httpd/logs/error_log

In my server logs appeared the following #$f..ck@ error:

Error Loading MySQLdb module: /home/username/public_html/testAppDjango/env/lib/python2.7/site-packages/_mysql.so: failed to map segment from shared object: Permission denied

After a deep search on Google and some hopeless guides that told difficult things to recompile libraries and all that stuff I found that this problem is related to a security system included in Fedora the SELinux. Some people have deactivated it and their apps work, but my production server can’t be modified in that way so other guy's guide and a little troubleshot in a website gave me some useful commands:

$ cd /home/username/public_html/testAppDjango/env/lib/python2.7/site-packages/
$ ll -Z
# The _mysql.so file shoud appear as a lib_t not a httpd_user_content.
# With the following it tells that is a shared lib:
$ chcon -t shlib_t *.so


NOW FOR ME IT WORKED!!

Next, do some important things to display the website correctly and to maintain it:

$ cd ~/public_html/testAppDjango/
$ pip freeze > requirements.txt
$ cd testproject/testproject
$ mkdir static
$ mkdir media
$ cp ../../env/lib/python2.7/site-packages/django/contrib/admin/static/admin/* .


Just if you want to verify, my only dependencies in requirements file are:
Django==1.5.3
MySQL-python==1.2.4
wsgiref==0.1.2

Hope this will be useful. RaC!

06 septiembre, 2013

Acceder desde otro PC en la misma red local al Django dev server, instalado en una VM Fedora 18

Esto lo realicé luego de tener el siguiente problema:

- Tenía mi ambiente de desarrollo para mi sitio en Django en una máquina virtual Fedora 18. Además, estoy empezando a utilizar la librería XTK que es una extensión de WebGL para hacer más sencillas los renderizados 3D en Web. Sin embargo, ni en Google ni en Firefox en la VM me funcionó WebGL, incluso si decía que OpenGL estaba soportado. Intenté todo lo que decían los foros y no funcionó. Por esta razón, quería poner el servidor de desarrollo accesible desde mi máquina real y con eso hacer la prueba con los navegadores instalados en mi máquina real, y FUNCIONÓ :D.


Aquí la guía de pasos a seguir:

1- Cambiar a modo de adaptador en la configuración de red de la máquina virtual. Asignar como modo Bridge (Puente) y seleccionar como Name (Nombre) el que corresponda al dispositivo de conexión inalámbrico o conexión por cable (yo intenté con los dos porque no sabía exactamente cual era el adecuado).

2- En la máquina virtual, dejar lo más pública posible la máquina. Verificar Firewall especialmente.

3- Preguntar la ip por ifconfig o ir a la página http://whatsmyip.net/.

4- Si se tiene otro servidor web ejecutándose (como Apache) en la máquina virtual, detenerlo. Esto se puede verificar y realizar con los siguientes comandos como superusuario:

sudo service httpd status
sudo service httpd stop


5- Ejecutar el servidor de desarrollo de django como de costumbre, pero asignar como ip 0.0.0.0 y puerto 80, es decir:

python manage.py runserver 0.0.0.0:80

6- Volver a la máquina real y acceder desde el browser al servidor utilizando la ip identificada en la máquina virtual.

Y todos contentos !! :) es posible hacer pruebas rápidas en una máquina virtual, pero validar el funcionamiento en una máquina real.