Presentation is loading. Please wait.

Presentation is loading. Please wait.

School of Computer Science and Information Technology COSC1300 / COSC1301 Web Servers and Web Technology COSC1300 / COSC1301 Web Servers and Web Technology.

Similar presentations


Presentation on theme: "School of Computer Science and Information Technology COSC1300 / COSC1301 Web Servers and Web Technology COSC1300 / COSC1301 Web Servers and Web Technology."— Presentation transcript:

1 School of Computer Science and Information Technology COSC1300 / COSC1301 Web Servers and Web Technology COSC1300 / COSC1301 Web Servers and Web Technology Apache Installation Week 3

2 Web Servers and Web Technology Why Apache? Why Unix? Apache: ( Ease of installation Transparent configuration Open source (and therefore free) Popular (http://news.netcraft.com/archives/web server survey.html)http://news.netcraft.com/archives/web server survey.html Extensible (many third party modules Very good documentation (http://httpd.apache.org/docs-2.0/)http://httpd.apache.org/docs-2.0/ Semester 1, RMIT Department of Computer Science and IT

3 Web Servers and Web Technology Other platforms, other servers Many commercial products are just a bundled Apache. ─ Apache Tomcat Other Options: ─ IIS ─ NGINX ─ Lighttpd ─ GWS Semester 1, RMIT Department of Computer Science and IT

4 Web Servers and Web Technology Apache Installation on UNIX Common general steps (from source code): ─ configure: ► generates a Makefile ─ make ► compiles the code and creates a executable binary based on the Makefile settings ─ make install ► installs executable binary to final location Semester 1, RMIT Department of Computer Science and IT

5 Web Servers and Web Technology Before you Install While detailed instructions will be provided for the installation of your web server, you should think about what you are doing at each step. This will help you later in the assignment, in which you are required to reinstall with a different configuration without instructions. If you are having trouble, ask a lab assistant. Semester 1, RMIT Department of Computer Science and IT

6 Web Servers and Web Technology Preparation Log into iWeb1.cs.rmit.edu.au Change to your working directory cd /iweb/username *NOTE: Replace username with your own username. You will be compiling Apache and PHP from source, so you will need the source code. Create a directory to hold the source code and copy it there mkdir src cd src cp /public/courses/WebServersAndWebTechnology/src/httpd tar.gz. cp /public/courses/WebServersAndWebTechnology/src/php tar.gz. Semester 1, RMIT Department of Computer Science and IT

7 Web Servers and Web Technology Preparation Uncompress and unarchive the source code (often called a tarball): gtar zxvf httpd tar.gz gtar zxvf php tar.gz This will create directories httpd and php (httpd is the Apache source directory. httpd is the HTTP daemon. You will examine this in the topic “The Web”.) Semester 1, RMIT Department of Computer Science and IT

8 Web Servers and Web Technology Compiling the Apache Source Code Before installing any software you should read any associated README and INSTALL files. Change into the Apache directory (/iweb/username /src/httpd ) cd /iweb/username/src/httpd ─ and type: less README ─ and less INSTALL Semester 1, RMIT Department of Computer Science and IT

9 Web Servers and Web Technology Now you should run the configure script that comes with Apache. ─ Your port needs to be different from the ports of other students. You should use 5 followed by the last four digits of your student number. (Example: If your student number is s , then use port number 52234)./configure --prefix=/iweb/username/apache2 \ --with-port= Your port \ --enable-so \ --with-mpm=prefork ─ Ask a lab assistant if you have any doubt. Semester 1, RMIT Department of Computer Science and IT Compiling the Apache Source Code

10 Web Servers and Web Technology NOW SPEND SOME TIME TRYING TO UNDERSTAND THE COMMAND YOU JUST TYPED. DISCUSS THIS WITH YOUR TUTOR. Semester 1, RMIT Department of Computer Science and IT Compiling the Apache Source Code

11 Web Servers and Web Technology If the configure script finishes without error, you should now compile Apache and copy the binaries to the locations specified when you configured. make make install Semester 1, RMIT Department of Computer Science and IT Compiling the Apache Source Code

12 Web Servers and Web Technology Starting Apache If your installation was successful, you should now be able to start Apache. Change to the bin directory of your Apache installation and run the apachectl script. cd /iweb/username/apache2/bin./apachectl start Check that you have an httpd process running by typing: ps -u username Semester 1, RMIT Department of Computer Science and IT

13 Web Servers and Web Technology Ensuring that Apache Responds The Apache default page can now be viewed at: Your port Semester 1, RMIT Department of Computer Science and IT

14 Web Servers and Web Technology Stop Apache cd /iweb/username/apache2/bin./apachectl stop Note: You must stop apache before you commence your php installation. Semester 1, RMIT Department of Computer Science and IT

15 Web Servers and Web Technology Apache DAEMON httpd ─ http daemon daemon ─ dae·mon/ ˈ dēmən/ ► Noun:(in ancient Greek belief) A divinity or supernatural being of a nature between gods and humans. ► A background process that handles requests for services such as print spooling and is dormant when not required. Other types of daemons? Semester 1, RMIT Department of Computer Science and IT

16 Web Servers and Web Technology PHP – Apache - MySql Semester 1, RMIT Department of Computer Science and IT

17 Web Servers and Web Technology Compiling the PHP Source Code Change to the PHP directory (/iweb/username/src/php-5.1.4): cd /iweb/username/src/php ─ and type less INSTALL Again, take into consideration that you are not installing as root and that your installation will be in a non-standard directory. Semester 1, RMIT Department of Computer Science and IT

18 Web Servers and Web Technology Compiling the PHP Source Code To configure the PHP for installation, go to your PHP source directory, and type:./configure \ --with-apxs2=/iweb/username/apache2/bin/apxs \ --prefix=/iweb/username/php5 If the configure script finishes without error, you should now compile PHP and copy the binaries to the locations specified when you configured as follows: make make install Semester 1, RMIT Department of Computer Science and IT

19 Web Servers and Web Technology Configuring Apache for PHP You now need to tell Apache what to do with a PHP file as follows: ─ Change to the conf directory of your Apache installation. cd /iweb/username/apache2/conf ─ Backup the apache configuration file before you make any changes to it. cp httpd.conf httpd.conf.bak ─ Edit the file httpd.conf nedit httpd.conf Semester 1, RMIT Department of Computer Science and IT

20 Web Servers and Web Technology Configuring Apache for PHP Find the line: AddType application/x-tar.tgz Below it add the lines AddType application/x-httpd-php.php AddType application/x-httpd-php-source.phps ─ Note: these lines do not begin with a “#”, since lines that begin with a “#” are comments and will not be read by Apache) Ensure that you can find the following line in your configuration file: LoadModule php5_module modules/libphp5.so Semester 1, RMIT Department of Computer Science and IT

21 Web Servers and Web Technology Test PHP Start Apache cd /iweb/username/apache2/bin./apachectl start Create a.php file called information.php cd /iweb/username/apache2/htdocs nedit information.php (this opens up the nedit text editor) ─ In the text editor type the following php code: In a browser open the following link: Your port /information.php Semester 1, RMIT Department of Computer Science and IT

22 Web Servers and Web Technology Cleanup Source Files cd /iweb/username/src/httpd make distclean cd /iweb/username/src/php make distclean cd /iweb/username/src rm -rf httpd rm -rf php It is important to clean up all source files. make distclean puts all of the files into their original state. You must do this if you have to reinstall Apache. By deleting the source files you are saving significant space on the hard drive. The hard drives on iweb1 and iweb2 will fill up if students do not do this! Semester 1, RMIT Department of Computer Science and IT

23 Web Servers and Web Technology Apache 2.0 versus Apache 2.2 features 2 0.html ─ Support for threading on Unix ─ Multi-platform support (MPMs) ─ providing native implementation for Windows and increase in performance ─ mod ssl bundled features 2 2.html ─ Apache has very recently released version 2.2. We are not using this as it does not have support for PHP yet! ─ Much better caching to improve web server performance. ─ Improved organisation of the configuration file. ─ Redesigned support for authentication and authorization. Semester 1, RMIT Department of Computer Science and IT

24 Web Servers and Web Technology Multi-Processing Modules Different platforms, different needs - more information in the Web Server Performance lecture Some MPMs for Unix: ─ worker (hybrid of threading/processes) ─ prefork (original 1.3.x process based version) For Windows: ─ mpm_winnt What MPM are we using for our apache installation? How does it work? Semester 1, RMIT Department of Computer Science and IT

25 Web Servers and Web Technology Dynamic Shared Objects Our installation uses DSOs, These are enable by including the --enable-so directive, to load the mod_so module, during Apache configuration. DSOs can either be included when the server is compiled, or, as we do with the PHP module, included later by using the LoadModule directive in Apache’s httpd.conf file (actually, the process of installing PHP writes this line into the httpd.conf file automatically). The Apache apxs program is used to build DSO modules. Semester 1, RMIT Department of Computer Science and IT

26 Web Servers and Web Technology Static Modules The alternative is to statically compile modules which Apache is built. The simplest way to include the SSL module, mod_ssl is to compile it statically. What are the advantages and disadvantages of DSO? What are the advantages and disadvantages of Static Modules? Semester 1, RMIT Department of Computer Science and IT

27 Web Servers and Web Technology lighttpd, FastCGI and PHP An emerging alternative to Apache is lighttpd As its name suggests, this server is light (uses a small amount of memory per process) and fast. According (to its own) benchmarking, it is faster than Apache. It uses FastCGI - a significant improvement on CGI - to run PHP (and other script languages) scripts. It’s also a great platform for rubyonrails - Semester 1, RMIT Department of Computer Science and IT


Download ppt "School of Computer Science and Information Technology COSC1300 / COSC1301 Web Servers and Web Technology COSC1300 / COSC1301 Web Servers and Web Technology."

Similar presentations


Ads by Google