Remove Apache2 from linux server

Here we are,

I’m leaving Apache for Nginx which is a faster asynchronous http server.
If you need more informations about it, please go here http://www.wikivs.com/wiki/Apache_vs_nginx.

So, to start with a clean base, I’ve had to first remove apache from my server, this is how to deal with it.

//Stop apache server
sudo service apache2 stop 

//Uninstall Apache2 and its dependent packages
sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common

//By precaution
apt-get purge apache2

//remove any other dependencies that were installed with Apache2, but are no longer used by any other package
sudo apt-get autoremove

//Delete apache2 directory manually
sudo rm -rf /etc/apache2

Thank you for reading.

Advertisements
Remove Apache2 from linux server

FFMPEG merge audio and video to multiple outputs formats

Hi everybody,

I was wondering this day, how to combine audio and video file to multiple outputs formats using FFMPEG.
I’ve searched a long on Google with no results, so I thought by myself and have found the solution, it’s very simple to use.
All you have to do is add outputs to your convert command, and it’s done.

By example, let’s try to convert wav and webm input into mp4, we’ll proceed as this:

ffmpeg -i input.webm -i input.wav -map 0:0 -map 1:0 output.mp4

Good, now when it comes to add multiple outputs, it is not more difficult, we only have to add new outputs at the suit.
By example, let’s try to add “avi and ogg” formats.
This is the result

ffmpeg -i input.webm -i input.wav -map 0:0 -map 1:0 output.mp4 output.ogg output.avi

Perfect !
But some formats will need specific codecs in order to work, like “FLV”.
To make it work you only have to specify the corresponding codecs before the output, like this.

ffmpeg -i input.webm -i input.wav -map 0:0 -map 1:0 output.mp4 output.ogg output.avi -c:a libmp3lame -ar 44100 -c:v libx264 output.flv

And for linux users

ffmpeg -i input.webm -i input.wav -map 0:0 -map 1:0 -strict experimental output.ogg -strict experimental output.mp4 -c:a libmp3lame -ar 44100 -c:v libx264 -strict experimental output.flv

Congratulations, the job is done, you’re a hero.
Hope it will help you.

FFMPEG merge audio and video to multiple outputs formats

Linux easily save git credentials

Hello everybody,

If you’re searching a quicker way to save your git credentials on Linux, there is a one line command for it that will save your life.
The idea is to put your credentials in the cache and give it a lifetime.
It works fine!

git config --global credential.helper 'cache --timeout 36000'

Hope this will help you.

Linux easily save git credentials

Doctrine Annotations 1.2.2 // Bug errorException unlink annotations

Hello,

If you have updated doctrine dependency today 2014-12-19, and since 2014-12-18, you may have faced this error:

[ErrorException]
  unlink(/var/www/xxx/app/cache/dev/annotations/54940ee3e1d910.826327572T4l9C): No such file or directory

The problem is caused for a recent update in Doctrine Annotations, in the fileReader that tries to delete a file that has been removed.
I’ve proposed a fix here:
https://github.com/doctrine/annotations/commit/6355277c8254bfeb9db68fae0d1de53f1cd09388

if you want to fix this issue quickly, just open:

nano /var/www/xxxx/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php

//Then, Comment line 207
//@unlink($tempfile);
Doctrine Annotations 1.2.2 // Bug errorException unlink annotations

Linux swap space for cloud servers like AWS EC2; DigitalOcean or your local machine

Hi everyone,

We have decided in my company to make all the dev team make on the same distribution, we’ve choosen for that, DigitalOcean.
DigitalOcean doesn’t actually offer multilevel account managements, so each of us had to create a specific Droplet, we have then made database replication to centralize our work, we will do further later.

When I tried to update composer on my symfony project, I’ve got this error:

Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar:///var/www/headoo/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:974

What does it mean?
It means that our OS is using a lot of memory and that there is not enough memory available to do some actions. Why?
By default, Linux tends to use all the RAM to speed up its operations, particularly caching datas.
Therefore it can easily happen in situations where the RAM is used at 90% or more, while treatments only need the half.

Let’s explain more
Simply run “free -m” command to see how many memory is available on your machine, and let’s analyze the result.
Here, we will work on a 7.5GO ram available machine.

[root@~]# free -m
             total       used       free     shared    buffers     cached
Mem:          7873       7289        583          0        251       4272
-/+ buffers/cache:       2765       5107
Swap:         4095         70       4025

It seems to be more than 7 GB of RAM used, more than 4 GB for the cache (buffers and cache), see the last column.

Ok right, so, how to solve this problem?

1. First, you can empty linux cache

[root@~]# sync; echo 3 > /proc/sys/vm/drop_caches

2. Swap some space. What is a swap?
The swap is a “virtual” physical memory often installed on a separate Linux partition. Part of hard drive is reserved for this virtual memory that could relieve the system in case of overload.

3. How to swap some space?
Type in your console:

dd if=/dev/zero of=/swapfile bs=1M count=1024 #count must be equal to the desired block size you need
mkswap /swapfile                              #Setup the swap file with the command
swapon /swapfile                              #Enable the swap file immediately but not automatically at boot time
/swapfile swap swap defaults 0 0              #Enable swap file at the boot time

Right! Now your problem must be solved, if not, do not hesitate to contact me please.

Linux swap space for cloud servers like AWS EC2; DigitalOcean or your local machine

AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message

When you start or restart your apache server on Linux and it gives you such error message like below, that means you didn’t specified the domain or ip that your server has to respond to.

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message

It is very easy to solve this, I will show you how, just execute these commands (tested on Debian and Ubuntu):

nano /etc/apache2/apache2.conf

Add at the end of the document:

ServerName "YourDomain.com"

“YourDomain.com” can also be a ip address.

Finally, just restart apache:

service apache2 restart

And that’s all, everything would be ok right now.

AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message

Stream live mp4 video with ffmpeg while encoding

Hello everybody,

It’s been awhile I’ve posted an article on this blog, and, it’s with a great pleasure I share with you what I’ve just learnt… How to stream an mp4 video while encoding it, directly with ffmpeg just like Youtube or Vimeo?

First, we’ll have to understand why an mp4 video has to be completely loaded by the browser in order to play it.

1. MOOV ATOM, What’s that?
MOOV ATOM, is literaly an autonomous unit of metadata related to the video file, that contains informations about:
– The video duration
– The video display characteristics
– Some additional video track informations

With mp4 files, the MOOV ATOM is placed by default at the end of the file, so, until your video is completely loaded, it is impossible to know its duration and some other essential informations, this is why mp4 videos are not natively streamable on the fly while encoding.

But, this is not the case for “flv, ogg, webm, mpeg-ts” video files, that are called SOTF (Stream-Oriented Transport Format).

2. How to encode mp4 and move MOOV ATOM details to the beginning?
This is done in just one command with the “-movflags faststart” attributes, juste like this.

ffmpeg -i input.avi -c:v libx264 -crf 22 -c:a libfaac -movflags faststart output.mp4

3. Now, how to stream our video while encoding?
Ok, now we have a streamable mp4 file, what we need is to live streaming it while encoding.
You have many ways to solve this, like using JWPlayer and FFMPEG.

I will not explain again what has been perfectly explained on another website, so I recommand you to see this great tutorial about video live streaming with FFServer and FFmpeg.
https://www.virag.si/2012/11/streaming-live-webm-video-with-ffmpeg/

Or this great tutorial too.
http://www.bogotobogo.com/VideoStreaming/ffmpeg_http_live_streaming_hls.php

Hope it helped you.

Stream live mp4 video with ffmpeg while encoding