Different result for same page on different ports : cakephp - php

I am new to cakephp, and following the 'Bookmarkers Tutorial'. I get to know that I can access the project using two kind of urls(I am using apache and the folder is located at /var/www/html/bookmarker):
localhost:8765
and
localhost/bookmarker
Now, when I use the first url, I get the following warning message on top:
warning(2) : file_put_contents(/var/www/html/bookmarker/logs/error.log): failed to
open stream: Permission denied [CORE/src/Log/Engine/FileLog.php, line
133]
But is not the case with the second url !
Why is there such a difference b/w these two urls? Which one should be used? And how to resolve that message appearance? Any help is greatly appreciated!

It's two servers here.
"localhost:8765" is the server built-in by CakePHP when you run the command: "bin/cake server" but you already have Apache web server at "localhost", so you don't need it.
And 2 servers being ran by 2 users:
localhost:8765 is you
localhost is apache
That's why you don't have permission to write log file (owned by apache)
Just stop the server built-in (bin/cake server), and use Apache server (2nd URL)
In case you want to use the server built-in, stop Apache server and remove everything inside "/var/www/html/bookmarker/logs/", the error message will gone.

Related

PHP file_get_contents() is not working on PLESK / CENTOS7 Server

I was using cpanel before, but I'm using Plesk Panel / Centos7 now. I moved my sites to Plesk Panel from CPanel. I'm runing file_get_contents() function, but it's not working on Plesk Panel.
Why? I dont know why. What should i do?
my code;
$data = file_get_contents('http://example.com');
this code is not working on Plesk Panel.
Thanks, best regards.
What is error message says?
if error message says, the stream (URL) requested cannot be opened. There are many possible reasons for this:
1. base URL is bad. $pc['pcname']
2. username and/or password are bad
3. username/password do not have permission on the server
4. Your system cannot reach the server (firewall, PHP permissions, ...)
I would use the following strategy to debug:
1. Dump $url and write it down.
2. Use a browser with debug tools (eg Firefox/Firebug) and try to access that URL.
3. Look at the headers returned to see what error the server reports (if any).
4. Think about why that error is returned

PHP Warning: oci_connect(): ORA-28040: No matching authentication protocol

I was given a task of fixing an app after the update.
Presumably, the person who updated it said they updated it to 'Oracle 12c' - whatever that means, thought the path is: 'C:/oracle/product/11.2.0/' which sounds like it's still 11.2.0 or whatever.. not important.
Whenever I'm trying to run oci_connect(); with verified and tested credentials, the error pops:
Warning: oci_connect(): ORA-28040: No matching authentication protocol
I've searched around the internet, found 2 solutions:
download and add 'ojdbc8.jar' to 'C:\oracle\product\11.2.0\client_1\jdbc\lib' (hope the path is correct).
add the lines below to 'sqlnet' which I found in:
'C:\oracle\product...\network\admin\' and
'C:\oracle\ora92\newtork\ADMIN'
**I've changed in both to be
sure**.
The lines:
SQLNET.ALLOWED_LOGON_VERSION=8
SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8
SQLNET.ALLOWED_LOGON_VERSION_SERVER=8
Same result, neither worked.
Edit:
I've also noticed, there's no oradmin.exe nor oracle.exe in the bin folder, is this normal?
It sounds like the server is updated and now the client fails to connect. In this case the server needs to configured to allow older client to connect. Add the SQLNET parameters to the server sqlnet.ora file and restart the server.

phpsdk_deps returns fatal error on windows

