apache is called apache2 in debian/ubuntu and httpd in Centos/Fedora, it lives in /etc/apache2/
apt-get install apache2 libapache2-mod-php5 mysql-server php5-mysql php5 openssl ssl-cert
you normally create some kind of “Virtual Host” that points to where your website files are on your server, so you have to specify all that, along with who has access and what IP and port you want apache to look for visitors to your website on, otherwise it has no idea.
here’s a virtual host that works (you will have to modify it for your server). If you’re using Jessie/Apache2.4 MAKE SURE to end your filename in .conf, or it wont’ read it.
ServerName www.scooby.com DirectoryIndex index.php ServerAdmin firstname.lastname@example.org ErrorLog /var/log/apache2/error.log DocumentRoot /var/www/scooby/ Options Indexes FollowSymLinks Multiviews AllowOverride All Order allow,deny allow from all # Next line required in apache 2.4, not 2.2 and earlier Require all granted
or more complex with more goodies
ServerAdmin email@example.com DocumentRoot /clients/example.com/www/ ScriptAlias /cgi-bin/ /clients/example.com/cgi/ ServerAlias example.com *.example.com ServerName www.example.com AddType application/x-httpd-php .html AddHandler server-parsed .shtml ErrorLog /clients/example.com/logs/example.com-error_log LogFormat "%h %l %u %t \"%r\" %>s %b" common CustomLog "|/usr/bin/cronolog /clients/example.com/logs/%Y/%m/%d/example.com-access_log" common Options -Indexes FollowSymLinks MultiViews AllowOverride None Order deny,allow Allow from all # Next line required in apache 2.4, not 2.2 and earlier Require all granted
Once you make your file whatever.conf in /etc/apache2/sites-available, you have to enable it by running:
a simple alias in the beastly 2.2.52 without the dreaded 403 error, in this case to make a mirror site
Alias /mirror/ /var/mirror/ <Directory "/var/mirror"> Options Indexes Includes FollowSymLinks Multiviews AllowOverride All Order allow,deny Allow from all
unable to determine hostname, using 127.0.0.1 error
to fix this error, do:
vi /etc/apache2/apache2.conf ServerName localhost <--add this line somewhere /etc/init.d/apache2 restart
|a2enmod rewrite||enabled modrewrite so you can make sane URL’s from gobleygook|
|a2ensite www.example.com||enables a website you have listed in /etc/apache2/sites-availabe by putting a symlink in /etc/apache2/sites-enabled , you then have to reload apache2, which you do by doing /etc/init.d/apache2 reload|
|httperf –server [my server] –port 80 –uri / –rate 250 –num-conn 100 –num-call 100 –timeout 5||applies a load to your server to test if it breaks|
apache2 out of memory OOM crash
The default settings in apache2 seem prone to memory exhaustion issues which then crash the box. You might see an error like this on your console:
Killed process 8737 (apache2) Out of memory: kill process 9786 (apache2) score 38746 or a child
If this happens, change your /etc/apache2/apache2.conf section below to the values below. Before you do, make a copy of what you started with in case you want to revert to those. You can, of course, also add memory if you have the ability in your environment, which will help as well.
StartServers 1 MinSpareServers 3 MaxSpareServers 6 ServerLimit 24 MaxClients 24 MaxRequestsPerChild 3000