Monday, November 18, 2013

Apache2 Notes

Enabling a module

On seeing this error:

.htaccess: Invalid command 'RewriteEngine'

This indicates that rewrite module is not enabled. In Apache 2, both module and sites are handled in the separated folders under /etc/apache2:


In the *-available folders are the configurations to be used, for instance, here we need to enable rewrite module, we just type

sudo a2enmod rewrite

You see that rewrite.load is in the folder mods-available with the content:

LoadModule rewrite_module /usr/lib/apache2/modules/

You will be notified to restart/reload the Apache service. Do it.

Enabling a website

We write the configurations as in sites/available:

        ServerName  localhost

        # Indexes + Directory Root.
        DirectoryIndex index.php
        DocumentRoot /var/www/foo

        # Logfiles
        ErrorLog  /var/www/foo/logs/error.log
        CustomLog /var/www/foo/logs/access.log combined

Make sure there is a logs folder

cd /var/www/foo
mkdir logs

And then enable the website

sudo a2ensite 

Just to notice how to disable the website:

sudo a2dissite

Most importantly, enact the changes.

sudo service apache2 restart

Troubleshooting: Does PHP have write permission to a folder?

This article only talks about PHP installed alongside Apache under Linux (see here). Since PHP is run through libapache2-mod-php5. it inherits the permissions from Apache. So let's take a look about Apache. By default, it uses www-data user, to check this,

ps -u www-data

If it is so, you might get something similar:

 1276 ?        00:00:00 php5-fpm
 1277 ?        00:00:00 php5-fpm
 1278 ?        00:00:00 php5-fpm
 1279 ?        00:00:00 php5-fpm
14934 ?        00:00:00 apache2
14935 ?        00:00:00 apache2
14936 ?        00:00:00 apache2

Now check user info and its group of www-data

cat /etc/passwd | grep www-data

The following shows up on my machine which says it doesn't belong to the root group or my administrator group.


We list the file permissions of the folder img/ to see apache's right:

ls -l | grep img

All right! Since Apache is in other group here, it doesn't have 'w' permission.

drwxrwxr-x 2 admin admin 4096 Nov 12 19:26 img

Then let's give him the permission. Notice that it is dangerous to do this, since in this way every user on the computer will have rights on this folder. Normally, we let the owner of the folder be Apache, and others can only read.

chmod o+w img

Sunday, November 17, 2013

MS Windows Terminology Italian - English

La Terminologia principale del MS Windows in correspondenza fra italiano e inglese. The correspondence of MS Windows terminology between Italian and English.

account utente User account
aggiornamento update
arresta il sistema shut down
attendere wait
attivazione o disattivazione activation or disactivation
avviare start
barre degli strumenti Tool bar
caricamento loading
cerca search
collegamenti shortcuts
connessioni di rete Network connection
Disinstalla o modifica programma Uninstall or modify programs
disinstalla uninstall
eseguire execute
gestione attività Task manager
Gestione dispositivi Device Manager
ibernazione hibernate
Immagini Pictures
impostazioni configuration
indrizzi address
manutenzione maintainance
Modalità provvisoria Safe Mode
mostra desktop show desktop
nuova new
Pannello di controllo Control Panel
proprietà property
riavvia il sistema restart
risoluzione problemi Troubleshooting
Sistema e sicurezza System and Security
souni sound
stampante printer
strumento tool

To sort a random file by alphabet,

sort -gk 2 temp