469,328 Members | 1,316 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,328 developers. It's quick & easy.

Shared object and php - 'cannot restore segment prot after reloc: Permission denied'

Dheeraj Joshi
1,123 Expert 1GB
i have a shared object (.so) as example.so

In my php file when i try to call a function myfun() which is in example.so

I get a name look up error.. I gave the extensions properly in php.ini..

my code is
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include("example.php")
  3.  
  4. $num=example::myfun();
  5.  
  6. echo "$num;
  7.  
Aug 7 '09 #1
16 4377
Dheeraj Joshi
1,123 Expert 1GB
Look up error is gone.. Its fine now. But a new error.

Warning: dl(): Unable to load dynamic library './example.so' - ./example.so: cannot restore segment prot after reloc: Permission denied in /root/example.php on line 22

Fatal error: Call to undefined functionmyfun() in /root/myfile.php on line 4

I place these .so files in /root

and in php.ini i gave extension as /root/example.so.

We can place .so anywhere and give extension in php.ini file right?

Or should we place in specific locations?
Aug 7 '09 #2
Dormilich
8,651 Expert Mod 8TB
it looks like you don't have access to root's home directory (which would make sense). place the file somewhere with public access (like php's directory (something like /usr/bin or /var or /opt ...) otherwise you have to modify permission rights.
Aug 7 '09 #3
Dheeraj Joshi
1,123 Expert 1GB
Right now i am logged in as root.

And your meaning of permission means?

Regards
Dheeraj Joshi
Aug 7 '09 #4
Dormilich
8,651 Expert Mod 8TB
@dheerajjoshim
isn't that risky?

well, I guess it's PHP (resp. its process) that needs access permission then. (therefore I recommended PHP's directory)

@dheerajjoshim
file system permission
Aug 7 '09 #5
Dheeraj Joshi
1,123 Expert 1GB
Hey Dormilich i got the root cause of the problem.

My security policy was not allowing me to create a shared library.

When i disabled it, It is working.
Aug 7 '09 #6
Dormilich
8,651 Expert Mod 8TB
if you use __autoload() then you may indeed don't need it, though.
Aug 7 '09 #7
Dheeraj Joshi
1,123 Expert 1GB
I am trying to call a C function via PHP. So will __autoload( ) does that?

I think it won't work for 2 different languages.? Or will it work?
Aug 7 '09 #8
Dormilich
8,651 Expert Mod 8TB
@dheerajjoshim
wouldn't that usually work via shell command?
Aug 7 '09 #9
Dheeraj Joshi
1,123 Expert 1GB
It work's. But it was according to some specifications.So we had to take that route.

By the way, i observer strange thing. I am able to create .so file and call it in PYTHON.

Problem is coming only in PHP. Why?
Aug 7 '09 #10
Dormilich
8,651 Expert Mod 8TB
@dheerajjoshim
beats me, I've no idea.
Aug 7 '09 #11
Dheeraj Joshi
1,123 Expert 1GB
Even I don't have an idea. I am searching Internet, to get a answer. But it is strange behavior.
Aug 7 '09 #12
Markus
6,050 Expert 4TB
Get an answer for what? You just said it was working.
Aug 7 '09 #13
Markus
6,050 Expert 4TB
For any others experiencing this problem, this seems to be a common problem/fix.
Aug 7 '09 #14
Dheeraj Joshi
1,123 Expert 1GB
I am able to create a shared object and call the functions in PYTHON. But when i try to do it via PHP, I need to disable security policies of LINUX.

Why it works for one language and not for other.?
Aug 7 '09 #15
Dormilich
8,651 Expert Mod 8TB
maybe the processes' groups have different rights?
Aug 7 '09 #16
Dheeraj Joshi
1,123 Expert 1GB
May be....

But it is an interesting issue. Need to know more about it.
Aug 7 '09 #17

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Jim | last post: by
1 post views Thread by Alexander Cohen | last post: by
1 post views Thread by Simon Harvey | last post: by
1 post views Thread by Jerome | last post: by
21 posts views Thread by llothar | last post: by
2 posts views Thread by =?Utf-8?B?QW5kcmVhIEdhbGxhenpp?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.