Yii Framework Forum: $_Server Variable Failed (Requirements) - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

$_Server Variable Failed (Requirements) Rate Topic: -----

#1 User is offline   ItsYii 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 117
  • Joined: 24-January 12

Posted 10 March 2013 - 04:39 AM

I'm trying to install Yii on a windows plesk server running PHP 5.2.13 and I ran into this when I check requirments

Quote

$_SERVER variable Failed Yii Framework Either $_SERVER["REQUEST_URI"] or $_SERVER["QUERY_STRING"] must exist.


I checked around I found this issue

https://code.google....s/detail?id=814

Apparently I am supposed yo use that code, but where do I place it doesn't mention.

Anyway know how to fix this?

Thanks
0

#2 User is offline   Da:Sourcerer 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,222
  • Joined: 30-March 11
  • Location:Berlin, Germany

Posted 10 March 2013 - 04:47 AM

Well, qiang suggests to put that code into your entry script, so I'd think you should do just that :)

Out of interest: What kind of webserver are you using? Plesk implies it's most likely Apache, but it would still be interesting to know.
programmer /ˈprəʊgramə/, noun: a device that converts ►coffee into ►code
0

#3 User is offline   ItsYii 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 117
  • Joined: 24-January 12

Posted 10 March 2013 - 04:55 AM

View PostDa:Sourcerer, on 10 March 2013 - 04:47 AM, said:

Well, qiang suggests to put that code into your entry script, so I'd think you should do just that :)

Out of interest: What kind of webserver are you using? Plesk implies it's most likely Apache, but it would still be interesting to know.



I'm using Parallels Plesk, it supports ASP and PHP.

Sorry where is the entry script exactly, and how do I locate it?
0

#4 User is offline   Da:Sourcerer 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,222
  • Joined: 30-March 11
  • Location:Berlin, Germany

Posted 10 March 2013 - 05:01 AM

View PostItsYii, on 10 March 2013 - 04:55 AM, said:

I'm using Parallels Plesk, it supports ASP and PHP.

That's a hosting management solution, not a webserver. The underlying webserver were of interest. It is my understanding that this is most likely Apache httpd followed by nginx.

View PostItsYii, on 10 March 2013 - 04:55 AM, said:

Sorry where is the entry script exactly, and how do I locate it?

Your entry script is the index.php handling and routing all incoming requests. It should be in the docroot of your project.
programmer /ˈprəʊgramə/, noun: a device that converts ►coffee into ►code
0

#5 User is offline   ItsYii 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 117
  • Joined: 24-January 12

Posted 10 March 2013 - 05:19 AM

My bad Microsoft-IIS/7.0

So I copied and pasted the code inside index.php, where it calls the framework like so, but it's still showing failed

<?php


function api_request_uri() 
{ 
   if (!empty($_SERVER['REQUEST_URI'])) 
   { 
      return $_SERVER['REQUEST_URI']; 
   } 
   else 
   { 
      $uri = $_SERVER['SCRIPT_NAME']; 
      if (!empty($_SERVER['QUERY_STRING'])) 
      { 
         $uri .= '?'.$_SERVER['QUERY_STRING']; 
      } 
      $_SERVER['REQUEST_URI'] = $uri; 
      return $uri; 
   } 
}

// change the following paths if necessary
$yii=dirname(__FILE__).'/framework/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';

// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

require_once($yii);
Yii::createWebApplication($config)->run();




If it try to run the web app I get 500 - Internal server error.
Also I tried placing the code after the include calls

Thanks
0

#6 User is offline   Da:Sourcerer 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,222
  • Joined: 30-March 11
  • Location:Berlin, Germany

Posted 10 March 2013 - 05:37 AM

Well, you weren't supposed to copy that code in as-is. Anyway, can you try to follow the instructions on this wiki page and see if your situation improves? I think your greatest problem is IIS not passing the query string to PHP correctly.

Oh, and I'm afraid my support has got to end here as I'm not proficient with IIS :)
programmer /ˈprəʊgramə/, noun: a device that converts ►coffee into ►code
0

#7 User is offline   ItsYii 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 117
  • Joined: 24-January 12

Posted 10 March 2013 - 07:22 AM

I checked out that Wiki and it didn't help anything.

Quote

Well, you weren't supposed to copy that code in as-is
Would you be able to tell me how? I really think this will solve my problem.

Quote

Oh, and I'm afraid my support has got to end here as I'm not proficient with IIS


Thanks for all the help, much appreciated.
0

#8 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 10 March 2013 - 07:43 AM

It's not clear to me what you are trying to do.

If you want to check requirements, run the requirements script, otherwise: explain what it is you need to do.
"Less noise - more signal"
0

#9 User is offline   ItsYii 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 117
  • Joined: 24-January 12

Posted 10 March 2013 - 07:47 AM

View Postjacmoe, on 10 March 2013 - 07:43 AM, said:

It's not clear to me what you are trying to do.

If you want to check requirements, run the requirements script, otherwise: explain what it is you need to do.


Im installing Yii on a server- IIS/7, one of the requirements failed ($_SERVER variable).

Quote

$_SERVER variable Failed Yii Framework Either $_SERVER["REQUEST_URI"] or $_SERVER["QUERY_STRING"] must exist.


