You are on page 1of 10

TECNOLOGAS DE LA INFORMACIN Y COMUNICACIN - TSU 3-F,G : Desarrollo de Aplicaciones Web

Apache (httpd)
The World Wide Web (WWW or Web for short), is a collection of servers that hold material, called content, that Web browsers (or just browsers) can display. Each of the servers on the Web is connected to the Internet, a network of networks (an internetwork). Much of the content on the Web is coded in HTML (Hypertext Markup Language, page 1086). Hypertext, the code behind the links that you click on a Web page, allows browsers to display and react to links that point to other Web pages on the Internet. Apache is the most popular Web server on the Internet today. It is both robust and extensible. The ease with which you can install, configure, and run it in the Linux environment makes it an obvious choice for publishing content on the World Wide Web. The Apache server and related projects are developed and maintained by the Apache Software Foundation (ASF), a notfor-profit corporation formed in June 1999. The ASF grew out of the Apache Group, which was established in 1995 to develop the Apache server. Apache HTTP Server Version 2.4 Documentation http://httpd.apache.org/docs/2.4/

To see if the packages are installed, use the rpm command:


[JeBus@localhost ~]$ su Password: [root@localhost JeBus]# rpm -q httpd package httpd is not installed [root@localhost JeBus]# rpm -q apr package apr is not installed [root@localhost JeBus]# rpm -q apr-util package apr-util is not installed [root@localhost JeBus]# rpm -q php-mysql package php-mysql is not installed

Install the following packages:


[root@localhost JeBus]# yum install httpd httpd.i386 0:2.2.3-81.el5.centos [root@localhost JeBus]# rpm -q httpd httpd-2.2.3-81.el5.centos [root@localhost JeBus]# rpm -q apr apr-1.2.7-11.el5_6.5 [root@localhost JeBus]# rpm -q apr-util apr-util-1.2.7-11.el5_5.2 [root@localhost ~]# yum install php-mysql php-mysql.i386 0:5.1.6-40.el5_9

Ing. Jesus Bustos Medina - JeBusSoft

Page 1

TECNOLOGAS DE LA INFORMACIN Y COMUNICACIN - TSU 3-F,G : Desarrollo de Aplicaciones Web

Starting Apache :
Run chkconfig to cause httpd to start when the system enters multiuser mode: [root@localhost JeBus]# /sbin/chkconfig httpd on After you configure Apache, use service to start httpd: [root@localhost JeBus]# /sbin/service httpd start Starting httpd: [ OK ] After changing the Apache configuration, restart httpd with the following command, which will not disturb clients connected to the server: root@localhost JeBus]# /sbin/service httpd graceful

More packages
You can install the following optional packages: php: Embedded PHP scripting language, including IMAP & LDAP support. system-config-httpd: GUI configuration tool . webalizer: Web server log analyzer. httpd-manual: The Apache manual . mod_ssl: Secure Sockets Layer extension mrtg: MRTG traffic monitor. net-snmp and net-snmp-utils: SNMP, required for MRTG. mod_perl: Embedded Perl scripting language mod_python: Embedded Python scripting language

More Information
Local The Apache Reference Manual and Users Guide: Point a browser at : http://localhost/manual if httpd is running or at /var/www/manual/index.html if httpd is not running. The manual is available online only if the httpd-manual package is installed. Web Apache documentation: httpd.apache.org/docs/2.2 Apache directives list: httpd.apache.org/docs/2.2/mod/directives.html Apache Software Foundation (newsletters, mailing lists, projects, module registry, and more): www.apache.org mod_perl: perl.apache.org mod_php: www.php.net mod_python: www.modpython.org mod_ssl: www.modssl.org MRTG: mrtg.hdl.com/mrtg SNMP: net-snmp.sourceforge.net SSI: httpd.apache.org/docs/2.2/howto/ssi.html webalizer: www.mrunix.net/webalizer

