Archives: March 2014
18 articles
Apache 2.4 upgrade on Arch Linux
Update: Here is the follow-up, using Apache 2.4.9
This article has been written from memory afterwards, so it may be imprecise and/or incomplete but contains the main steps to a successful migration. I plan to complete it when I'll upgrade another machine. You should be able to find the missing instructions by following this thread on the Arch Linux forum.
After the upgrade from 2.2.x to 2.4.x, Apache throws an error because the current PHP package is not thread-safe. An option is to recompile it (not tested), another is to use the PHP FastCGI Process Manager:
$ yaourt -S php-fpm
and the already included Apache module mod_proxy_fcgi. Uncomment the following lines in /etc/httpd/conf/httpd.conf:
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
then comment this one:
#LoadModule mpm_event_module modules/mod_mpm_event.so
and add the mod_proxy_handler module:
LoadModule proxy_handler_module modules/mod_proxy_handler.so
We need to write proxy rules to avoid bad request or file not found errors. The path must be adapted to your configuration:
ProxyPassMatch ^/(.*.php(/.*)?)$ fcgi://127.0.0.1:9000/srv/http/www/$1
ProxyPassMatch ^/$ fcgi://127.0.0.1:9000/srv/http/www/index.php$1
In /etc/php/php-fpm.conf, change the listen directive:
listen = 127.0.0.1:9000
;listen = /run/php-fpm/php-fpm.sock
Activate the php-fpm service:
$ sudo systemctl enable php-fpm.service
Replace "enable" with "start" if you do not want/need it to start automatically at each boot; but you will have to start it manually whenever you need it to avoid Apache throwing a 503 "service unavailable" error.
Turn PHP_SESSID off on an OVH shared server
In a .htaccess file, add:
SetEnv SESSION_USE_TRANS_SID 0
In your PHP code:
ini_set('session.use_cookies', '1');
ini_set('session.use_only_cookies', '1'); // PHP >= 4.3
ini_set('session.use_trans_sid', '0');
ini_set('url_rewriter.tags', '');
Who am I?
I am an entity with a very limited perception and knowledge about itself, its own existence and its surrounding universe. A short physical summary based on what I have been taught is that I am a human being. I live in the northern hemisphere of the planet Earth, more precisely in a country called Belgium and located in the west of the European continent. In my twenty-first century north-western culture, it is often expected to describe oneself with our work(s) and/or our passion(s) so here are mine.
I have been primarily a full-stack PHP developer for 8 years. Now I specialize in Laravel. I am used to work with the MariaDB / MySQL RDBMS. I also perform administration tasks on GNU/Linux (and, alas, Windows Server when required by professional constraints). I am familiar with:
- development techniques like OOP, MVC, AJAX and TDD,
- PHP tools and libraries like Composer, PHPUnit, CodeSniffer, PHPMailer, PHPExcel, etc.,
- Apache, both on Linux and Windows thanks to Apache Lounge,
- JavaScript with jQuery, Qunit, Grunt and its useful plug-ins to fix my mistakes,
- HTML, CSS, Sass and Twitter Bootstrap,
- Git,
- Bugzilla,
- Virtualization tools like Homestead, Vagrant and VirtualBox,
- Bash scripts, command line tools and Cygwin.
I used to work with SQL Server 2005 before migrating to MariaDB. I have also learned Java, Python and PostgreSQL a few years ago but those skills would need serious refreshing! I love learning, so I am currently learning to play cello, develop Android apps and Dutch!
I am a GNU/Linux and more generally free(dom) software enthusiast. I turned my back to a nearly monopolistic closed-source system in 2009 for Kubuntu which I immediately adopted as my main system both for professional and private uses. I spent four years switching between Ubuntu and various derivatives, just for fun, to finally choose the Arch Linux way in 2013. Nowadays, it allows me to do all my computer tasks, from fun to work. Some of my main tools are i3, Firefox, Chromium, Vim and a terminal emulator (currently urxvt with tmux).
What is this website about?
This website is primarily serving as backup of my notes and findings, especially about programming and free software, in the hope it can also be useful to people encountering the same problems or questions. It also serves me to experiment and improve my programming skills.
The other purpose of this website is to provide an independent platform to express myself, in replacement of my closed social networks accounts. I felt the need to take concrete action to reflect my opinions against tracking, general surveillance and violation of people privacy.
MySQL: dump the encoding hell
I have encountered this issue in MySQL version 5.1.x, but not in 5.5 (I have not tested other versions): generating a dump of a UTF-8 encoded database (Collation: utf8_general_ci) resulted on non-ASCII characters (like "éà ç") being garbled.
I am used to backup databases with this mysqldump command:
$ mysqldump -h hostname -u username -p databaseName > backup.sql
I never had to worry about encoding since I use UTF-8 everywhere. But when I tried to import a dump file from 5.1 to 5.5, there were weird symbols like àƒ© àƒ§ all over the place! A workaround is to dump the database using the latin1 charset:
$ mysqldump -h hostname -u username -p --default-character-set=latin1 --databases databaseName -r backup.sql
The -r option outputs the data directly into backup.sql, avoiding risks of additional encoding interferences while passing through the underlying system.
Before importing the data, edit the dump file to replace the line
/*!40101 SET NAMES latin1 */;
with
/*!40101 SET NAMES utf8 */;
Finally import the dump file:
$ mysql -u username -p --default-character-set=utf8 databaseName