Linux basic configurations - web server http://basicconfig.com/taxonomy/term/8 en Setup Linux web server - Install and configure Apache in Slackware http://basicconfig.com/linuxnetwork/setup_linux_web_server-install_configure_apache_slackware <!-- google_ad_section_start --><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>If you are planning on setting up your own web server (http server) using Slackware Linux, then the Apache http server would be the perfect choice. It is a stable and secure web server and works very well with Linux. Apache http server is <a href="http://news.netcraft.com/archives/2009/04/06/april_2009_web_server_survey.html" target="_blank">The World’s #1 Web Server Tops Linux Journal’s Reader’s Choice Awards</a>.</p> <h2>Check Apache web server in Slackware Linux</h2> <p>Before we begin installing Apache http server, let's check does it already exist in our Slackware system. If you install a fresh Slackware server dedicated for web server, then it's ok. But if this is an already running Slackware server or a training server, we need to know whether Apache is already installed so we can choose to upgrade the current Apache server or to re-install a new package.</p> <p>Apache http server come in a package called <b>httpd</b>. To check httpd package in Slackware, we can view installed packages list in /var/log/packages directory. Here is the example:</p> <table><tr><td><code>luzar@slackware:~$ <span style="color:red;">ls /var/log/packages/ | grep httpd</span><br /> httpd-2.2.10-i486-1<br /> luzar@slackware:~$<br /></code></td> </tr></table><p>We can also use Slackware pkgtool utility to check httpd package. However, we need root privilege to use pkgtool. So switch to root using su command and enter the correct root password. See step by step example below:</p> <table><tr><td><code>luzar@slackware:~$ <span style="color:red;">su -</span><br /> Password:<br /> root@slackware:~# <span style="color:red;">pkgtool</span><br /></code></td> </tr></table><p>In Slackware pkgtool, choose <b>View</b> menu. Wait a few seconds for Slackware to list all packages in the system. When it's done, press <b>h</b> letter to view all packages starting with h. Use down arrow key and search for <b>httpd</b> package. See example screenshot image below:</p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/apache-webserver.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/apache-webserver.png" alt="Check httpd package using Slackware pkgtool screenshot image" /></a></p> <p>Press <b>OK</b> to see details about httpd package. Write down the version if you want.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/apache-webserver02.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/apache-webserver02.png" alt="Check httpd package details screenshot image" /></a></p> <p>You can use <b>ps</b> command to check httpd daemon status:</p> <table><tr><td><code>root@slackware:~# <span style="color:red;">ps aux | grep httpd</span><br /> root 6241 0.0 0.3 8568 3312 ? Ss 11:03 0:00 /usr/sbin/httpd -k start<br /> apache 6242 0.0 0.1 8700 2020 ? S 11:03 0:00 /usr/sbin/httpd -k start<br /> apache 6243 0.0 0.1 8700 2020 ? S 11:03 0:00 /usr/sbin/httpd -k start<br /> apache 6244 0.0 0.1 8700 2020 ? S 11:03 0:00 /usr/sbin/httpd -k start<br /> apache 6245 0.0 0.1 8700 2020 ? S 11:03 0:00 /usr/sbin/httpd -k start<br /> apache 6246 0.0 0.1 8700 2020 ? S 11:03 0:00 /usr/sbin/httpd -k start<br /> root 6250 0.0 0.0 2084 632 pts/1 R+ 11:03 0:00 grep httpd<br /> root@slackware:~#<br /></code></td> </tr></table><p>All the results above shows that apache has been installed in my Slackware system. If you your result shows that Apache is not installed in your system, you can continue reading this tutorial, which will guide you on how to install Apache web server in Slackware Linux.</p> <h2>Install Apache httpd package in Slackware Linux</h2> <p>There are two ways on how to install Apache web server in Slackware. You can install Slackware httpd package which comes with Slackware installer dvd or you can install httpd source from Apache website. The former is the easiest and hustle free while the latter is having advantage to customize installation and get the latest Apache httpd source released. We'll see both examples in this tutorial.</p> <h3>Install official Slackware httpd package</h3> <p>Here is the step by step instructions on how to install Slackware httpd package.</p> <p>1) Insert and mount Slackware installer dvd.</p> <table><tr><td><code>root@slackware:~# <span style="color:red;">mount /dev/hda /mnt/dvd/</span><br /> mount: block device /dev/hda is write-protected, mounting read-only<br /> root@slackware:~#<br /></code></td> </tr></table><p>2) Slackware httpd package is in <em>/slackware/n</em> directory. Use installpkg command to install the package.</p> <table><tr><td><code><br /> root@slackware:~# <span style="color:red;">installpkg /mnt/dvd/slackware/n/httpd-2.2.10-i486-1.tgz</span><br /> Installing package httpd-2.2.10-i486-1 ([OPT])...<br /> PACKAGE DESCRIPTION:<br /> httpd: httpd (The Apache HTTP Server)<br /> httpd:<br /> httpd: Apache is an HTTP server designed as a plug-in replacement for the<br /> httpd: NCSA HTTP server. It fixes numerous bugs in the NCSA server and<br /> httpd: includes many frequently requested new features, and has an API which<br /> httpd: allows it to be extended to meet users' needs more easily.<br /> httpd:<br /> httpd: Apache is the most popular web server in the known universe; over<br /> httpd: half of the servers on the Internet are running Apache or one of<br /> httpd: its variants.<br /> httpd:<br /> Executing install script for httpd-2.2.10-i486-1...<br /><br /> root@slackware:~#<br /></code></td> </tr></table><p><b>Note:</b><em> You can download dhcpd package from <a href="http://packages.slackware.it/" target="_blank">Slackware package website </a> if you have trouble with your Slackware installer dvd.</em></p> <p>If you already setup Slackware slackpkg package management system, you can use it to install httpd web server. See example below:</p> <table><tr><td><code>root@slackware:~# <span style="color:red;">slackpkg install httpd</span><br /></code></td> </tr></table><p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/apache-webserver03.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/apache-webserver03.png" alt="Install httpd using slackpkg screenshot image" /></a></p> <h3>Install Apache httpd source in Slackware Linux</h3> <p>Here is the step by step instructions on how to install Apache httpd source in Slackware.</p> <p>1) Download latest httpd source from <a href="http://httpd.apache.org/download.cgi" target="_blank">Apache official website</a>.</p> <p>2) Change directory to /usr/local/src (change to your chosen directory) and extract the httpd source:</p> <table><tr><td><code>root@slackware:/usr/local/src# <span style="color:red;">tar zxvf /home/luzar/Desktop/httpd-2.2.11.tar.gz</span><br /></code></td> </tr></table><p><b>Note:</b><em> Provide the right path where your httpd source location is.</em></p> <p>3) Change to the new extracted httpd directory:</p> <table><tr><td><code>root@slackware:/usr/local/src# <span style="color:red;">cd httpd-2.2.11/</span><br /></code></td> </tr></table><p>4) Open config.layout file using text editor and insert text below (There are configurations for other Linux distributions, freeBSD, openBSD, etc but no Slackware). You can check all these configurations in the Slackware httpd package (use explodepkg) to be sure that you follow Slackware standard.</p> <table><tr><td><code># Layout for Slackware Linux<br /><layout slackware=""><br /> prefix: /usr<br /> exec_prefix: ${prefix}<br /> bindir: ${prefix}/bin<br /> sbindir: ${prefix}/sbin<br /> libdir: ${prefix}/lib<br /> libexecdir: ${prefix}/lib/libexec<br /> mandir: ${prefix}/man<br /> sysconfdir: /etc/httpd<br /> datadir: /var/www<br /> installbuilddir: ${datadir}/build<br /> errordir: ${datadir}/error<br /> iconsdir: ${datadir}/icons<br /> htdocsdir: ${datadir}/htdocs<br /> manualdir: ${datadir}/manual<br /> cgidir: ${datadir}/cgi-bin<br /> includedir: ${exec_prefix}/include/httpd<br /> localstatedir: /var<br /> runtimedir: ${localstatedir}/run<br /> logfiledir: ${localstatedir}/log/httpd<br /> proxycachedir: ${localstatedir}/cache/httpd<br /></layout><br /></code></td> </tr></table><p>5) Save config.layout file when you are done. The next step is we are going to run <b>configure</b>. See the example below:</p> <table><tr><td><code>root@slackware:/usr/local/src/httpd-2.2.11# <span style="color:red;">./configure --enable-layout=Slackware --enable-module=most --enable-mods-shared=most --enable-ssl=shared</span><br /></code></td> </tr></table><p>6) Run <b>make</b></p> <table><tr><td><code>root@slackware:/usr/local/src/httpd-2.2.11# <span style="color:red;">make</span><br /></code></td> </tr></table><p>7) Run <b>make install</b></p> <table><tr><td><code>root@slackware:/usr/local/src/httpd-2.2.11# <span style="color:red;">make install</span><br /></code></td> </tr></table><p>That's it. Now we have Apache httpd installed in our Slackware server now. It's time to start the httpd service.</p> <h2>Start, stop and restart httpd (http daemon - Apache service) in Slackware Linux</h2> <p>All Slackware daemons can be found in /etc/rc.d/ directory. Slackware Apache daemon is rc.httpd. If you don't have rc.httpd in /etc/rc.d directory, you can copy the script below:</p> <table><tr><td><code>#!/bin/sh<br /> #<br /> # /etc/rc.d/rc.httpd<br /> #<br /> # Start/stop/restart/graceful[ly restart]/graceful[ly]-stop<br /> # the Apache (httpd) web server.<br /> #<br /> # To make Apache start automatically at boot, make this<br /> # file executable: chmod 755 /etc/rc.d/rc.httpd<br /> #<br /> # For information on these options, "man apachectl".<br /><br /> case "$1" in<br /> 'start')<br /> /usr/sbin/apachectl -k start<br /> ;;<br /> 'stop')<br /> /usr/sbin/apachectl -k stop<br /> killall httpd<br /> rm -f /var/run/httpd/*.pid<br /> ;;<br /> 'restart')<br /> /usr/sbin/apachectl -k restart<br /> ;;<br /> 'graceful')<br /> /usr/sbin/apachectl -k graceful<br /> ;;<br /> 'graceful-stop')<br /> /usr/sbin/apachectl -k graceful-stop<br /> ;;<br /> *)<br /> echo "Usage: $0 {start|stop|restart|graceful|graceful-stop}"<br /> ;;<br /> esac<br /></code></td> </tr></table><p>Change /etc/rc.d/rc.httpd permission to make it starts during reboot:</p> <table><tr><td><code>root@slackware:/etc/rc.d# <span style="color:red;">chmod 755 rc.httpd</span><br /></code></td> </tr></table><p>Here is the command to start Apache httpd service in Slackware:</p> <table><tr><td><code>root@slackware:~# <span style="color:red;">/etc/rc.d/rc.httpd start</span><br /> httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName<br /> root@slackware:~#<br /></code></td> </tr></table><p>Here is a command to restart Apache httpd service in Slackware:</p> <table><tr><td><code>root@slackware:~# <span style="color:red;">/etc/rc.d/rc.httpd restart</span><br /> httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName<br /> root@slackware:~#<br /></code></td> </tr></table><p>Here is a command to stop Apache httpd service in Slackware:</p> <table><tr><td><code>root@slackware:~# <span style="color:red;">/etc/rc.d/rc.httpd stop</span><br /> httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName<br /> root@slackware:~#<br /></code></td> </tr></table><p>We have to start Slackware httpd service to use Apache web server. In the example above, we have warning every time we start, restart and stop httpd service. This warning indicates that our dns is not properly configured but we still can test our web server using localhost. So let's test our Apache httpd server right away. Open web browser and type <b><a href="http://localhost">http://localhost</a></b> in the url (you can also use ip address 127.0.0.1, which is the loopback ip address). If you have lynx, you can type <b>lynx localhost</b> to check our web server from the command line terminal. Press enter and you should have the same result as the example below:</p> <table><tr><td><code>luzar@ubuntu:~$ <span style="color:red;">lynx localhost</span><br /></code></td> </tr></table><p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/localhost.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/localhost.png" alt="Example testing Apache httpd web server using lynx screenshot image" /></a></p> <h2>Configure Apache httpd server in Slackware Linux</h2> <p>Slackware httpd server configuration files can be found in /etc directory. The main http server configuration file is httpd.conf. We can customize our web server by editing this file. Here are the most basic configuration that you need to edit in the httpd.conf file:</p> <p>Add <b>index.php</b>, <b>index.htm</b> and <b>index.xhtml</b> in the <em>DirectoryIndex</em>:</p> <table><tr><td><code>&lt;IfModule dir_module&gt;<br /> DirectoryIndex index.html index.php index.htm index.xhtml<br /> &lt;/IfModule&gt;<br /></code></td> </tr></table><p>Set your email address to receive any problems with the server:</p> <table><tr><td><code>ServerAdmin root@example.com</code></td> </tr></table><p>ServerName gives the name and port that the server uses to identify itself. If your host doesn't have a registered DNS name, enter its IP address here. You can also set as localhost like in the example below:</p> <table><tr><td><code>ServerName localhost:80</code></td> </tr></table><p>You also need to remove comment(#) from the line below:</p> <table><tr><td><code># Various default settings<br /> #Include /etc/httpd/extra/httpd-default.conf</code></td> </tr></table><p>to be like this:</p> <table><tr><td><code># Various default settings<br /> Include /etc/httpd/extra/httpd-default.conf</code></td> </tr></table><p>That is the basic configuration that you need to do. Everything else is up to you. There are several other things to setup for the content management system. You can find specific setting for apache httpd.conf in joomla and Drupal tutorials. When you finished, save and exit.</p> <p>Create a new html file to test our new Apache httpd configuration just for fun. Below is the example:</p> <table><tr><td><code>root@slackware:/etc/httpd# <span style="color:red;">cd /var/www/htdocs/</span><br /> root@slackware:/var/www/htdocs# <span style="color:red;">cat &gt; index.html</span><br /> &lt;html&gt;<br /> &lt;head&gt;<br /> &lt;title&gt;Slackware Apache httpd configuration testing.&lt;/title&gt;<br /> &lt;/head&gt;<br /><br /> &lt;body&gt;<br /> &lt;h1&gt;This is a testing page.&lt;/h1&gt;<br /> &lt;p&gt;It works alright!&lt;/p&gt;<br /> &lt;/body&gt;<br /> &lt;/html&gt;<br /></code></td> </tr></table><p>Now we can restart httpd service again and test the new configuration. Here is the command: </p> <table><tr><td><code>root@slackware:/etc/httpd# <span style="color:red;">/etc/rc.d/rc.httpd restart</span><br /></code></td> </tr></table><p>Here is the result:</p> <table><tr><td><code>root@slackware:/var/www/htdocs# <span style="color:red;">lynx localhost</span> </code></td> </tr></table><p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/test-apache-httpd01.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/test-apache-httpd01.png" alt="Check Apache web server screenshot image" /></a></p> <p>One thing to remember, in the future when restarting httpd after upgrade to the latest slackware httpd package, the httpd.conf file will be override. So you might not be able to view some of your websites. However, Slackware does not delete the old httpd.conf configuration file. What you need to do is just copy your configuration to the new file and restart httpd service again.</p> <p>That's all. Good luck.</p> </div></div></div><!-- google_ad_section_end --><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above"><div class="field-label">Tags:&nbsp;</div><div class="field-items"><div class="field-item even" rel="dc:subject"><a href="/taxonomy/term/16" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">linux server</a></div><div class="field-item odd" rel="dc:subject"><a href="/taxonomy/term/8" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">web server</a></div></div></div> Wed, 24 Jun 2009 05:45:46 +0000 jinlusuh 126 at http://basicconfig.com http://basicconfig.com/linuxnetwork/setup_linux_web_server-install_configure_apache_slackware#comments Linux web server setup - Install and configure Apache2 in Ubuntu http://basicconfig.com/linuxnetwork/ubuntu_web_server_setup <!-- google_ad_section_start --><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>Apache server is an open source web server or HTTP server widely used not only in Linux and Unix-based operating system but nowadays in Windows as well. Apache is known for it's stability and highly configurable with support of many add on modules for customization. In Linux, Apache, PHP and MySql work greats together and always be a perfect web server solution for many organizations around the world.</p> <h2>Ubuntu web server installation</h2> <p>We must first check apache2 package in Ubuntu to make sure it's already installed using <b>dpkg</b> and <b>ps</b> command. Here are dpkg and ps command usage examples:</p> <table><tr><td><code>luzar@ubuntu:~$ <span style="color:red;">sudo dpkg -l | grep apache</span><br /> [sudo] password for luzar:<br /> ii apache2 2.2.8-1ubuntu0.3 Next generation, scalable, extendable web server<br /> ii apache2-mpm-prefork 2.2.8-1ubuntu0.3 Traditional model for Apache HTTPD<br /> ii apache2-utils 2.2.8-1ubuntu0.3 utility programs for webservers<br /> ii apache2.2-common 2.2.8-1ubuntu0.3 Next generation, scalable,<br /> extendable web server<br /> ii libapache2-mod-php5 5.2.4-2ubuntu5.4 server-side, HTML-embedded<br /> scripting language<br /> luzar@ubuntu:~$<br /></code></td> </tr></table><p>In the example above, we use <b>| (pipe) grep</b> with dpkg command to grab all apache package in our system. If we just use <b>dpkg -l apache</b>, dpkg won't find apache unless we specified the exact name, which is apache2.</p> <p>This is an example of how to use ps command to check apache running service:</p> <table><tr><td><code>luzar@ubuntu:~$ <span style="color:red;">ps aux | grep apache</span><br /> root 4594 0.0 1.3 20460 6748 ? Ss Dec10 0:01 /usr/sbin/apache2 -k start<br /> www-data 5247 0.0 0.6 20460 3376 ? S Dec10 0:00 /usr/sbin/apache2 -k start<br /> www-data 5248 0.0 0.6 20460 3376 ? S Dec10 0:00 /usr/sbin/apache2 -k start<br /> www-data 5249 0.0 0.6 20460 3376 ? S Dec10 0:00 /usr/sbin/apache2 -k start<br /> www-data 5253 0.0 0.6 20460 3376 ? S Dec10 0:00 /usr/sbin/apache2 -k start<br /> www-data 5255 0.0 0.6 20460 3376 ? S Dec10 0:00 /usr/sbin/apache2 -k start<br /> luzar 8725 0.0 0.1 3004 752 pts/0 R+ 02:32 0:00 grep apache<br /> luzar@ubuntu:~$<br /></code></td> </tr></table><p>If you don't have results like the example above, that means apache has not been installed in your system. You can install apache using apt-get command like an example below:</p> <table><tr><td><code>luzar@ubuntu:~$ <span style="color:red;">sudo apt-get install apache2</span><br /> Reading package lists... Done<br /> Building dependency tree<br /> Reading state information... Done<br /> ...<br /> ...<br /></code></td> </tr></table><h2>Apache2 start, stop and restart service</h2> <p>Now that apache2 already installed in your system, it's time to start the service. Here is the command to start apache2 service:</p> <table><tr><td><code>luzar@ubuntu:~$ <span style="color:red;">sudo /etc/init.d/apache2 start</span><br /> [sudo] password for luzar:<br /> * Starting web server apache2 [ OK ]<br /></code></td> </tr></table><p>Here is a command to stop apache2 service:</p> <table><tr><td><code>luzar@ubuntu:~$ <span style="color:red;">sudo /etc/init.d/apache2 stop</span><br /> [sudo] password for luzar:<br /> * Stopping web server apache2 [ OK ]<br /></code></td> </tr></table><p>Here is a command to restart apache2 service:</p> <table><tr><td><code>luzar@ubuntu:~$ <span style="color:red;">sudo /etc/init.d/apache2 restart</span><br /> * Restarting web server apache2 [ OK ]<br /></code></td> </tr></table><p>Starting and stopping apache2 service is important when you are testing apache2 configuration and troubleshooting. All changes you made to the configuration file only be affected once you restart apache2 service.</p> <p>At this point, you probably don't have any problem starting apache2 service. The apache2 still using default configuration. You can test your new web server using lynx web browser to open localhost default website in Ubuntu command line terminal. If you don't have lynx in your system, check <a href="/linuxnetwork/lynx_browser_ubuntu">lynx tutorial</a> for installation and usage guide. Here is an example of a default apache2 website opened using lynx web browser:</p> <table><tr><td><code>luzar@ubuntu:~$ <span style="color:red;">lynx localhost</span><br /></code></td> </tr></table><p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/localhost.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/localhost.png" alt="Example of testing apache2 web server using lynx screenshot" /></a></p> <h2>Ubuntu apache2 configuration</h2> <p>All Apache2 configuration files are located in /etc/apache2 in Ubuntu. Other than apache2 main configuration file, apache2.conf, there are many other files and directory included in the package. In the past, httpd.conf is the apache main configuration file. Don't get confused. Ubuntu has made apache2 configuration easier though you might see it complicated. Here are the complete list of files and directories in apache2 directory:</p> <table><tr><td><code>luzar@ubuntu:/etc/apache2$ <span style="color:red;">ls -l</span><br /> total 40<br /> -rw-r--r-- 1 root root 10587 2008-06-25 09:49 apache2.conf<br /> drwxr-xr-x 2 root root 4096 2008-10-19 15:17 conf.d<br /> -rw-r--r-- 1 root root 378 2008-06-25 09:49 envvars<br /> -rw-r--r-- 1 root root 0 2008-10-19 15:17 httpd.conf<br /> drwxr-xr-x 2 root root 4096 2008-12-11 20:46 mods-available<br /> drwxr-xr-x 2 root root 4096 2008-10-19 15:17 mods-enabled<br /> -rw-r--r-- 1 root root 59 2008-06-25 09:49 ports.conf<br /> drwxr-xr-x 2 root root 4096 2008-10-19 15:17 sites-available<br /> drwxr-xr-x 2 root root 4096 2008-10-19 15:17 sites-enabled<br /> luzar@ubuntu:/etc/apache2$<br /></code></td> </tr></table><p>Here are default configuration and brief explanation of files and directories above:</p> <h3>/etc/apache2/apache2.conf </h3> <p>Apache2 main configuration file.</p> <table><tr><td><code><br /> ### Section 1: Global Environment<br /> #<br /> # The directives in this section affect the overall operation of Apache,<br /> # such as the number of concurrent requests it can handle or where it<br /> # can find its configuration files.<br /> #<br /><br /> #<br /> # ServerRoot: The top of the directory tree under which the server's<br /> # configuration, error, and log files are kept.<br /> #<br /> # NOTE! If you intend to place this on an NFS (or otherwise network)<br /> # mounted filesystem then please read the LockFile documentation (available<br /> # at &lt;URL:http://httpd.apache.org/docs-2.1/mod/mpm_common.html#lockfile&gt;);<br /> # you will save yourself a lot of trouble.<br /> #<br /> # Do NOT add a slash at the end of the directory path.<br /> #<br /> ServerRoot "/etc/apache2"<br /><br /> #<br /> # The accept serialization lock file MUST BE STORED ON A LOCAL DISK.<br /> #<br /> ...<br /> ...<br /></code></td> </tr></table><h3>/etc/apache2/httpd.conf</h3> <p>Add additional configuration parameters. By default, this file is empty.</p> <h3>/etc/apache2/envvars </h3> <p>Environment variables to tune the operation of Apache server.</p> <table><tr><td><code># envvars - default environment variables for apache2ctl<br /><br /> # Since there is no sane way to get the parsed apache2 config in scripts, some<br /> # settings are defined via environment variables and then used in apache2ctl,<br /> # /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.<br /> export APACHE_RUN_USER=www-data<br /> export APACHE_RUN_GROUP=www-data<br /> export APACHE_PID_FILE=/var/run/apache2.pid<br /></code></td> </tr></table><h3>/etc/apache2/ports.conf </h3> <p>Port numbers that the Apache server will listen on.</p> <table><tr><td><code>Listen 80<br /><br /> &lt;IfModule mod_ssl.c&gt;<br /> Listen 443<br /> &lt;/IfModule&gt;<br /></code></td> </tr></table><h3>/etc/apache2/conf.d/ </h3> <p>Put additional Apache configuration files in this directory. By default this directory only contains an example additional apache configuration file named charset . Here is charset default configuration.</p> <table><tr><td><code># Read the documentation before enabling AddDefaultCharset.<br /> # In general, it is only a good idea if you know that all your files<br /> # have this encoding. It will override any encoding given in the files<br /> # in meta http-equiv or xml encoding tags.<br /><br /> #AddDefaultCharset UTF-8<br /></code></td> </tr></table><h3>/etc/apache2/mods-available/</h3> <p>Contains all the modules installed for your server. This is the default modules came with Ubuntu 8.04 server. For additional modules, visit <a href="http://modules.apache.org"> apache modules</a> page in apache official website. Here are example of modules in /mod-available directory:</p> <table><tr><td><code>luzar@ubuntu:/etc/apache2$ <span style="color:red;">ls mods-available/</span><br /> actions.conf authz_owner.load dir.load mem_cache.load setenvif.load<br /> actions.load authz_user.load disk_cache.conf mime.conf speling.load<br /> alias.conf autoindex.conf disk_cache.load mime.load ssl.conf<br /> alias.load autoindex.load dump_io.load mime_magic.conf ssl.load<br /> asis.load cache.load env.load mime_magic.load status.conf<br /> auth_basic.load cern_meta.load expires.load negotiation.conf status.load<br /> auth_digest.load cgid.conf ext_filter.load negotiation.load substitute.load<br /> authn_alias.load cgid.load file_cache.load php5.conf suexec.load<br /> authn_anon.load cgi.load filter.load php5.load unique_id.load<br /> authn_dbd.load charset_lite.load headers.load proxy_ajp.load userdir.conf<br /> authn_dbm.load dav_fs.conf ident.load proxy_balancer.load userdir.load<br /> authn_default.load dav_fs.load imagemap.load proxy.conf usertrack.load<br /> authn_file.load dav.load include.load proxy_connect.load version.load<br /> authnz_ldap.load dav_lock.load info.conf proxy_ftp.load vhost_alias.load<br /> authz_dbm.load dbd.load info.load proxy_http.load<br /> authz_default.load deflate.conf ldap.load proxy.load<br /> authz_groupfile.load deflate.load log_forensic.load rewrite.load<br /> authz_host.load dir.conf mem_cache.conf setenvif.conf<br /></code></td> </tr></table><h3>/etc/apache2/mods-enabled/ </h3> <p>As you can see from mod-available above, there are 86 modules available by default. They are not enabled yet. Create a symbolic link in this directory that refers to the module file in /mods-available above to enable it. Below are the default enabled modules:</p> <table><tr><td><code>luzar@ubuntu:/etc/apache2$ <span style="color:red;">ls -l mods-enabled/</span><br /> total 0<br /> lrwxrwxrwx 1 root root 28 2008-10-19 15:17 alias.conf -&gt; ../mods-available/alias.conf<br /> lrwxrwxrwx 1 root root 28 2008-10-19 15:17 alias.load -&gt; ../mods-available/alias.load<br /> lrwxrwxrwx 1 root root 33 2008-10-19 15:17 auth_basic.load -&gt; ../mods-available/auth_basic.load<br /> lrwxrwxrwx 1 root root 33 2008-10-19 15:17 authn_file.load -&gt; ../mods-available/authn_file.load<br /> lrwxrwxrwx 1 root root 36 2008-10-19 15:17 authz_default.load -&gt; ../mods-available/authz_default.load<br /> lrwxrwxrwx 1 root root 38 2008-10-19 15:17 authz_groupfile.load -&gt; ../mods-available/authz_groupfile.load<br /> lrwxrwxrwx 1 root root 33 2008-10-19 15:17 authz_host.load -&gt; ../mods-available/authz_host.load<br /> lrwxrwxrwx 1 root root 33 2008-10-19 15:17 authz_user.load -&gt; ../mods-available/authz_user.load<br /> lrwxrwxrwx 1 root root 32 2008-10-19 15:17 autoindex.conf -&gt; ../mods-available/autoindex.conf<br /> lrwxrwxrwx 1 root root 32 2008-10-19 15:17 autoindex.load -&gt; ../mods-available/autoindex.load<br /> lrwxrwxrwx 1 root root 26 2008-10-19 15:17 cgi.load -&gt; ../mods-available/cgi.load<br /> lrwxrwxrwx 1 root root 26 2008-10-19 15:17 dir.conf -&gt; ../mods-available/dir.conf<br /> lrwxrwxrwx 1 root root 26 2008-10-19 15:17 dir.load -&gt; ../mods-available/dir.load<br /> lrwxrwxrwx 1 root root 26 2008-10-19 15:17 env.load -&gt; ../mods-available/env.load<br /> lrwxrwxrwx 1 root root 27 2008-10-19 15:17 mime.conf -&gt; ../mods-available/mime.conf<br /> lrwxrwxrwx 1 root root 27 2008-10-19 15:17 mime.load -&gt; ../mods-available/mime.load<br /> lrwxrwxrwx 1 root root 34 2008-10-19 15:17 negotiation.conf -&gt; ../mods-available/negotiation.conf<br /> lrwxrwxrwx 1 root root 34 2008-10-19 15:17 negotiation.load -&gt; ../mods-available/negotiation.load<br /> lrwxrwxrwx 1 root root 27 2008-10-19 15:17 php5.conf -&gt; ../mods-available/php5.conf<br /> lrwxrwxrwx 1 root root 27 2008-10-19 15:17 php5.load -&gt; ../mods-available/php5.load<br /> lrwxrwxrwx 1 root root 31 2008-10-19 15:17 setenvif.conf -&gt; ../mods-available/setenvif.conf<br /> lrwxrwxrwx 1 root root 31 2008-10-19 15:17 setenvif.load -&gt; ../mods-available/setenvif.load<br /> lrwxrwxrwx 1 root root 29 2008-10-19 15:17 status.conf -&gt; ../mods-available/status.conf<br /> lrwxrwxrwx 1 root root 29 2008-10-19 15:17 status.load -&gt; ../mods-available/status.load<br /></code></td> </tr></table><p>Here is an example to enable another module:</p> <table><tr><td><code>luzar@ubuntu:/etc/apache2$ <span style="color:red;">cd mods-enabled/</span><br /> luzar@ubuntu:/etc/apache2/mods-enabled$ <span style="color:red;">ln -s ../mods-available/rewrite.load <br />rewrite.load</span><br /> [sudo] password for luzar:<br /> luzar@ubuntu:/etc/apache2/mods-enabled$ <span style="color:red;">ls -l |grep rewrite.load</span><br /><span style="color:green;">lrwxrwxrwx 1 root root 30 2008-12-12 03:37 rewrite.load -&gt; <br />../mods-available/rewrite.load</span><br /></code></td> </tr></table><p>To disable a module, just delete the symbolic link.</p> <h4>/etc/apache2/sites-available/ </h4> <p>Stores all the configuration files for the web sites serviced by Apache server. By default, only one file available, a default virtual host configuration file:</p> <table><tr><td><code>NameVirtualHost *<br /> &lt;VirtualHost * &gt;<br /> ServerAdmin webmaster@localhost<br /><br /> DocumentRoot /var/www/<br /> &lt;Directory /&gt;<br /> Options FollowSymLinks<br /> AllowOverride None<br /> &lt;/Directory&gt;<br /> &lt;Directory /var/www/&gt;<br /> Options Indexes FollowSymLinks MultiViews<br /> AllowOverride None<br /> Order allow,deny<br /> allow from all<br /> &lt;/Directory&gt;<br /><br /> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/<br /> &lt;Directory "/usr/lib/cgi-bin"&gt;<br /> AllowOverride None<br /> Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch<br /> Order allow,deny<br /> Allow from all<br /> &lt;/Directory&gt;<br /><br /> ErrorLog /var/log/apache2/error.log<br /><br /> # Possible values include: debug, info, notice, warn, error, crit,<br /> # alert, emerg.<br /> LogLevel warn<br /><br /> CustomLog /var/log/apache2/access.log combined<br /> ServerSignature On<br /><br /> Alias /doc/ "/usr/share/doc/"<br /> &lt;Directory "/usr/share/doc/"&gt;<br /> Options Indexes MultiViews FollowSymLinks<br /> AllowOverride None<br /> Order deny,allow<br /> Deny from all<br /> Allow from 127.0.0.0/255.0.0.0 ::1/128<br /> &lt;/Directory&gt;<br /><br /> &lt;/VirtualHost&gt;<br /></code></td> </tr></table><h3>/etc/apache2/sites-enabled/</h3> <p>Create a symbolic link to enable sites in /etc/apache2/sites-available.</p> <p>As you can see from the testing web server example previously, the default apache2 configuration is already working. Perhaps you want to change document root directory from /var/www to /srv/www because you want to keep certain server in a dedicated directory. Perhaps also because you want to avoid future problems where logs files taking all the available space. You can change the document root directory by editing /sites-available/default file configuration like an example below: </p> <p>First you make a backup of the original file:</p> <table><tr><td><code>luzar@ubuntu:/etc/apache2/sites-available$ <span style="color:red;">sudo cp default default.ori</span><br /> [sudo] password for luzar:<br /> luzar@ubuntu:/etc/apache2/sites-available$ <span style="color:red;">ls</span><br /> default default.ori<br /></code></td> </tr></table><p>Open /sites-available/default file with text editor and change document root directory like the example below:</p> <table><tr><td><code>luzar@ubuntu:/etc/apache2/sites-available$ <span style="color:red;">sudo vim default</span><br /> NameVirtualHost *<br /> &lt;VirtualHost *&gt;<br /> ServerAdmin webmaster@localhost<br /><br /> DocumentRoot /srv/www/<br /> &lt;Directory /&gt;<br /> Options FollowSymLinks<br /> AllowOverride None<br /> &lt;/Directory&gt;<br /> &lt;Directory /srv/www/&gt;<br /> Options Indexes FollowSymLinks MultiViews<br /> AllowOverride None<br /> Order allow,deny<br /> allow from all<br /> &lt;/Directory&gt;<br /> ...<br /> ...<br /></code></td> </tr></table><p>Then, copy the /var/www directory to /srv/ directory:</p> <table><tr><td><code>luzar@ubuntu:~$ <span style="color:red;">sudo cp -r /var/www /srv/www</span><br /></code></td> </tr></table><p>Create a new html file to test new document root directory. For example, I created a file named test.html in /srv/www directory. Here is the content:</p> <table><tr><td><code><br /> &lt;html&gt;<br /> &lt;head&gt;<br /> &lt;title&gt;My testing website&lt;/title&gt;<br /> &lt;/head&gt;<br /><br /> &lt;body&gt;<br /> &lt;h1&gt;This is a testing website&lt;/h1&gt;<br /> &lt;p&gt;It works alright!&lt;/p&gt;<br /> &lt;/body&gt;<br /> &lt;/html&gt;<br /></code></td> </tr></table><p>Now we can restart apache2 service again before we test the new configuration. Here is the command: </p> <table><tr><td><code>luzar@ubuntu:~$ <span style="color:red;">sudo /etc/init.d/apache2 restart</span><br /></code></td> </tr></table><p>Finally we can test our new configuration. Here is the command: </p> <table><tr><td><code>luzar@ubuntu:~$ <span style="color:red;">lynx localhost/test.html</span><br /></code></td> </tr></table><p>Here is the result:</p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/test.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/test.png" alt="New document root testing website screenshot" /></a></p> <p>So our apache2 web server works fine. We can now put our website in /srv/www directory.</p> </div></div></div><!-- google_ad_section_end --><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above"><div class="field-label">Tags:&nbsp;</div><div class="field-items"><div class="field-item even" rel="dc:subject"><a href="/taxonomy/term/16" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">linux server</a></div><div class="field-item odd" rel="dc:subject"><a href="/taxonomy/term/8" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">web server</a></div></div></div> Thu, 11 Dec 2008 04:17:31 +0000 jinlusuh 125 at http://basicconfig.com http://basicconfig.com/linuxnetwork/ubuntu_web_server_setup#comments Setup local web server for windows - Install, configure and testing xampp http://basicconfig.com/software/local_webserver <!-- google_ad_section_start --><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>Why do you need a local web server? Most would answer it's for testing a website. It doesn't matter whatever reason you need a web server for, here is a simple, easy and free way to have one in your computer.</p> <p>For a free web server and compatible with Windows operating system, we have Apache web server. Apache is a great web server, well established and has been using in Unix and Unix-based operating system for many years. It is well maintains and has many source of support such as online forum and security guide.</p> <p>Then, maybe you would need a database server. Mysql is a good choice. It's free and stable and has well support too. There are lots of FAQs and forum available in Internet if you need help. Documentation is well written, it's our perfect choice then. </p> <p>Perhaps we need a server side scripting too. For many years, people has been using Mysql with PHP. They are a great couple. And good news, PHP is free too. </p> <p>So, there we have all softwares that we need. Here's the list of where you can have them:</p> <table><tr><td><a href="http://httpd.apache.org/download.cgi">Download Apache web server.</a><br /> Look for Apache for Windows. Choose the right version for your Windows.</td> </tr><tr><td><a href="http://dev.mysql.com/downloads/windows/">Download Mysql database server.</a><br /> Look for Mysql database for Windows. Scroll down the page until you find the right version.</td> </tr><tr><td><a href="http://my1.php.net/downloads.php">Download php for Windows installer.</a><br /> Pick a mirror closest to you for a faster download. Choose the right version for your Windows.</td> </tr></table><p>From the list above, you can customize your web server however you want. But if what you need is only a simple, working web server to use locally and easy to install and configure than I recommend Apache Friends XAMPP for windows. It is a package of softwares mentioned above plus an FTP server and a mail server.</p> <p>You can download Apache Friends XAMPP for windows from <a href="http://www.apachefriends.org/en/xampp-windows.html">their website.</a></p> <p>Here the step by step on how to install xampp in windows:</p> <p>Firstly, download xampp installer from the Apache Friends wesite's link above. </p> <p>After finished downloading, double click xampp installer to start the installation. You should get the welcome message like the picture below:</p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/01welcome.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/01welcome.png" alt="xampp welcome message" /></a></p> <p>Just click next and xampp installer will ask for xampp install location. You can change to your preference or just click next for default location.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/02location.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/02location.png" alt="xampp install location" /></a></p> <p>Here is the options. You can install xampps as a service too. That means xampp will be added into Windows services. That means you can start and stop apache, mysql and other xampp services from Windows Services in Windows Control Panel. If you choose not to add to Windows services, you can always start apache and mysql from zampp control panel.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/03options.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/03options.png" alt="xampp install options" /></a></p> <p>Xampp installation in process. It takes only a few seconds and not worth to grap your pizza. Just wait for a while.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/04install.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/04install.png" alt="xampp install process" /></a></p> <p>Xampp installer will install php automatically, so don't worry if this command prompt pop up. During this time, if you have a firewall in your system, it will warn you about xampp services. It's green so it means friendly warning. Give access for xampp services.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/05configphp.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/05configphp.png" alt="xampp php configuration" /></a></p> <p>There you go. Less than 5 minutes of installation process.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/06finish.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/06finish.png" alt="xampp install finish" /></a></p> <p>A little hint from xampp.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/07hint.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/07hint.png" alt="xampp hint" /></a></p> <p>A congratulation message from xampp.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/08congrat.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/08congrat.png" alt="xampp congratulation message" /></a></p> <p>Here is xampp control panel. If you didn't choose to install services during the installation process, you can still tick the box beside each services to install it into Windows Services. Click start button to start service.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/09controlpanel.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/09controlpanel.png" alt="xampp control panel" /></a></p> <h2>Configure web server</h2> <p>1. Now that our web server is ready to use, we are going to configure the web server folder. Click start --&gt; All Programs --&gt; Apache Friends --&gt; XAMPP --&gt; XAMPP Httpdocs folder. That is the location of our web server root directory.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/xamppconfig01.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/xamppconfig01.png" alt="xampp web server root location" /></a></p> <p>2. Let's create a shortcut on the desktop to make our job easier in the future. We are going to open this folder frequently. Just right-click on the XAMPP httpdocs folder and choose Send to --&gt; Desktop (create shortcut) </p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/xamppconfig02.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/xamppconfig02.png" alt="Create shortcut for xampp httpdocs folder" /></a></p> <p>3. Open xampp httpdocs folder. This is the root directory of our web server. Put all our website file here and open web browser to view it.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/xamppconfig03.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/xamppconfig03.png" alt="xampp web server root directory" /></a></p> <p>4. To test our website, open web browser and type <b>localhost/website_folder/</b> in the url and enter.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/xamppconfig04.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/j/jinlusuh/thumbs/xamppconfig04.png" alt="xampp website testing" /></a></p> <p>That's all. The Apache Friends really did a great job. The xampp project is really useful and save us lots of our time. There are more projects and add on for xampp in their website. We can show our support by giving a donation.</p> <p><a href="http://www.apachefriends.org/en/xampp.html">Apache Friends xampp project page</a>.</p> </div></div></div><!-- google_ad_section_end --><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above"><div class="field-label">Tags:&nbsp;</div><div class="field-items"><div class="field-item even" rel="dc:subject"><a href="/taxonomy/term/8" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">web server</a></div><div class="field-item odd" rel="dc:subject"><a href="/taxonomy/term/9" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">software</a></div></div></div> Mon, 08 Sep 2008 16:22:08 +0000 jinlusuh 69 at http://basicconfig.com http://basicconfig.com/software/local_webserver#comments