
<p> CIS 238 - UNIX System Administration</p><p>Lab Exercise #11: Apache Web Server, LAMP Server</p><p>Install a basic Web Server:</p><p>1) Install: lynx, httpd, httpd-tools, httpd-devel, system-config-httpd</p><p>2) In /etc/httpd/conf/httpd.conf - Change ServerName to: www.p156.occcns.info - change the “listen port to 8080</p><p>Copy “web.txt” from Lab2 to /var/www/html/index.html </p><p>3) service httpd restart</p><p>4) telnet 127.0.0.1 8080 GET http://127.0.01 HTTP/1.0\n\n </p><p>.. and hit ENTER twice </p><p>5) Connect to the website using NETCAT echo -e "GET http://127.0.0.1 HTTP/1.0\n\n" | nc -w 5 127.0.0.1 8080 </p><p>Demonstrate the website for the instructor using Firefox browser</p><p>6) Add www.p156.occcns.info to /etc/hosts as DHCP assigned IP address Repeat steps 4, 5 using www.p156.occcns.info replacing 127.0.0.1 </p><p>Password secure the web server:</p><p>7) Create passwd file for your website: htpasswd -c /etc/httpd/conf/.htpasswd user1 Repeat for users2 –user9 (withoput –c) chmod 644 /etc/httpd/conf/.htpasswd</p><p>8) Create .htaccess file in your DocumentRoot:</p><p>AuthUserFile /etc/httpd/conf/.htpasswd AuthGroupFile /dev/null AuthName “EnterPassword” AuthType Basic require valid-user</p><p>9) vi /etc/httpd/conf/http.conf: Change DocumentRoot as follows: <Directory /var/www/html/*> AllowOverride AuthConfig </Directory></p><p>10) service httpd restart.</p><p>11) Try accessing the web site and you'll be prompted for a password. Lab Exercise #11: Apache Web Server, LAMP Server</p><p>Install MySQL Database Server</p><p>12) yum install mysql mysql-server mysql-libs</p><p>13) Start the mysql daemon, service mysqld start</p><p>14) then type “mysql” mysql Change the MySQL Root Password, the default the root password for the for mysql database. mysql> USE mysql; mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root'; mysql> FLUSH PRIVILEGES; exit;</p><p>15) check by logging in mysql -u root -p Enter Password: exit;</p><p>16) Create a new MySQL User: To create a new mysql user ‘guest’ with ‘all privileges’ on database ‘demo’ mysql –u root –p –e ‘create database demo’ mysql –u root –p mysql >GRANT ALL PRIVILEGES ON demo.* TO 'guest'@'localhost' IDENTIFIED BY 'guest' \ WITH GRANT OPTION; mysql> USE mysql; mysql> UPDATE user SET Password=PASSWORD('guest') WHERE user='guest'; mysql> FLUSH PRIVILEGES; mysql> exit;</p><p>Python – native interface, see also mod_wsgi</p><p>17) Create Python CGI program /var/www/cgi-bin/test.cgi</p><p>#!/usr/bin/python import cgitb cgitb.enable() print (“Content-type: text/html\n\n”) print (“Hello World”)</p><p>18) Point your browser to: http://127.0.0.1:8080/cgi-bin/test.cgi Lab Exercise #11: Apache Web Server, LAMP Server</p><p>Install PHP </p><p>19) Install PHP Scripting Language yum install php php-mysql php-pear php-common php-gd php-mbstring php-mcrypt php-xml php- cli php-devel</p><p>20) Restart the apache to load php.</p><p> service httpd restart</p><p>21) Test PHP: Create a file named /var/www/html/test.php with the following phpinfo() function inside php quotes.</p><p>// test.php <?php phpinfo(); ?></p><p>22) Point your browser to http://127.0.0.1:8080/test.php</p><p>Install PERL </p><p>23) Install Perl yum install mod_perl</p><p>24) Verify Apache CGI scripts are placed in the /var/www/cgi-bin/ directory as defined by the ScriptAlias directive in the httpd.conf file: </p><p>ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"</p><p>25) Create Perl CGI Program: /var/www/cgi-bin/test/test.cgi</p><p>#!/usr/bin/perl # CGI Script "test.cgi" print qq( <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html"> <title>Linux Home Networking</title> </head> <body> Success! </body> </html> );</p><p>26) Point your browser to: http://127.0.0.1:8080/cgi-bin/test/test.cgi Lab Exercise #11: Apache Web Server, LAMP Server</p><p>Apache self-cert install:</p><p>Fedora 15 (RHEL 6)</p><p>27) Install SSL software: yum install openssl yum install mod_ssl</p><p>28) mkdir /etc/httpd/conf/ssl; cd /etc/httpd/conf/ssl</p><p>Generate RSA private key without a passphrase: openssl genrsa -out <hostname>.key 1024</p><p>(Don’t do this): openssl genrsa -des3 -out <hostname>.key 1024</p><p>Generates a RSA key with a passphrase - you will be prompted to enter a passphrase right after you hit enter and when Apache starts. You should generally NOT generate the RSA private key with a passphrase if you have scripts that restart apache automatically; Apache will just sit there and wait for the script to input the passphrase.</p><p>29) generate the CSR using the RSA Private Key openssl req -new -key <hostname>.key -out <hostname>.csr</p><p>Enter your Common Name, Organization, Organization Unit, City or Locality, State or Province and Country. At email address and challenge password, just hit enter.</p><p>Country Name (2 letter code) [XX]:US State or Province Name (full name) []:Illinois Locality Name (eg, city) [Default City]:Skokie Organization Name (eg, company) [Default Company Ltd]:Oakton Community College Organizational Unit Name (eg, section) []:CIS Common Name (eg, your name or your server's hostname) []:<hostname> Email Address []: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []:</p><p>30) Generate self-signed cert (or send ,csr to 3rd party vendor for 3rd party cert): openssl x509 -req -days 365 -in <hostname>.csr -signkey <hostname>.key -out <hostname>.crt</p><p>31) chmod all files to 600, owner and group = root</p><p>32) Add to Apache main server(s): vi /etc/httpd/conf.d/ssl.conf</p><p># Server Certificate: # SSLCertificateFile /etc/pki/tls/certs/localhost.crt SSLCertificateFile /etc/httpd/conf/ssl/<hostname>.crt</p><p># Server Private Key: # SSLCertificateKeyFile /etc/pki/tls/private/localhost.key SSLCertificateKeyFile /etc/httpd/conf/ssl/<hostname>.key</p><p> repeat for each virtual server</p><p>Fedora 19 (RHEL 7) see text:</p><p>33) yum install mod_ssl openssl</p><p>34) grep ‘^SSLCertificate’ /etc/httpd/conf.d/ssl.conf</p><p>35) cd /etc/pki/tls/certs</p><p>36) make localhost.key (enter passphrase)</p><p>37) make localhost.crt (enter passphrase)</p><p>38) mv localhost.key ../private</p><p>39) service httpd restart (enter passphrase)</p><p>40) netstat –an | grep 443</p><p>41) point browser to https://127.0.01 </p><p>42) cat /etc/pki/tls/certs/localhost.crt</p>
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages5 Page
-
File Size-