embeded php code not activating

Richard Stanway r1ch+nginx at teamliquid.net
Sun Aug 14 16:42:06 UTC 2016


Visiting http://www.craythorneweather.info/moonphase.php show a HTTP/500,
so you should examine your backend (PHP) error logs for more information.

On Sun, Aug 14, 2016 at 5:48 PM, Joe Curtis <nginx-forum at forum.nginx.org>
wrote:

> I have a weather station website running successfully under apache2 on a
> fedora based server. I am in the process of transferring it to run on a
> raspberry pi 3 under nginx. This has transferred without a problem with the
> exception of a small section of PHP code which loads a graphic of the moon
> phase selected by date.
>
> The html code calling the graphic is:-
>
> /var/www/html/weather/index.htm excerpt
>
>  <td rowspan="3"><img src="moonphase.php" alt="Moon" width="64"
> align="left"
> border="0" height="64" hspace="10" /></td>
>
> moonphase.php calculates which image is required depending on parameters
> passed in moonphasetag.php.
>
> /var/www/html/weather/moonphase.php
>
> <?php
>
> error_reporting(E_ALL);
>
> require "moonphasetag.php";
> function int($s){return(int)preg_replace('/[^\-\d]*(\-?\d*).*/','$1',$s);}
> $mp = int($MoonPercent);
> $lat = substr($latitude, 0, 1);
> $file1 = 'moon/back.jpg';
> $file2 = 'moon/moon.jpg';
> $img = @imagecreatetruecolor(64, 64);
> $imgFinal = @imagecreatetruecolor(64, 64);
> if ($lat == "N") {
>         if ($mp  == 0) {
>             $file1 = 'moon/new.jpg';
>             copy ($file1, $file2);
>         } elseif ($mp  >= 1 AND $mp < 49) {
>             $file1 = 'moon/waxing_crescent.jpg';
>             copy ($file1, $file2);
>         } elseif ($mp  == 49 OR $mp  == 50) {
>             $file1 = 'moon/first_quarter.jpg';
>             copy ($file1, $file2);
>         } elseif ($mp  > 50 AND $mp < 99) {
>             $file1 = 'moon/waxing_gibbous.jpg';
>             copy ($file1, $file2);
>         } elseif ($mp  == 99 OR $mp  == 100) {
>             $file1 = 'moon/full.jpg';
>             copy ($file1, $file2);
>         } elseif ($mp  >= -99 AND $mp <= -51) {
>             $file1 = 'moon/waning_gibbous.jpg';
>             copy ($file1, $file2);
>         } elseif($mp  == -50 OR $mp  == -49) {
>             $file1 = 'moon/last_quarter.jpg';
>             copy ($file1, $file2);
>         } elseif ($mp  >= -49 AND $mp <= -1) {
>             $file1 = 'moon/waning_crescent.jpg';
>             copy ($file1, $file2);
>         }
> } else {
>         if ($mp  == 0) {
>             $file1 = 'moon/new.jpg';
>             copy ($file1, $file2);
>         } elseif ($mp  >= 1 AND $mp < 49) {
>             $file1 = 'moon/swaxing_crescent.jpg';
>             copy ($file1, $file2);
>         } elseif ($mp  == 49 OR $mp  == 50) {
>             $file1 = 'moon/sfirst_quarter.jpg';
>             copy ($file1, $file2);
>         } elseif ($mp  > 50 AND $mp < 99) {
>             $file1 = 'moon/swaxing_gibbous.jpg';
>             copy ($file1, $file2);
>         } elseif ($mp  == 99 OR $mp  == 100) {
>             $file1 = 'moon/full.jpg';
>             copy ($file1, $file2);
>         } elseif ($mp  >= -99 AND $mp <= -51) {
>             $file1 = 'moon/swaning_gibbous.jpg';
>             copy ($file1, $file2);
>         } elseif ($mp  == -50 OR $mp  == -49) {
>             $file1 = 'moon/slast_quarter.jpg';
>             copy ($file1, $file2);
>         } elseif ($mp  >= -49 AND $mp <= -1) {
>             $file1 = 'moon/swaning_crescent.jpg';
>             copy ($file1, $file2);
>     }
> }
> $img = imagecreatefromjpeg($file2);
> imagecopyresampled($imgFinal, $img, 0, 0, 0, 0, 64, 64, 64, 64);
> header('Content-Type: image/jpeg');
> imagejpeg($imgFinal, null, 100);
> imagedestroy($imgFinal);
> imagedestroy($img);
> ?>
>
> As far as I can tell I have set all the nginx parameters correctly:-
>
> /etc/nginx/sites-enabled/weather
>
> server {
>         listen 80;
>         listen [::]:80;
>
>         server_name www.craythorneweather.info;
>
>         root /var/www/html/weather;
>         index index.html index.htm index.php;
>
>         access_log /var/log/nginx/weather.access_log;
>         error_log /var/log/nginx/weather.error_log info;
>
>         location / {
>                 try_files $uri $uri/ =404;
>         }
>         location ~* \.php$ {
>                 fastcgi_split_path_info ^(.+\.php)(/.+)$;
>                 fastcgi_pass unix:/var/run/php5-fpm.sock;
>                 fastcgi_index index.php;
>                 fastcgi_param SCRIPT_FILENAME
> $document_root$fastcgi_script_name;
>                 include /etc/nginx/fastcgi.conf;
>                 include /etc/nginx/fastcgi_params;
>                 }
> }
>
> The code works perfectly under apache but I am keen to have it operating
> under nginx on the RPI.
>
> Any pointers as to where I am going wrong would be appreciated.
>
> Posted at Nginx Forum: https://forum.nginx.org/read.
> php?2,268949,268949#msg-268949
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20160814/b2eb5d92/attachment.html>


More information about the nginx mailing list