Installing & Configure Apache
Installing & Configure Apache
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/
Page 1
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
Page 2
Page 3
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 .
Page 4
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
Page 5
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
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.
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.
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.
Page 9
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).
Page 10