To compile PHP 7.1.X on Windows I use steps written here:
https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2
When I try to update dependencies with following command:
phpsdk_deps -u
I get following error:
D:\php-sdk2\php-sdk-binary-tools\phpdev\vc14\x64_71_2\php-7.1.15-src
$ phpsdk_deps -u
Fatal error: Uncaught SDK\Exception: Failed to fetch supported
branches
This is happening for almost two weeks now.
You're having network trouble.
If you open up the Config.php file at this line, you'll see that the Config tries to load the URI https://windows.php.net/downloads/php-sdk/deps/series/, and pick the correct txt file from there, in order to download the right dependencies. The exception you get means that this cannot be properly fetched.
The solution in my case was to use the company proxy (command line wasn't using it, so it cannot properly resolve & reach the above URL, and so the Config.php gets an empty response). How to do so might change depending on the network settings you use. In my case, I simply visited the URL above in Firefox (which is properly configured by the company), opened up the network pannel, get the IP of the website from there (which is actually the IP of the proxy Firefox was told to use by the company settings), and add the IP hostname entry in my host file (C:\Windows\System32\Drivers\etc\host) so it looks like 10.1.2.3 windows.php.net
Then I rerun the Config script, and boom, it managed to retrieve the txt files and the dependencies.
Another solution can be to retrieve all the dependencies listed in the txt file that corresponds to your setup, but it's a bit tedious...

Deploying a Symfony2 project

We were working on a Symfony2 project. Now, it's done and ready to be deployed. We uploaded the whole project files to the server (via ftp of course) and the database as well. Now when we open any page of it we got just a blank page (empty source code). Cache is clean, logs do not show anything new. We googled the steps of deploying a Symfony2 project to a hosting but we did not find a good explanation (even these ones were about Symfony not-version-2).
We believe it maybe a configuration issue, but no idea so far.
Any help will be greatly appreciated.
Thanks in advance.
Edit: the blank page is in Firefox. Google Chrome is saying something:
Server error The website encountered an error while retrieving
http://*.com/mammoky/web/app_dev.php/main. It may be down for
maintenance or configured incorrectly. Here are some suggestions:
Reload this webpage later. HTTP Error 500 (Internal Server Error): An
unexpected condition was encountered while the server was attempting
to fulfill the request.
error_log is showing:
[24-Mar-2012 23:29:24] PHP Parse error: syntax error, unexpected
T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in
/home/leadow33/public_html/mammoky/web/app.php on line 7
It's: use Symfony\Component\HttpFoundation\Request;
And
[24-Mar-2012 23:15:08] PHP Warning: Unexpected character in input:
'\' (ASCII=92) state=1 in
/home/leadow33/public_html/mammoky/web/config.php on line 84
It's: $reflector = new \ReflectionExtension('intl');
EDIT: I've posted my solution, check it out down here.
Answer:
I got it to work, this is my experience:
Upload the whole project folder to the server.
Enter www.your-website.com/project-name/web/config.php.
It should say: "This script is only accessible from localhost".
Open this web site: http://www.whatismyip.com, it should show you your public IP address, copy it.
Open the config.php from the admin panel (like cPanel) and edit that config.php:
if (!in_array(#$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1', /*your IP here*/))) {
header('HTTP/1.0 403 Forbidden');
die('This script is only accessible from localhost.');
}
Refresh your config.php file, the page will tell you if your system is missing some required conditions like: PHP version, APC extension, giving /cache and /log folders permissions to write on, etc.
After you provide the required conditions you'll see a form of configuring you project to connect to a database if you have one, this step is pretty simple.
Open the link www.your-website.com/project-name/web/app_dev.php, it'll help you get started with Symfony2 project.
In case you got in app_dev.php this message: You are not allowed to access this file... just do the same thing to app_dev.php as you did in steps 4 and 5 (add your public IP address to the array).
Note of Hakan Deryal (comment): If you don't have a fix IP address, you need to do this last step each time you get a new IP adrdress from the DHCP. So to solve that, open the app_dev.php and comment out the line die('You are not allowed to.., however this is not a recommended way because you're disabling the built-in security of the file.
One thing stopped me and may stop you too, the server I deployed the project on, was case-sensitive (unlike the localhost on my computer), so it kept telling me that the template (Index.html.php for example) does not exist, however it does exist, but I did return $this->render('...:index.html.php') with small i in DefaultController.php. So render the exact template (file) name with the same letters cases.
Now everything is going well, I hope that helps you.
In my case it was the php version* and I catched the error by running config.php with removed lines for checking ip address. On my hosting I just changed the default version of PHP for my scripts.
*Since namespaces are only from 5.3.
production isnt app_dev but app.. The page might be the same did you do a view source? Did you try to run the config.php that comes with the framework zip ?
If your installation runs on a shared webserver, try setting the following line into the app.php:
date_default_timezone_set('America/Los_Angeles');
This solves the problem in my case.

Running PHP in IIS6

i am using IIS to run my php website and i configure IIS to work with php as its explained the following tutorial
http://www.wikihow.com/Install-PHP-5-for-IIS-6
but when i run any php page is give me the following error
You have attempted to execute a CGI, ISAPI, or other executable program from a directory that does not allow programs to be executed.
i follow this https://serverfault.com/questions/251499/error-when-installing-php5-on-iis6/252149#252149
now i am getting the following error message
FastCGI Error
The FastCGI Handler was unable to process the request.
Error Details:
Could not find entry for "php" on site 67761686 in [Types] section.
Error Number: 1413 (0x80070585).
Error Description: Invalid index.
HTTP Error 500 - Server Error.
Internet Information Services (IIS)
here is my updated fcgiext.ini
[Types]
php=PHP
[PHP]
ExePath=C:\PHP\php-cgi.exe
now i am getting this error message
The FastCGI Handler was unable to process the request.
--------------------------------------------------------------------------------
Error Details:
The FastCGI process exceeded configured request timeout
Error Number: 258 (0x80070102).
Error Description: The wait operation timed out.
I hope this link would help
http://www.ardamis.com/2009/02/15/php-pages-return-a-404-error-on-iis/
Open iis.msc again, go back to the Home Directory tab, and select the “Scripts only” option >from the Execute Permissions menu. Restart the server.
The server should now be correctly processing .php files.
PHP pages return a 404 error on IIS
I was installing PHP 5 on an IIS 6 server when I ran into what turns out to be a pretty common problem. PHP appeared to be installed correctly, but browsing to any page with a .php extension returned a 404 Page Not Found error. While the steps below fixed this for me, I had to piece them together from a few different sources, and a number of other suggestions (like copying the php.ini file to C:/WINDOWS/) didn’t work and were not necessary.
Open your IIS management console at C:\WINDOWS\system32\inetsrv\iis.msc.
Drill down to your web site, right-click and select Properties.
Select the Home Directory tab, then click on the Configuration button.
Select the Mappings tab.
If you don’t see a .php extension listed, click the Add button. Browse to the PHP 5 DLL (which may be at C:\Program Files\PHP\php5isapi.dll). Type .php into the Extension field and leave everything else at the default values. Click OK. The extension and executable path will be filled out and under Verbs you should see “All”.
I should point out that I didn’t have anything listed under the ISAPI Filters tab.
Stop and restart your IIS server and browse to a .php file. (To restart your IIS server, open the IIS management console, right-click the local computer in the left pane, hover on All Tasks and choose Restart IIS.) Chances are, you’re no longer getting the 404 error, but are now seeing a 403.1 message, like:
The page cannot be displayed
You have attempted to execute a CGI, ISAPI, or other executable program from a directory that does not allow programs to be executed.
Please try the following:
* Contact the Web site administrator if you believe this directory should allow execute access.
HTTP Error 403.1 – Forbidden: Execute access is denied.
Internet Information Services (IIS)
Open iis.msc again, go back to the Home Directory tab, and select the “Scripts only” option from the Execute Permissions menu. Restart the server.
The server should now be correctly processing .php files.
Take a look at my answer on Server Fault for a fairly bulletproof way to install PHP in under ten minutes:
Error When Installing PHP5 on IIS6
If you follow all of the steps in the correct order you'll have PHP up and running in no time.
Updated:
As per your comment and question update, edit your fcgiext.ini file so that it only contains the following lines:
[Types]
php=PHP
[PHP]
ExePath=C:\PHP\php-cgi.exe
Execute the following from the command prompt:
1.
cd c:\Windows\system32\inetsrv
2.
c:\Windows\system32\inetsrv>cscript fcgiconfig.js -add -section:"PHP" -extension:php -path:"c:\php\php-cgi.exe"

Categories