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

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

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

Access Mysql without password and recover root password

You don’t remember your mysql password, be quiet, this is how you can access your mysql server without password and query for a new root password.

Step 1 : Stop mysql service

/etc/init.d/mysql stop

Step 2: Start to MySQL server without password:

mysqld_safe --skip-grant-tables &

Step 3: Connect to mysql server using mysql client:

mysql -u root

Step 4: Setup new MySQL root user password

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

Step 5: Stop MySQL Server:

/etc/init.d/mysql stop

Step 6: Start MySQL server and test it

/etc/init.d/mysql start
mysql -u root -p
Access Mysql without password and recover root password

Install dropbox on linux server debian 7 (wheezy)

Installing dropbox in command line can be very paintful if you don’t know some tips.
I will give you a complete tutorial based on my personal experience.

First you have to check how many bits your CPU server can handle (x64 or x86), just type this:

    uname -m

 

Then choose the correct repository

    wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86"
    OR
    wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86_64"

 

If you don’t have Python installed in your server, install it because Dropbox will need it

    apt-get install python

 

Ensure that you’re not going to clog your home directory and extract the content

    tar -tzf dropbox.tar.gz
    tar -xvzf dropbox.tar.gz

 

Now, you can run dropbox

    ~/.dropbox-dist/dropboxd

 

You should now see output like this

    This client is not linked to any account... Please visit https://www.dropbox.com/cli_link?host_id=7d44a557aa58f285f2da0x67334d02c1 to link this machine.

 

Dropbox will loop on this message, copy this link, target it in your browser and log in to your Dropbox account, you will see a confirmation that your machine has been linked to your dropbox account.
PS: MAKE SURE TO NOT STOP THIS LOOP ! Copy the link by right clicking, but don’t press ctrl+C, it will stop the loop and your account will not be logged.

 

Now, we will get a python file from the dropbox site in order to start dropbox server.

    mkdir -p ~/bin  
    wget -O ~/bin/dropbox.py "http://www.dropbox.com/download?dl=packages/dropbox.py"  
    chmod 755 ~/bin/dropbox.py  

 

Right ! Now we can have the list of available commands Dropbox has to offer

    python ~/bin/dropbox.py help

 

Alright ! Now start dropbox server

    python ~/bin/dropbox.py start

 

Check that server has been successfully started

    python ~/bin/dropbox.py status

 

Congratulations, your dropbox folder is now on this directory

    ~/Dropbox

 

CONGRATULATIONS, it can’t be much simpler :).

Install dropbox on linux server debian 7 (wheezy)