Creating backups of server data in Dropbox.

Recently faced with the task of creating server data backups on my vps. Various websites are hosted on it. My personal ones are built on more or less reasonable technologies/engines, so all the code is in version control system. For such sites, only backup of the database and uploaded data is needed. Some third-party sites are built on WordPress, so the source code also needs to be backed up.

So, the task is as follows: with a certain frequency, databases and the contents of certain directories need to be backed up. Backups should be kept for a specific period of time to save space.

Increase web server performance: we put nginx in front of apache

In one of the notes we described how to configure nginx + php-fpm. But nginx can be used in a slightly different way. For example, if you don't want to completely abandon apache, but you want to speed up the web server. (Perhaps you have implemented a complex redirect system that you don't want to port to nginx).

In this case, a possible solution is to use nginx only for serving static files (images, css, js, etc.). Other requests (to the php engine, for example) will still be redirected to apache (assuming you already have a site configured to work with it). To do this, configure nginx to serve static files, and proxy all other requests to apache. (In this case, you can do without php-fpm).

Mapping USB modem in udev

I decided to install kernel 3.10.4 with the tuxonice patch on my Gentoo.

The result was very satisfying, many system problems disappeared, and this is considering the fact that I did not modify the old kernel configuration. The first thing I noticed is that the network finally started working properly after waking up from suspend.

But there was something that needed adjustment.

Access restriction using .htaccess

Sometimes a convenient method to restrict access to certain sections of a website (such as the administrator panel or confidential data) is to use access restriction with .htaccess (or, alternatively, basic authentication). Of course, with scripts, this can be done more elegantly, conveniently, and sometimes even more securely. The thing is, all the information needed to gain access is sent with each request in the form of headers. But if this is not critical, then it can be used; it is probably the fastest option.

Converting table engine in MySQL

Sometimes you need to convert the table engine MySQL in an existing database.

For example, I needed to create relationships between tables. To create them, the tables must be InnoDB (to support foreign keys).

Old Wordpress (and other) projects use MyISAM because until version MySQL 5.5.4 it was the default engine. But it doesn't support many useful features, such as foreign keys, transactions, etc. All these features are supported by the more modern engine InnoDB, which is now used by default.

Create relations in MySQL database using phpmyadmin

After reading this article, you will be able to create relations in MySQL database using phpmyadmin. If for some reasons you don't want to use phpmyadmin, please look at SQL queries below.

So, what reason to store relations in the database? After all, your application also solves this task. Actually, it's all about the restrictions and actions upon changes, which can be set using relations.

For example, you can deny deleting category while any article connected with it. Or remove all articles if category removed. Or set NULL in relation field. In any case, using relations increases fault tolerance and reliability of the application.

You need to use an InnoDB engine to create a relation. Only this engine supports foreign keys. If you have MyISAM tables, you can read how convert it to InnoDB.

Setting PHP timezone in php.ini

During the work with Symfony framework, I received the following warning:

Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /var/www/symfony/app/cache/prod/classes.php on line 5009

In fact, there is nothing to worry about or unusual - this was caused by updating PHP to version 5.4, and since the new version was installed next to the old one with new configs, it was necessary to configure the PHP timezone in php.ini again. First, we need to find out which timezone we are in. More precisely, how it should be specified in the PHP config.

Installation and configuration of Apache / PHP / MySQL in Ubuntu

You have just installed the latest version of Ubuntu 13.04 and want to install additional software for learning web programming and running frameworks like Symfony 2, yii, zend, etc.? Then you've come to the right place. Let's go through 10 simple steps to achieve this. We will start with the installation of a web server and then move on to Symfony.