how to make php scripts executable instead of downloadable using nginx -
recently set virtual machine through vagrant , i'm using nginx web server. os i'm using vm ubuntu linux 12.04. problem script write in php gets downloaded, instead of being executed on browser. seeing php interpreter installed figured i'd post here config file of nginx, problem found. being novice in world of web development, can't figure out out of ordinary, can guys take , tell me if see wrong? thanks.
server { listen 80; server_name localhost; root /vagrant/www/web; error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; #strip app.php/ prefix if present rewrite ^/app\.php/?(.*)$ /$1 permanent; location / { index app.php; try_files $uri @rewriteapp; } location @rewriteapp { rewrite ^(.*)$ /app.php/$1 last; } # pass php scripts fastcgi server listening socket location ~ ^/(app|app_dev)\.php(/|$) { fastcgi_pass unix://var/run/php5-fpm.sock; fastcgi_keep_conn on; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; fastcgi_param script_filename $document_root$fastcgi_script_name; fastcgi_param https off; } # enable global phpmyadmin location /phpmyadmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpmyadmin/(.+\.php)$ { try_files $uri =404; root /usr/share/; 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_params; } location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/; } } location /phpmyadmin { rewrite ^/* /phpmyadmin last; } }
looks you're having double //
indicate fastcgi_pass
path of php in location block, try instead
location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_keep_conn on; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; fastcgi_param script_filename $document_root$fastcgi_script_name; fastcgi_param https off; }
Comments
Post a Comment