I'm trying to find out how to fix/pass that requirement
0

#10 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 10 March 2013 - 07:51 AM

The CHttpRequest component takes care of the differences between server software.

Are you telling me that the requirements script failed?

Can you run a regular php script on your server?

If $_SERVER['HTTP_X_REWRITE_URL'] set?

If it is, you're running IIS.
"Less noise - more signal"
0

#11 User is offline   ItsYii 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 117
  • Joined: 24-January 12

Posted 10 March 2013 - 07:54 AM

View Postjacmoe, on 10 March 2013 - 07:51 AM, said:

The CHttpRequest component takes care of the differences between server software.

Are you telling me that the requirements script failed?

Can you run a regular php script on your server?

If $_SERVER['HTTP_X_REWRITE_URL'] set?

If it is, you're running IIS.



No the requirements script runs fine, one of the requirements failed from the list. I can run regurlar PHP scripts fine. This is the one that failed $_SERVER variable
0

#12 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 10 March 2013 - 08:10 AM

Look at the output of phpinfo.
You also didn't answer all my questions. :)
"Less noise - more signal"
0

#13 User is offline   ItsYii 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 117
  • Joined: 24-January 12

Posted 10 March 2013 - 08:32 AM

View Postjacmoe, on 10 March 2013 - 08:10 AM, said:

Look at the output of phpinfo.
You also didn't answer all my questions. :)


What am I supposed to look for on phpinfo?


Quote

If $_SERVER['HTTP_X_REWRITE_URL'] set?


Not sure what you mean by the above


Quote

If it is, you're running IIS.


I am running IIS7, I can confirm.


Thanks
0

#14 User is offline   ItsYii 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 117
  • Joined: 24-January 12

Posted 10 March 2013 - 09:31 AM

I used http://www.yiiframew...IIS#entry149995 fr0d0z has a solution.

$_SERVER variable still failed but when I run index.php yii takes over instead of 500 server error.

I'm still getting Yii erros as I need to configure my Web App, (DB connection etc).

I will see what problems I get next.

Thanks everyone.
0

#15 User is offline   acorncom 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 99
  • Joined: 25-February 11
  • Location:CO, USA

Posted 19 March 2013 - 01:14 AM

From what I remember, to get this type of thing running onIIS, I had to tweak a web.config file in the web data folder. Don't remember much more right now, but I can look it up for you if you don't have this solved.
0

#16 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 19 March 2013 - 01:17 AM

If it's not too much trouble, please: do :)

Besides bringing closure, it's also going to be useful for others stumbling upon this topic in the future.
"Less noise - more signal"
0

#17 User is offline   acorncom 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 99
  • Joined: 25-February 11
  • Location:CO, USA

Posted 19 March 2013 - 11:13 AM

Hmm, my issues with IIS were actually different (trying to remove index.php from the URL and having permissions issues when changing the file).

But I just found this fix:
http://davidwalsh.na...ver-request_uri

@jacmoe, think we should add a github issue about this? Wouldn't be too hard to add that line to CHttpRequest and it could really help IIS folks with their problems ...
0

#18 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 19 March 2013 - 01:51 PM

It is already in there - CHttpRequest:



	public function getRequestUri()
	{
		if($this->_requestUri===null)
		{
			if(isset($_SERVER['HTTP_X_REWRITE_URL'])) // IIS
				$this->_requestUri=$_SERVER['HTTP_X_REWRITE_URL'];
			else if(isset($_SERVER['REQUEST_URI']))
			{
				$this->_requestUri=$_SERVER['REQUEST_URI'];
				if(!empty($_SERVER['HTTP_HOST']))
				{
					if(strpos($this->_requestUri,$_SERVER['HTTP_HOST'])!==false)
						$this->_requestUri=preg_replace('/^\w+:\/\/[^\/]+/','',$this->_requestUri);
				}
				else
					$this->_requestUri=preg_replace('/^(http|https):\/\/[^\/]+/i','',$this->_requestUri);
			}
			else if(isset($_SERVER['ORIG_PATH_INFO']))  // IIS 5.0 CGI
			{
				$this->_requestUri=$_SERVER['ORIG_PATH_INFO'];
				if(!empty($_SERVER['QUERY_STRING']))
					$this->_requestUri.='?'.$_SERVER['QUERY_STRING'];
			}
			else
				throw new CException(Yii::t('yii','CHttpRequest is unable to determine the request URI.'));
		}

		return $this->_requestUri;
	}


Or, perhaps I'm wrong?
"Less noise - more signal"
0

#19 User is offline   acorncom 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 99
  • Joined: 25-February 11
  • Location:CO, USA

Posted 19 March 2013 - 06:27 PM

It doesn't look like Yii handles the specific fix that shows up on that blog. Here's what he has:

if (!isset($_SERVER['REQUEST_URI']))
{
       $_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'],1 );
       if (isset($_SERVER['QUERY_STRING'])) { $_SERVER['REQUEST_URI'].='?'.$_SERVER['QUERY_STRING']; }
}


He's handling the case when REQUEST_URI doesn't exist, which Yii only does if HTTP_X_REWRITE_URL is set in IIS.

@ItsYii: can you do a:

print_r($_SERVER);


On your server and post the results (with any info snipped to protect you that you need to)?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users