Ing. Jesus Bustos Medina - JeBusSoft

Page 2

TECNOLOGAS DE LA INFORMACIN Y COMUNICACIN - TSU 3-F,G : Desarrollo de Aplicaciones Web

JumpStart I: Getting Apache Up and Running


Modifying the httpd.conf Configuration File
Apache runs as installed, but add the line described in this section to the /etc/httpd/conf/httpd.conf configuration file before starting Apache. The ServerName line establishes a name for the server. Add one of the following lines to httpd.conf to set the name of the server to the domain name of the server or, if you do not have a domain name, to the IP address of the server: ServerName example.com or ServerName IP_address . [root@localhost ~]# emacs /etc/httpd/conf/httpd.conf After making the changes to httpd.conf, start or restart httpd . [root@localhost ~]# service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]

Putting Your Content in Place


Place the content you want Apache to serve in /var/www/html. Apache automatically displays the file named index.html in this directory. /var/www/html/index.html

Ing. Jesus Bustos Medina - JeBusSoft

Page 3

TECNOLOGAS DE LA INFORMACIN Y COMUNICACIN - TSU 3-F,G : Desarrollo de Aplicaciones Web

File Protections
A Linux system may have many users with login accounts. To maintain privacy and security, most users can access only some files on the system, not all. This access control is embodied in two questions: Who has permission? Every file and directory has an owner who has permission to do anything with it. What kind of permission is granted? File owners, groups, and the world may each have permission to read, write (modify), and execute (run) particular files. To see the ownership and permissions of a file, run: $ ls -l myfile -rw-r--r-- 1 smith smith 7384 Jan 04 22:40 myfile To see the ownership and permissions of a directory, run: $ ls -ld dirname drwxr-x--- 3 smith smith 4096 Jan 08 15:02 dirname In the output, the file permissions are the 10 leftmost characters, a string of r (read), w (write), x(execute), other letters, and dashes. For example: -rwxr-x---

Heres what these letters and symbols mean: Position 1 24 57 8 10 Meaning File type: - = file, d = directory, l = symbolic link, p = named pipe, c = character device, b = block device . Read, write, and execute permissions for the files owner . Read, write, and execute permissions for the files group . Read, write, and execute permissions for all other users .

Ing. Jesus Bustos Medina - JeBusSoft

Page 4

TECNOLOGAS DE LA INFORMACIN Y COMUNICACIN - TSU 3-F,G : Desarrollo de Aplicaciones Web

chmod
chmod [options] permissions files The chmod (change mode) command protects files and directories from unauthorized users on the same system, by setting access permissions. Typical permissions are read, write, and execute, and they may be limited to the file owner, the files group owner, and/or other users. The permissions argument can take three different forms: Scope (optional) u for user, g for group, o for other users not in the group, a for all users. The default is a. Command + to add permissions; to remove permissions; or = to set absolute permissions, ignoring existing ones. Permissions r for read, w for write/modify, x for execute (for directories, this is permission to cd into the directory), X for conditional execute (explained later), u to duplicate the user permissions, g to duplicate the group permissions, o to duplicate the other users permissions, s for setuid or setgid, and t for the sticky bit. For example : [root@mmm2pdn133 www]# ls -ld html drwxr-xr-x 2 root root 4096 Jun 26 07:38 html [root@mmm2pdn133 www]# chmod g+rw html [root@mmm2pdn133 www]# ls -ld html drwxrwxr-x 2 root root 4096 Jun 26 07:38 html

SELinux is preventing the http daemon from connecting to network port 3306 Detailed Description: SELinux has denied the http daemon from connecting to 3306. An httpd script is trying to do a network connect to a remote port. If you did not setup httpd to network connections, this could signal a intrusion attempt. Allowing Access: If you want httpd to connect to network ports you need to turn on the httpd_can_network_network_connect boolean: "setsebool -P httpd_can_network_connect=1" The following command will allow this access: [root@mmm2pdn133]#setsebool -P httpd_can_network_connect=1

