phpinfo() is not working on my CentOS server - centos

I have PHP installed on my CentOS server. However, when running a phpinfo() inside my script to test it, I receive the HTML, not the interpreted information.
I can see the folders for PHP. I can even see the php.ini in the etc folder.
But PHP itself does not seem to be working.
I mean my test.php file looks like this:
<?php
phpinfo();
?>
And the response looks like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html><head>
<style type="text/css">
body {background-color: #ffffff; color: #000000;}
body, td, th, h1, h2 {font-family: sans-serif;}
pre {margin: 0px; font-family: monospace;}
a:link {color: #000099; text-decoration: none; background-color: #ffffff;}
...
and so on.
What seems to be the problem and how do I solve it?
If I copy the HTML returned, paste it into an HTML file, and run it from there, I can see the formatted result, but not by running the test.php. I assume PHP is not loaded somehow... even if in the interpreted HTML I can see the:
**Server API Apache 2.0 Handler
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc/php.ini
Scan this dir for additional .ini files /etc/php.d
additional .ini files parsed /etc/php.d/dbase.ini, /etc/php.d/json.ini, /etc/php.d/mysql.ini, /etc/php.d/mysqli.ini, /etc/php.d/pdo.ini, /etc/php.d/pdo_mysql.ini, /etc/php.d/pdo_sqlite.ini
PHP API 20041225
PHP Extension 20050922
Zend Extension 220051025
Debug Build no
Thread Safety disabled
Zend Memory Manager enabled
IPv6 Support enabled
Registered PHP Streams php, file, http, ftp, compress.bzip2, compress.zlib, https, ftps**
and so on...
On this system, there are three websites hosted. Does that have anything to do with this problem?

This happened to me as well. The fix was wrapping it in HTML tags. Then I saved the file as /var/www/html/info.php and ran http://localhost/info.php in the browser. That's it.
<html>
<body>
<?php
phpinfo();
?>
</body>
</html>

Save the page which contains
<?php
phpinfo();
?>
with the .php extension. Something like info.php, not info.html...

You need to update your Apache configuration to make sure it's outputting php as the type text/HTML.
The below code should work, but some configurations are different.
AddHandler php5-script .php
AddType text/html .php

This did it for me (the second answer): Why are my PHP files showing as plain text?
Simply adding this, nothing else worked.
apt-get install libapache2-mod-php5

I just had the same issue and found that a client had disabled this function from their php.ini file:
; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
disable_functions = phpinfo;
More information: Enabling and disabling phpinfo() for security reasons

Be sure that the tag "php" is stick in the code like this:
?php phpinfo(); ?>
Not like this:
? php phpinfo(); ?>
OR the server will treat it as a (normal word),
so the server will not understand the language you are writing to deal with it so it will be blank.
I know it's a silly error ...but it happened ^_^

Try to create a php.ini file in root and write the following command in and save it.
disable_functions =
Using this code will enable the phpinfo() function for you if it is disabled by the global PHP configuration.

For people who have no experience in building websites (like me) I tried a lot, only to find out that I hadn't used the .php extension, but the .html extension.

It happened to me as well. On a newly provisioned Red Hat Linux 7 server.
When I run a PHP page, i.e. info.php, I could see plain text PHP scripts instead of executing them.
I just installed PHP:
[root#localhost ~]# yum install php
And then restarted Apache HTTP Server:
[root#localhost ~]# systemctl restart httpd

My solution was uninstalling and installing the PHP instance (7.0 in my case) again:
sudo apt-get purge php7.0
sudo apt-get install php7.0
After that you will need to restart the Apache service:
sudo service apache2 restart
Finally, verify again in your browser with your localhost or IP address.

I accidentally set the wrong file permissions. After chmod 644 phpinfo.php the info indeed showed up as expected.

It may not work for you if you use localhost/info.php.
You may be able to found the clue from the error. Find the port number in the error message. To me it was 80. I changed address as http://localhost:80/info.php, and then it worked to me.

I had the same problem.
The solution in my case was to set default_mimetype = "text/html" inside the php.ini file.

Another possible answer for Windows 10:
The command httpd -k restart does not work on my machine somehow.
Try to use the Windows 10 Service to restart the relative service.

Related

Autofs/Automount in SmartOS (Solaris)

Faced with a trouble using Autofs in SmartOS.
I added single line in /etc/auto_master:
/- auto_share
Here is /etc/auto_share's content:
/Public -rw 10.0.1.20:/nfs/Public
10.0.1.20 is WD MyCloud NAS, that why /nfs/ needed.
Anyway, simple mount 10.0.1.20:/nfs/Public /Public_test works well, but after svcadm enable autofs && automount I see new folder /Public but ls /Public says No such file or directory.
I'm little bit confused, because same case works like a charm in Linux and OS X, but not in SmartOS. Am I missing something?
I tried also inderect share /root auto_share & Public 10.0.1.20:/nfs/Public and adding -fstype=nfs, but no luck.
Well, I just should to get more info about Solaris administration tools.
svcs -l autofs
gave me information that some services necessary for autofs are offline:
dependency require_all/none svc:/system/filesystem/local (online)
dependency require_all/restart svc:/milestone/name-services (online)
dependency optional_all/none svc:/network/nfs/client (disabled)
dependency require_all/restart svc:/network/rpc/bind (disabled)
So, a couple of commands...
svcadm enable svc:/network/rpc/bind
svcadm enable svc:/network/nfs/client
...and everything works like a charm.
Sorry for noob question) Hope this information will be useful for someone.

Cannot issue PURGE request to Varnish cache

I am using Varnish 3 in front of nginx running multiple WordPress sites. I am using a default.vcl recommended and used by many large WordPress sites.
default.vcl: http://pastebin.com/KaSdvuRS
I am using W3 Total Cache which has an option to automatically purge when clearing the cache. I also tested installing Varnish HTTP Purge plugin to purge posts/pages when editing them. Neither seemed to work so I tested interactive session over ssh w/ curl.
I am logged into SSH on the varnish/nginx box, and I type the following command to test the varnish purge:
curl -X PURGE http://www.example.com
The result is:
<head>
<title>405 Not allowed.</title>
</head>
<body>
<h1>Error 405 Not allowed.</h1>
<p>Not allowed.</p>
<h3>Guru Meditation:</h3>
<p>XID: 265824636</p>
<hr>
<p>Varnish cache server</p>
</body>
Any ideas what I am missing? This vcl file is very similar to what is recommended by Varnish-Cache.org for WordPress and is the purge configuration I see recommended everywhere.
Chances are, you're connecting to your Varnish box via the public IP and Varnish will also see a public IP connecting, not a local one. Your ACL for purges now only allows localhost/127.0.0.1. You may want to extend that list with the public IP address of your server as well.
Alternatively, try debugging by removing the ACL check and by simply allowing purges from everyone, just to exclude the ACL as the guilty one.

SugarCRM error on module loader on shared hosting

I’ve a shared hosting account and installed SugarCRM. Everything is fine except the message i get for the module loader. Here i get the message to add suhosin.executor.include.whitelist = “upload://” to the php.ini file.
The message is:
Upload stream is blocked by Suhosin, please add "upload" to
suhosin.executor.include.whitelist (See sugarcrm.log for more
information)
Because i have a shared hosting account i don’t have access to my etc map and therefore also not to my php.ini file.
I want to use the .htaccess file for this but don't know exact code. Can anyone help me?
You Can Try Add this to your .htaccess file as suggested in http://forums.sugarcrm.com/f6/upload-stream-blocked-suhosin-82116/
<IfModule mod_php.c>
php_value suhosin.executor.include.whitelist upload://
</IfModule>
In my case I'm using php-fpm so I modified the php.ini locater in /etc/php5/fpm/conf.d/suhosin.ini and I have no more warnings from SugarCRM
; configuration for php suhosin module
extension=suhosin.so
suhosin.executor.include.whitelist="phar"
suhosin.executor.include.whitelist="upload"
The solution posted by Carlos Quijano didn't work for me.
I've found that the solution is different depending if PHP is run as module, CGI or FASTCGI .
This is the documentation I've found about the different methods you can use to use a custom php.ini file for your domain (or even subdomains)
First you should check which one is your case.
For this, you can use the phpinfo command:
Create a php file called phpinfo.php with this content: <?php phpinfo(); ?>
and upload it into your domain root, then visit www.yourdomain.com/phpinfo.php,
you'll see a table and next to "Server API" you'll see which way PHP is run.
For me it was "CGI/FastCGI", so I had to get a copy of the global php.ini, which I didn't know how to get since it was not accessible by FTP access. I've found a solution in a Drupal forum:
Create a php file you can call gettheini.php with this content:
<?php system("cp /usr/local/php5/lib/php.ini /home/YOURCPANELUSERNAME/php.ini"); ?>
*The first path must be the path next to "Configuration File (php.ini) Path" in the table obtained before (phpinfo.php), with php.ini at the end. The second path is the path where you want to copy it to.
Upload it into your domain root, then visit www.yourdomain.com/gettheini.php.
This command will copy the global php.ini file yo the path you specified.
Then you can edit that file adding
; configuration for php suhosin module
extension=suhosin.so
suhosin.executor.include.whitelist="phar"
suhosin.executor.include.whitelist="upload"
save it and upload it.
As my hosting service had made some arrangements php.ini overriding, when I checked again the phpinfo page, the new file was already working (check next to "Loaded Configuration File").
Don't forget to protect the new file, add
<Files php.ini>
order allow,deny
deny from all
</Files>
to the end of yout .htaccess file (in the same root folder of your domain or subdomain)
I hope my experience can help you to solve your problem or at least give you some guidance.

ASP.Net MVC 2 on nginx/mono 2.8

I am trying to setup ASP.Net MVC 2 application on Linux environment. I've installed Ubuntu 10.10 on VirtualBox, then installed Mono 2.8 from sources. After that I have installed nginx and configure it as recommended here.
Unfortunately, FastCGI shows me standard error 500 page:
No Application Found
Unable to find a matching application for request:
Host localhost:80
Port 80
Request Path /Default.aspx
Physical Path /var/www/mvc/Default.aspx
My application is located in /var/www/mvc directory. I've tried to create some stub Default.aspx file and place it in root dir of my application, but it didn't help, same error occured.
Thanks.
I've been doing some testing with this as well, using all ubuntu10.10 binaries.
From what I can make from it, either nginx fails to pass the hostname of the mono server fails to receive it over the fastcgi protocol. Anyhow, the tutorial line:
fastcgi-mono-server2 /applications=www.domain1.xyz:/:/var/www/www.domain1.xyz/ /socket=tcp:127.0.0.1:9000
doesn't work. Removing the hostname makes the thing work:
fastcgi-mono-server2 /applications=/:/var/www/www.domain1.xyz/ /socket=tcp:127.0.0.1:9000
but this of course blocks the use of multiple virtual mono hosts.
Since you are running ASP.NET MVC 2 application you should use fastcgi-mono-server4.
Adding following line in /etc/nginx/fastcgi_param resolves the issue for me. It also allows to use multiple virtual hosts.
fastcgi_param HTTP_HOST $host;
Does your application work with xsp (xsp4 if you are using .net 4.0)? You'll want to make sure that is working before you try configuring the connection to another web server.
Does nginx know where to find mono? You most likely have a parallel install and it won't be in the default paths.
I use apache, but you may still find some of the instructions on my blog useful:
http://tqcblog.com/2010/04/02/ubuntu-subversion-teamcity-mono-2-6-and-asp-net-mvc/
I had this problem just now, I too had been following the document on the mono site:
I was trying to start the fastcgi-mono-server as it suggested:
sudo fastcgi-mono-server4 /applications=www.domain1.xyz:/:/var/www/www.domain1.xyz/ /socket=tcp:127.0.0.1:9000 &
However when I did it like that I got the same problem as you. I changed it to this:
sudo fastcgi-mono-server4 /applications=/:/var/www/www.domain1.xyz/ /socket=tcp:127.0.0.1:9000 &
And it worked ( I had to type in www.domain1.xyz/Home/Index to see my MVC page, not worked out how to stop it looking for www.domain1.xyz/default.aspx yet XD ).
You need to make sure the domain set in your site config matches the domain passed to the fastcgi server. So for example if your default site (/etc/nginx/sites-enabled/default) has the following config:
server {
...
server_name www.domain1.xyz;
...
}
You would need to pass that domain into the fastcgi server:
sudo fastcgi-mono-server4 /applications=www.domain1.xyz:/:/var/www/www.domain1.xyz/ ...
Then when you access the site it will obviously need to be with that domain you set.

Why does my Apache2::Log output replace newlines with \n?

I've set up multiple vhosts under apache2 / mod_perl. I used the ErrorLog directive to get a separate error log for each vhost. This only worked as expected when I used Apache2::Log. 'warn' would only log to the regular error log.
So that's all working. Finally. But there's one issue remaining: When I log via $r->log_error, I find that newlines are replaced with \n
Any idea why this happens, and how it can be fixed?
Thanks.
This is not a mod_perl problem, but an Apache one. Apparently there are some security concerns with printing unescaped output to the error logs (I'm not entirely sure why) so you have to explicitly enable this in Apache when building/configuring it using this:
CFLAGS=-DAP_UNSAFE_ERROR_LOG_UNESCAPED ./configure
If you're using an already installed apache, there's not much you can do to change this.
If you have a pre-built install, you can use this line of code to fix the issue but it must be included in every page execution within your vhost, say in a header.php or config.php file.
ini_set('error_log','/var/log/apache2/error.log');
i know this is very old thread, but still coming on top on google results, so just to help all, the following changes in mod_perl.pl did helped me:
comment out below:
BEGIN { *CORE::GLOBAL::warn = \&Apache2::ServerRec::warn; }
the above is for:
Make warnings go to the virtual host's log and not the main server log.
i hope this helps anyone out there like me :)