Posts

Installing OCI8 on Ubuntu

If we want to use a database from PHP, we need to install OCI8 extension, which it will provide an API to the use of Oracle databases. Installing OCI8 on Ubuntu is not as easy as doing an apt-get, as it takes some SDK packages provided by Oracle and their distribution license prevents that can be included in Linux distributions. This means we will have to download and compile them ourselves.  Below is the steps to follow:  1. Install PEAR and PECL. sudo apt-get install php-pear 2. Download ''Oracle Instant Client''. We need at least the following packages 'Basic' and 'SDK'. 3. Unzip the files sudo mkdir -p /opt/oracle cd /opt/oracle sudo unzip instantclient-basic-linux-xxxxxxx.zip sudo unzip instantclient-sdk-linux-xxxxxxx.zip sudo mv /opt/oracle/instantclient_xx_x /opt/oracle/instantclient The 'X' should be replaced by the appropriate version. 4. Create symbolic links. cd /opt/oracle/instantclient sudo ln -s libclntsh.so....

Batch file to connect to an FTP and put a file

Recently I needed to create a batch file to back up a file on a FTP from another machine. It was not as trivial as might be expected initially, but once you've found out is pretty easy, I put it here in case someone finds it useful. You just have to create a file with execute permissions containing the following lines: #!/bin/bash ftp -n -v xxx.xxx.xxx.xxx << EOT user username password prompt put filename bye EOT

How to solve: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

I'm going to discuss a problem I've had recently and it has taken me longer than expected to know what was happening. For a few days, randomly my server has been displaying the message: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' The Apache server was working normally, but Drupal could not access the database because the Mysql process had died. I started looking at the trace of mysql to see may have happened. It did not show any error message. When looking at the trace of S.O. (using dmesg) saw a memory overflow error. After doing a little research on Google, I found that Apache, when there are a greater number of connections, use all available memory on the server, causing the mysql closes before he could write anything in your log file. The solution has been to adjust the apache settings to reduce the amount of memory consumed and leave enough room to other processes running (like MySQL).

How to create swap file for amazon EC2 EBS instance

Amazon instances do not create a swap partition by default. If you want an easy solution to create it, we can do the following: sudo dd if = /dev/zero of = /var/swapfile bs = 1M count = 2048 sudo chmod 600 /var/swapfile sudo mkswap /var/swapfile echo /var/swapfile none swap defaults 0 0 | sudo tee -a /etc/fstab sudo swapon -a These instructions will create a 2Gb swap file. If you want to increase or reduce, just change the value of count=2048 in the first instruction

How access a remote machine via SSH behind a proxy?

If we want to access external server via SSH, it is possible that if we are behind a proxy we will not have access to port 22 used by SSH. As root, edit the file sshd_config: sudo nano /etc/ssh/sshd_config Edit the line which states 'Port 22' and changed it by 'Port 443'. This port is used by 'https' so it will not be closed in the proxy. Switch over to the new port by restarting SSH. sudo /etc/init.d/ssh restart