Вы находитесь на странице: 1из 4

Lab Exercises

i.

Is Apache installed on your system? Find out.

ii.

Start if it is not already running.

iii.

Figure out the version of Apache installed/running on your system.

iv.

Find out DocumentRoot for the Apache server. Create apache.html in the DocumentRoot
directory and access it through web browser.

v.

Find out the default port of Apache web server running on the system. Change the default
port to 65535 and start the Apache server on the new port. Access your documents when
the apache server is running on new port.

vi.

Change DocumentRoot to ~/lab/username/. Move your old file apache.html to new


directory and access it.

vii.

Modify DirectoryIndex to display only home.html file.

viii.

Check the Syntax of httpd.conf.

ix.

Configure the Apache server to start automatically at boot time.

Apache.html

<html>
<body>Hello World</body>
</html>

Lab Exercises
1.
2.
3.
4.

Is Apache installed on your system? Find out.


Start if it is not already running.
Figure out the version of Apache installed/running on your system.
Find out DocumentRoot for the Apache server. Create apache.html in the
DocumentRoot directory and access it through web browser.

5.

6.
7.
8.
9.

Find out the default port of Apache web server running on the system. Change the
default port to 65535 and start the Apache server on the new port. Access your
documents when the apache server is running on new port.
Change DocumentRoot to ~/lab/username/. Move your old file apache.html to new
directory and access it.
Modify DirectoryIndex to display only home.html file.
Check the Syntax of httpd.conf.
Configure the Apache server to start automatically at boot time.

Lab Solutions
#/etc/init.d/httpd status
httpd (pid 4458 4457 4456 4455 4454 4453 4452 4451 4450 4448) is running...
OR
# service httpd status
httpd (pid 4458 4457 4456 4455 4454 4453 4452 4451 4450 4448) is running...
2. #/etc/init.d/httpd start
OR
# service httpd start
3. # /usr/sbin/httpd -v
Server version: Apache/2.2.9 (Unix)
Server built: Jul 14 2008 15:36:56
4. Document Root is located at /var/www/html/
Create a HTML file apache.html
$cat apache.html
<html>
<body>Hello World</body>
</html>
$
open the web browser give the URL as:
http://localhost/apache.html
5. #grep Listen /etc/httpd/conf/httpd.conf | grep -v -e '#'
Listen 80
open /etc/httpd/conf/httpd.conf on vi editor, make changes:
Listen 80 >>> Listen 65535 , save and quit. Restart the Apache Web Server:
#/etc/init.d/httpd restart
Go to System>>Administration>>SELinux Management>>enter SuperUser password>>
In SELinux Administration in Status, set System Default enforcing mode as
DISABLED, set current enforcing mode as Permissive .
Open the web browser, type the URL
http://localhost:65535/apache.html
5. open /etc/httpd/conf/httpd.conf on vi editor, make changes DocumentRoot
/lab/username/ and Directory TAG /lab/username/
1.

Now restart the Apache Web Server. Open web browser and
type http://localhost/apache.html
5. open /etc/httpd/conf/httpd.conf on vi editor, make changes to directory index
DirectoryIndex apache.html
restart Apache web server
5. #/usr/sbin/httpd -t
httpd: Could not reliably determine the server's fully qualified domain name, using
127.0.0.1 for ServerName
Syntax OK
#
open /etc/httpd/conf/httpd.conf on vi editor, make
<Directory "/var/www/html">
now, change to
Directory "/var/www/html">
save and quit.
now restart Apache web server
#service httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: Syntax error on line 335 of /etc/httpd/conf/httpd.conf:
</Directory>without matching <Directory> section [FAILED]
now again change the httpd.conf open /etc/httpd/conf/httpd.conf on vi editor
Directory "/var/www/html">
to
<Directory "/var/www/html">
save and quit vi editor. Now restart Apache web server.
Stopping httpd: [FAILED]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name,
using 127.0.0.1 for ServerName [ OK ]

[root@sun conf]# chkconfig | grep httpd


httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
lighttpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
tclhttpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
thttpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@sun conf]# who -r
run-level 5 2009-09-26 11:24
[root@sun conf]# chkconfig --level 3 httpd on
[root@sun conf]# chkconfig | grep httpd
httpd 0:off 1:off 2:off 3:on 4:off 5:off 6:off
lighttpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
tclhttpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
thttpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@sun conf]# ls /etc/rc.d/rc3.d/*httpd*
9.

/etc/rc.d/rc3.d/K15lighttpd /etc/rc.d/rc3.d/K15thttpd /etc/rc.d/rc3.d/K30tclhttpd


/etc/rc.d/rc3.d/S85httpd
now restart the system and check the status of apache on terminal
#/etc/init.d/httpd status
httpd (pid 4458 4457 4456 4455 4454 4453 4452 4451 4450 4448) is running...

Вам также может понравиться