Linux Commands Examples

A great documentation place for Linux commands


Apache Hypertext Transfer Protocol Server

see also : apache2ctl


apache2 [ -d serverroot ] [ -f config ] [ -C directive ] [ -c directive ] [ -D parameter ] [ -e level ] [ -E file ] [ -k start|restart|graceful|stop|graceful-stop ] [ -R directory ] [ -h ] [ -l ] [ -L ] [ -S ] [ -t ] [ -v ] [ -V ] [ -X ] [ -M ]

add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!


sudo service apache2 stop
service apache2 restart
service apache2 stop
service apache2 stop
sudo service apache2 restart

Set up a wireless server, allowing access to files on computer, without offering internet

Pretty much all you need to do is to set up a router somehow - I do believe some wireless adaptors would do that, and/or you can use hostapd. Tricky thing really is to get the users to find the server - you would need to set up a captive portal for that - the firewall approach makes most sense here. If you wanted to make it even simpler, just name the AP in some way its obvious how to find the server ;)

Something that might work perfectly, with a few tweaks is the piratebox - these installations scripts would be what you're looking for, and there's more usecases here.


Linux server broken packages

Ok here's what I ended up doing:

First of all, I would recommend using aptitude instead of apt-get because it makes better choices by default. So, I went ahead and accepted aptitude's first solution, which was to leave everything the same version except for php5-curl which was to be installed. Trust me, you don't want to update the php5-common or libapache2-mod-php5 packages on a mission-critical server because they have a million dependencies. Then the server couldn't download the package because the repositories are outdated on this server (it's 10.04 remember) and it couldn't find the .deb file. So, I copied the name php5-curl-5.2.10.dfsg.1-2ubuntu6_amd_64.deb and Google'd it and found site hosting the .deb file. I then did the following commands to install this package without causing dependency hell:

$ wget

$ sudo dpkg -i php5-curl-5.2.10.dfsg.1-2ubuntu6_amd_64.deb

and then of course restart Apache

$ sudo /etc/init.d/apache2 restart

And voila! cURL was installed.


See active connection on apache web server

  1. I think for seeing current ip connectivity only this is the command there . You can refer this for advacned usage

  2. It shows all type of connections time_out , Time_wait , and connected and established in state .

For the above commands, you can do google


Having difficulties getting my vhosts to work properly

Looks like you have <VirtualHost> *:80> spelled incorrectly. Should be <VirtualHost *:80>


View specific virtualhost from within Virtualbox Windows XP?

I have the same setup as you do (Debian host, VirtualBox, WinXP guest {plus a Win2k3 server guest}), and IP-based routing works fine without using ports.

Although I did create a hosts file entry in each VM that points to, there is no "harm" in doing that since the IP will never change.


Creating a separate access_log and error_log for Apache2

An .htaccess file won't work, sorry. You need to put it in a logfile.

From the config docs at apache

CustomLog Directive
Description:    Sets filename and format of log file
Syntax: CustomLog file|pipe format|nickname [env=[!]environment-variable]
Context:    server config, virtual host
Status: Base
Module: mod_log_config

I haven't tested to see if it works in blocks though. You might want to experiment with that. Failing that, they have an example of SetEnfIf and CustomLog based on env vars which would work for what you wanted.


Apache can't bind to address [::]:80, already in use

Chrome is not listening on a local port 80 but just connected to a remote port 80.

I don't really see a problem. But try to specify an IP to listen on, as it seems to be failing on IPv6 right now...


httpd running but Apache not listening

This turned out to be a firewall issue. The IP address for dev was not opened in the firewall.


How do I save log files to another partition?

You can configure the location of the log files in apache2 in /etc/httpd/conf/httpd.conf:

 ErrorLog "/var/log/httpd/error_log"

 <IfModule log_config_module>                    
     CustomLog "/var/log/httpd/access_log" common

If you feel like too much information is being logged by apache, you can change the log level in /etc/httpd/conf/httpd.conf to warn, crit or alert (please see the apache documentation page for more information on loglevel values):

 LogLevel warn

If that's not enough, you can also modify the logrotate config for apache2 in /etc/logrotate.d/httpd. The logrotate for apache2 is usually configured as a daily cron job.


How to make SSHFS case sensitive

The problem is not SSHFS but the file system on OS X. HFS is case per default case-insensitve. HFS remembers the case of a name but the file system is case insensitive.