Ing. Jesus Bustos Medina - JeBusSoft

Page 5

TECNOLOGAS DE LA INFORMACIN Y COMUNICACIN - TSU 3-F,G : Desarrollo de Aplicaciones Web

JumpStart II: Setting Up Apache


Using system-config-httpd
Make a copy of httpd.conf The system-config-httpd utility overwrites this file. Make a copy of httpd.conf for safekeeping before you run this utility for the first time. /etc/httpd/conf/httpd.conf

You can use the system-config-httpd utility to display the HTTP window, which allows you to edit the /etc/httpd/conf/httpd.conf file to set up Apache. To run this utility, enter system-config-httpd on a command line or select Main menu: System -> Server Settings -> Administration HTTP. The HTTP window has four tabs: Main. Virtual Hosts. Server. Performance Tuning. Each field in these tabs/windows corresponds to a directive in the /etc/httpd/conf/httpd.conf file. Main tab The Main tab allows you to establish the name of the server, an email address for the server administrator, and

the ports and addresses that Apache listens on for requests.

Ing. Jesus Bustos Medina - JeBusSoft

Page 6

TECNOLOGAS DE LA INFORMACIN Y COMUNICACIN - TSU 3-F,G : Desarrollo de Aplicaciones Web Highlight an entry in the Available Addresses subwindow, and click Edit to edit that entry or Add to add a new entry. Both actions bring up a window that allows you to specify a port and select whether you want to listen to all IP addresses on that port or listen to a specific address. To get started, set up Apache to listen to all available addresses on port 80.

Virtual Hosts The Virtual Hosts tab allows you to establish default settings for Apache and set up virtual hosts. Click the Virtual Hosts tab, and then click Edit to edit the settings for the highlighted virtual host or Add to add a new virtual host.

Ing. Jesus Bustos Medina - JeBusSoft

Page 7

TECNOLOGAS DE LA INFORMACIN Y COMUNICACIN - TSU 3-F,G : Desarrollo de Aplicaciones Web The other tabs in the Virtual Host Properties window are Page Options , SSL, Logging, Environment, and Performance. This window is similar to the one you used to establish default settings, except that it pertains to a specific virtual host and has more tabs. You do not have to change most of the values in this window. Click OK when you are done making changes.

Server tab Usually you do not need to change the values in the Server tab. You can specify the pathname of the lock file (LockFile directive), the PID file (PidFile directive), and the directory that Apache stores core dumps in (CoreDumpDirectory). The lower portion of the tab allows you to specify the user and group that Apache runs as.

Ing. Jesus Bustos Medina - JeBusSoft

Page 8

TECNOLOGAS DE LA INFORMACIN Y COMUNICACIN - TSU 3-F,G : Desarrollo de Aplicaciones Web Performance Tuning tab The selections in the Performance Tuning tab control the maximum number of connections that Apache allows (MaxClients), the number of seconds after which a connection will disconnect (Timeout), the maximum number of requests Apache allows per connection (MaxRequestsPerChild), and whether to allow persistent connections (KeepAlive directive). Initially, the values in this tab do not need to be changed. Click OK when you are done making changes and restart httpd.

Ing. Jesus Bustos Medina - JeBusSoft

Page 9

TECNOLOGAS DE LA INFORMACIN Y COMUNICACIN - TSU 3-F,G : Desarrollo de Aplicaciones Web

Testing Apache
Once you start the httpd daemon, you can confirm that Apache is working correctly by pointing a browser on the local system to http://localhost/. From a remote system, point a browser to http:// followed by the ServerName you specified in httpd.conf. For example, you might use either of these URI formats: http://192.168.0.16 or http://example.org. The browser should display the Fedora/RHEL/Apache test page. If the server is behind a firewall, open TCP port 80 (page 844).

Ing. Jesus Bustos Medina - JeBusSoft

Page 10

You might also like