Presentation is loading. Please wait.

Presentation is loading. Please wait.

LING 408/508: Computational Techniques for Linguists

Similar presentations


Presentation on theme: "LING 408/508: Computational Techniques for Linguists"— Presentation transcript:

1 LING 408/508: Computational Techniques for Linguists
Lecture 20

2 Today's Topic Did everyone get their webserver (OS X or Ubuntu or both) up and running? Apache2 Last time: we configured the root site and a user site Those are static webpages (but could contain Javascript which runs on the client): Today we will start running programs on the webserver itself.

3 Today's Topics Quick Homework 8: do before next time! Warning message:
"Could not reliably determine the server’s fully qualified domain name" Solution: define in /etc/apache2.conf (or httpd.conf): ServerName localhost Quick Homework 8: do before next time!

4 Apache Webserver on OSX
Storage locations: cgi-bin directory: /Library/WebServer/CGI-Executables/ usage: permissions for *.cgi should be readable and executable ls -l /Library/WebServer/CGI-Executables/ -rwxr-xr-x 1 root wheel Oct get.cgi -rwxr-xr-x 1 root wheel Oct post.cgi -rw-r--r-- 1 root wheel Oct 27 16:06 test.cgi to change permissions sudo chmod 755 test.cgi html pages: /Library/WebServer/Documents/

5 Apache Webserver on OSX
By default, Apple ships Apache2 with the cgi module turned off. Assuming the webserver is running, possible symptoms: prints program.cgi as plain text instead of executing it get.cgi doesn't exist!

6 Apache Webserver on OSX
Enabling cgi-bin: uncomment cgi_module line in file /etc/apache2/httpd.conf sudo nano /etc/apache2/httpd.conf restart apache2

7 Apache Webserver on OSX
Boilerplate browser expects: Content-Type: text/plain <blank line> Simple bash script, let's call it test: #!/bin/bash echo "Content-Type: text/plain" echo echo "Running Bash script from cgi-bin successfully!" echo -n "Now: " date echo -n "User: " whoami exit 0 755 rwx 100 = 4 010 = 2 001 = 1

8 Apache Webserver on OSX
Boilerplate browser expects: Content-Type: text/plain <blank line> Simple bash script, let's call it test: #!/bin/bash echo "Content-Type: text/plain" echo echo "Running Bash script from cgi-bin successfully!" echo -n "Now: " date echo -n "User: " whoami exit 0 CGI-Executables$ ./test.cgi Content-Type: text/plain Running Bash script from cgi-bin successfully! Now: Tue Oct 30 11:10:12 MST 2018 User: sandiway make sure our bash script runs on the server…

9 Apache Webserver on OSX
Compare: CGI-Executables$ ./test.cgi Content-Type: text/plain Running Bash script from cgi-bin successfully! Now: Tue Oct 30 11:10:12 MST 2018 User: sandiway User: Preamble: content-type and blank line

10 Apache Webserver on Ubuntu
cgi-bin/ CGI binaries directory: /usr/lib/cgi-bin/ files must be made executable! create same test script executable permissions needed

11 Apache Webserver on Ubuntu
Enabling cgi-bin: sudo a2enmod cgi (enables cgid instead of cgi) directory /etc/apache2/mods-enabled/

12 Apache Webserver on Ubuntu
Compare running test directly: http//localhost/cgi-bin/test: User: www-data On OS X: _www

13 Running cgi-bin for users

14 Apache Webserver on OSX
To run programs in ~sandiway/Sites, i.e. outside of /Library/WebServer/CGI-Executables modify the Apache httpd configuration file: sudo nano /etc/apache2/httpd.conf uncomment invokes the cgi-script handler for all files of type .cgi

15 Apache Webserver on OSX
Also modify /etc/apache2/users/sandiway.conf (created last lecture) to add the ExecCGI option as follows: <Directory "/Users/sandiway/Sites/"> AllowOverride All Options Indexes Multiviews FollowSymLinks ExecCGI Require all granted </Directory> #!/bin/bash echo "Content-Type: text/plain" echo echo "Running Bash script from ~sandiway/Sites successfully!" echo -n "Now: " date echo -n "User: " whoami echo -n "Directory: " ls -l exit 0 File ~/Sites/test.cgi

16 Apache Webserver on OSX
Dangerous! Why?

17 Apache Webserver on Ubuntu
By default cgi-bin is not enabled for ~/public_html just displays program instead of running it

18 Apache Webserver on Ubuntu
From add these lines to /etc/apache2/apache.conf <Directory "/home/*/public_html"> Options +ExecCGI AddHandler cgi-script .cgi </Directory> and restart apache2

19 Apache Webserver on Ubuntu
/etc/apache2/apache2.conf I put the declarations here (I'm not sure it's the best place though…)

20 Apache Webserver on Ubuntu
/etc/apache2/mods-available/userdir.conf

21 Apache Webserver on Ubuntu

22 Documentation

23 Quick Homework 8 Make up two different bash shell scripts, one for the root server and one for the user. [Refresh your knowledge of bash scripting from the first few lectures.] Show them running using localhost/cgi-bin/example.cgi and localhost/~user/example.cgi Send me screen snapshots. Be adventurous!


Download ppt "LING 408/508: Computational Techniques for Linguists"

Similar presentations


Ads by Google