|
4 | 4 | =status show
|
5 | 5 | =author szabgab
|
6 | 6 | =archive 1
|
7 |
| -=comments_disqus_enable 1 |
| 7 | +=comments_disqus_enable 0 |
8 | 8 |
|
9 | 9 | =abstract start
|
10 | 10 |
|
@@ -134,4 +134,229 @@ followed by 2(!) newlines.
|
134 | 134 | Check out all the articles related to <a href="https://perlmaven.com/cgi">CGI and Perl</a> and
|
135 | 135 | <a href="/hello-world-using-cgi-in-ruby">CGI and Ruby</a>.
|
136 | 136 |
|
| 137 | +<h2>Comments</h2> |
| 138 | + |
| 139 | +A comment that was deleted before I decided to move them over. |
| 140 | +--- |
| 141 | + |
| 142 | +Well Said. I have been fighting this for 20 years. I set up an Apache Server, it runs for years, and when I go to do it again, everything is all moved around and it takes hours and hours to simply get a hello world program to run under apache. It is never clear on how to do it, they leave no instructions, For petes sake why doesn't the release at least have the file http.conf still there with the whole instruction set on how to get the functionality of http.conf working under the new paradigm??? It boggles the mind. |
| 143 | + |
| 144 | +--- |
| 145 | + |
| 146 | +Thumbs up. Moving files around for no real gain makes the software difficult to use. I too spent hours trying to get things straight. |
| 147 | + |
| 148 | +For other users, here's some advice that worked for me: |
| 149 | + |
| 150 | +1: Enable the CGI subsystem with a2enmod cgid |
| 151 | + |
| 152 | +2: Uncomment the CGI handler in mods-enabled/mime.conf, or include this directive in your specific vHost section |
| 153 | + |
| 154 | +AddHandler cgi-script .cgi |
| 155 | + |
| 156 | +3: Include Options ExecCGI in the vHost or topmost directory where you want these programs to be available |
| 157 | + |
| 158 | +--- |
| 159 | + |
| 160 | +In fact, very most times I had any issue I lost patience with myself, I was able to get someone to take the the time and lead me step by step. The truth, however, is that you are suposed to spend some time reading and learning stuff yourself as people generally expect some basic level of knowledge. |
| 161 | + |
| 162 | +And you know, I suspect you had neen doing some small stupid mistake, just as I sometimes do. But if you need an advice, you need to ask politely rather than throw feces. |
| 163 | + |
| 164 | +<hr> |
| 165 | + |
| 166 | +Oh thank you thank you thank you. 3 HOURS of searching before I found this article that finally talks about the CGI module and the soft link to fix this in mods-enabled. Why is this so well hidden on the internet is a mystery. |
| 167 | + |
| 168 | +<hr> |
| 169 | + |
| 170 | +After getting it to work with hello world, I tried to run one of my past cgi-perl scripts from an HTML page in my recent home apache2 server. The cgi-perl script runs fine as a webserver elsewhere - developed during my doctoral days. It's a long code: a certain bioinformatic application. |
| 171 | + |
| 172 | +The HTML page calls the cgi-perl script using method 'GET' as follows: |
| 173 | + |
| 174 | +<code> |
| 175 | +<form action="http://127.0.0.1/cgi-bin/newsdnamelt.cgi" method="GET"> |
| 176 | +<center><input value="Run" type="submit"></center> |
| 177 | +</form> |
| 178 | +</code> |
| 179 | + |
| 180 | +I am getting this error both with the HTML as well as with curl on command prompt: |
| 181 | + |
| 182 | +Internal Server Error |
| 183 | + |
| 184 | +The server encountered an internal error or misconfiguration and was unable to complete your request. |
| 185 | + |
| 186 | +Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error. |
| 187 | + |
| 188 | +More information about this error may be available in the server error log. |
| 189 | +Apache/2.4.29 (Ubuntu) Server at 127.0.0.1 Port 80 |
| 190 | + |
| 191 | +Any hint would be deeply appriciated. |
| 192 | + |
| 193 | +----------------------------------------------------------------------------------------------------- |
| 194 | + |
| 195 | +- Thanks in anticipation and Warm Regards, |
| 196 | + |
| 197 | +--- |
| 198 | + |
| 199 | +PS: Interestingly .sh scripts placed at /usr/lib/cgi-bin/ works just fine from HTML submit button - like the hw.sh. |
| 200 | +But none of the cgi-perl scripts do. |
| 201 | + |
| 202 | +These scripts start in the following way and all of them have worked just fine from similar HTML submission pages in the past. |
| 203 | +So, I wonder what's wrong! Any advice would be of great help! |
| 204 | + |
| 205 | +------------------------------------------------------------------------------------------- |
| 206 | + |
| 207 | +#!/usr/bin/perl |
| 208 | + |
| 209 | +use CGI qw(:standard); |
| 210 | +print "Content-type:text/html\n\n"; |
| 211 | + |
| 212 | +#============Input Environment variables====== |
| 213 | +$inptype;$filename;$inpseq;$x;$y;$Temp;$Na;$K;$NH4;$Mg;$tag;$tparam,$ustartbp; |
| 214 | +#============================================= |
| 215 | + |
| 216 | +$qstr = $ENV{QUERY_STRING}; |
| 217 | + |
| 218 | +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~env input from html~~~~~~~~~~~~~~~~~~~~ |
| 219 | +$qstr="choice=dirseq&filename=&dnaseq=GCGCGCGCGCGCGatgtcgtacgcatgcgatcagtcagcgacaCGCGC&tag=&tparam=&startbp=&window=20&overlap=0&Temp=37&Na=0.165&K=0&NH4=&Mg=0.01"; |
| 220 | +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 221 | + |
| 222 | +print $qstr,"\n"; |
| 223 | + |
| 224 | +@qdata = split(/&/,$qstr); |
| 225 | +#open (OUT,">ch.out"); |
| 226 | + |
| 227 | +--- |
| 228 | + |
| 229 | + |
| 230 | +Are the scripts executable, can you get the errors from the log file of the server? |
| 231 | + |
| 232 | +<hr> |
| 233 | + |
| 234 | +Excellent discourse. Great sincerity in helping the community. Long live Linux and opensource coding!! |
| 235 | + |
| 236 | +<hr> |
| 237 | + |
| 238 | +thanks |
| 239 | + |
| 240 | +<hr> |
| 241 | + |
| 242 | +Hey! It works. :) |
| 243 | + |
| 244 | +I'm now a "veteran" PHP dev. Because of that, I've not attempted traditional CGI scripting before but now I'm trying to add REBOL to my web dev toolbox and this is now necessary for me to do that. Funny thing... Your bash script example works but my REBOL script is returning a 500 Error for having a "malformed header" even though there are no typos and 2 newlines preceding the content. Off to find out why! Thanks for getting me going this far! |
| 245 | + |
| 246 | +--- |
| 247 | + |
| 248 | +I think this usually happens if the code does not print the Content-Type properly. |
| 249 | + |
| 250 | +<hr> |
| 251 | + |
| 252 | +Thanks a lot sir!! |
| 253 | + |
| 254 | +<hr> |
| 255 | + |
| 256 | +Hi, |
| 257 | + |
| 258 | +Instead of manually creating the symlink with |
| 259 | + |
| 260 | +$ cd /etc/apache2/mods-enabled |
| 261 | +$ sudo ln -s ../mods-available/cgi.load |
| 262 | + |
| 263 | +you should use the provided tool a2enmod. Ubuntu also provide a2disconf a2dismod a2dissite a2enconf and a2ensite for enabling and disabling modules, sites and configuration blocks |
| 264 | + |
| 265 | +Thanks for all your work. |
| 266 | + |
| 267 | +--- |
| 268 | + |
| 269 | +your post hi-lights exactly what is wrong with the linux community. You seem to think that " Ubuntu also provide a2disconf a2dismod a2dissite a2enconf and a2ensite for [this that and the other thing, that you don't provide any instructions for.]" is somehow better than just cutting and pasting the two lines: |
| 270 | + |
| 271 | +$ cd /etc/apache2/mods-enabled |
| 272 | +$ sudo ln -s ../mods-available/cgi.load |
| 273 | + |
| 274 | +this is exactly the problem with the linux community: If it ain't broke don't fix it. |
| 275 | + |
| 276 | +ALL instructions should be cut and paste lines form the command line. The FIRST set of instructions on setting up Apache is getting the welome screen to come up (that actually works pretty well,) and the second thing should be how to set up cgi-bin. For who knows what reason apache instructions instead go into multiple virtual hosting environments with do-decagon multi-plexing, cross-over premium drivers... whatever thing that is so complex I wouldn't have a chance to follow. Meanwhile I'm stuck getting hello_world.c which I can easily compile with gcc: ($ gcc -o hello_world.exe hellow_world.c) to run through the browser. Its absolutely ridiculous. This should be a no-brainer and up and running in less than 30 seconds. |
| 277 | + |
| 278 | +<hr> |
| 279 | + |
| 280 | +thanks for the post. it helped me alot. |
| 281 | + |
| 282 | +<hr> |
| 283 | + |
| 284 | +Ah, is it this easy? Why have I been thinking it is somewhat bloody difficult? :o) |
| 285 | + |
| 286 | +For the record, I had the cgid.load already present in my 2018-09-26 Raspbian Buster AND if you are getting that 500 server error, make sure the bash script is not indented (as was mine upon pasting it to nano). |
| 287 | + |
| 288 | +Indeed, not it works from me from my other machines too, which sugests I will be able to drive my RasPi car from a web interface. |
| 289 | + |
| 290 | +<hr> |
| 291 | + |
| 292 | +Hello sir i am trying to configure apache files to run a cgi script |
| 293 | +on Apache2 server from last 5 days. please help. hope for your better reply.. |
| 294 | + |
| 295 | +when i ran my python(test.cgi) file on localhost server (localhost/test.cgi) it prints the code |
| 296 | + |
| 297 | +<hr> |
| 298 | + |
| 299 | +Many thanks!!! |
| 300 | + |
| 301 | +<hr> |
| 302 | + |
| 303 | +Thank you so much!! |
| 304 | + |
| 305 | +<hr> |
| 306 | + |
| 307 | +Thanks Gabor, |
| 308 | +It really help us . Earlier we were using centos and recently we migrated to Ubuntu and our health check was failing for one service which is exposed using cgi. |
| 309 | + |
| 310 | +<hr> |
| 311 | + |
| 312 | +curl http://127.0.0.1/cgi-bin/hw.sh seems to be throwing an error for me :( |
| 313 | +Where does your localhost point to ? |
| 314 | + |
| 315 | +--- |
| 316 | +What is the error? |
| 317 | + |
| 318 | +aswin@aswin-desktop:~$ curl http://127.0.0.1/cgi-bin/hw.sh |
| 319 | + |
| 320 | +<code> |
| 321 | +<html><head> |
| 322 | +<title>500 Internal Server Error</title> |
| 323 | +</head><body> |
| 324 | +<h1>Internal Server Error</h1> |
| 325 | + |
| 326 | +The server encountered an internal error or |
| 327 | +misconfiguration and was unable to complete |
| 328 | +your request. |
| 329 | + |
| 330 | + |
| 331 | +Please contact the server administrator at |
| 332 | +webmaster@localhost to inform them of the time this error occurred, |
| 333 | +and the actions you performed just before this error. |
| 334 | + |
| 335 | + |
| 336 | +More information about this error may be available |
| 337 | +in the server error log. |
| 338 | + |
| 339 | + |
| 340 | +<hr> |
| 341 | +<address>Apache/2.4.18 (Ubuntu) Server at 127.0.0.1 Port 80</address> |
| 342 | +</body></html> |
| 343 | + |
| 344 | +</code> |
| 345 | + |
| 346 | +and what do you see in the error log of the server? |
| 347 | + |
| 348 | +--- |
| 349 | + |
| 350 | +I actually reinstalled lubuntu and tried it again and it works now, this was mostly due to some modifications i did to some of my files. |
| 351 | +This article was really helpful :) |
| 352 | +Thanks! |
| 353 | + |
| 354 | +<h2> |
| 355 | + |
| 356 | +Thanks a lot for this article! :) |
| 357 | + |
| 358 | +<h2> |
| 359 | + |
| 360 | +The missing symlink saved the day! I had the correct apache conf file for site but the cgi was not enabled. |
| 361 | + |
137 | 362 |
|
0 commit comments