It is now possible to format an OS X partition with HFS Plus with the "case sensitive" option, but Apple is still prudent and cannot guarantee that applications will not have problems.


How do I prevent Apache service from auto-starting on Linux?

Depending on your distro, you should be able to execute a command to disable the service on startup. Doing this it will be stopped until you manually start it. Here are some examples on different distros:

  • Ubuntu/Debian: update-rc.d -f apache2 remove
  • Gentoo: rc-update del apache2
  • ArchLinux: systemctl disable apache2

Apache2 + mod_fcgid + php stopped working after upgrade from Debian squeeze to wheezy

Now I stumbled upon the solution by myself. The problem is caused by an update of mod_fcgid which changed the directives used in the vhost configs. The changes could be seen here (this is what I stumbled upon).

The directive

FCGIWrapper /var/www/ .php

has to be changed to

FcgidWrapper /var/www/ .php

The documentation says

"All directives have been renamed in order to use a common prefix "Fcgid". Underscores in directive names have been eliminated in favor of CamelCase. The old directive names will still work but are deprecated. To fix your configuration you can use the sed script build/fixconf.sed."

but it seems like the old directive names didn't work anymore for now. The changes have done the trick for me, maybe this will help someone else.


Apache2 mod_mono ubuntu virtual hosting

You can check the apache log file and see what the error is and search for solution on it.


In my case, I have installed mono and mod_mono from source. They work on apache with PHP working on it. Here is a link that will help you get started:


Setting local network via WiFi

1) Introduce, in your DHCP server config file (located differently on different distros, in Debian and derivatives it is /etc/default/dhcp3-server, for other distros you will have to hunt it don), the following line:

   option domain-name              "";

inside the subnet stanza.

2) use the following iptables rules:

  iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
  iptables -I INPUT 2 -p tcp --dport ! 80 -j DROP
  iptables -I INPUT 3 -p udp -j DROP 


-d serverroot

Set the initial value for the ServerRoot directive to serverroot. This can be overridden by the ServerRoot directive in the configuration file.

-f config

Uses the directives in the file config on startup. If config does not begin with a /, then it is taken to be a path relative to the ServerRoot. The default is /etc/apache2/apache2.conf.

-k start|restart|graceful|stop|graceful-stop

Signals apache2 to start, restart, or stop. See Stopping Apache for more information.

-C directive

Process the configuration directive before reading config files.

-c directive

Process the configuration directive after reading config files.

-D parameter

Sets a configuration parameter which can be used with <IfDefine> sections in the configuration files to conditionally skip or process commands at server startup and restart.

-e level

Sets the LogLevel to level during server startup. This is useful for temporarily increasing the verbosity of the error messages to find problems during startup.

-E file

Send error messages during server startup to file.

-R directory

When the server is compiled using the SHARED_CORE rule, this specifies the directory for the shared object files.


Output a short summary of available command line options.


Output a list of modules compiled into the server. This will not list dynamically loaded modules included using the LoadModule directive.


Output a list of directives together with expected arguments and places where the directive is valid.


Dump a list of loaded Static and Shared Modules.


Show the settings as parsed from the config file (currently only shows the virtualhost settings).


Run syntax tests for configuration files only. The program immediately exits after these syntax parsing tests with either a return code of 0 (Syntax OK) or return code not equal to 0 (Syntax Error). If -D DUMP_VHOSTS is also set, details of the virtual host configuration will be printed. If -D DUMP_MODULES is set, all loaded modules will be printed.


Print the version of apache2, and then exit.


Print the version and build parameters of apache2, and then exit.


Run apache2 in debug mode. Only one worker will be started and the server will not detach from the console.


The full documentation is available in the apache2-doc package or at . Information about Debian specific changes and configuration can be found in /usr/share/doc/apache2.2-common/README.Debian.gz .


apache2 is the Apache HyperText Transfer Protocol (HTTP) server program. It is designed to be run as a standalone daemon process. When used like this it will create a pool of child processes or threads to handle requests.

In general, apache2 should not be invoked directly, but rather should be invoked via /etc/init.d/apache2 or apache2ctl. The default Debian configuration requires environment variables that are defined in /etc/apache2/envvars and are not available if apache2 is started directly. However, apache2ctl can be used to pass arbitrary arguments to apache2.

see also

apache2ctl , /usr/share/doc/apache2.2-common/README.Debian.gz

How can this site be more helpful to YOU ?

give  feedback