Jump to content

dariyoosh

Members
  • Posts

    13
  • Joined

  • Last visited

dariyoosh's Achievements

Newbie

Newbie (1/5)

0

Reputation

1

Community Answers

  1. Ok, I solved the problem. It was SELinux which was blocking the library load. Now I have OCI8 entry in phpinfo(). At the same time as we saw before the PHP in command line could detect OCI8, maybe this means that SELinux doesn't have the same impact in CLI as in GUI. I also wrote a test SQL script (SELECT employee_id FROM employees WHERE department_id = 100) and the result was printed on the screen perfectly. So for those who may have encountered the same problem with the same environment parameters I'm going to give a summary of how I proceeded in the case where it might be helpful for others. My environment OS: Linux Fedora Core 17 (X86_64) Oracle version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Apache version (httpd): Apache 2.0 PHP version: 5.4.13 Before the installation Before the installation I disabled SELinux. At the time of writing I'm not an expert of SELinux so I don't know any rule modification in order to modify SELinux policy accordingly allowing to OCI8 module to load oracle libraries. As a result I finally disabled completely the SELinux on my system which may have serious security impacts! This can be done in the following way (being as root) # vim /etc/selinux/config The file content is something similar to the following # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=enforcing # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted So what I did was that I put a comment at the beginning of the line SELINUX=enforcing and instead I added a new line right after that line which was SELINUX=disabled. Finally I rebooted the system. Installation: - Make sure that all oracle environment variables are defined in ~/.bash_profile of the user who installs OCI8. Otherwise you will have to enter manually the path to $ORACLE_HOME. I tested both ways and each method works pretty well. Yet I find the first one more elegant because it detects automatically everything - In my case, PHP, Apache and Oracle server were all on the same physical machine, therefore I didn't need to install the Oracle Instant client. All the required oracle libraries for OCI8 were therefore already available. - being as ROOT, I run the following (I don't know whether this was mandatory but I prefered to stop httpd before installing OCI8) # pecl install oci8 (On my machine pecl was already there, if not you can install it by using yum) - Once installation is over, at the end of the installation report in the terminal you will get something like this The two bold lines above shows what you have to put in your php.ini file (on my computer this file is in /etc/php.ini) So I updated the php.ini file in the following way: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Dynamic Extensions ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; If you wish to have an extension loaded automatically, use the following ; syntax: ; ; extension=modulename.extension . . . extension=oci8.so . . . ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Paths and Directories ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; UNIX: "/path1:/path2" ; ; . . . extension_dir="/usr/lib64/php/modules" Then you have to define the required oracle environment variables for Apache. According to what I read in http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html and in several forums while I was googling for this problem and also based on my own tests, it seems to me that depending on which Apache version you're using, the syntax for declaring the environment variables in /etc/sysconfig/httpd is not the same. Here is what I added at the end of the file /etc/sysconfig/httpd . . . ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/db_1/lib:/u01/app/oracle/product/11.2.0/db_1/network/lib TNS_ADMIN=/u01/app/oracle/product/11.2.0/db_1/network/admin NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252 ORACLE_SID=db01 I tried to use the export keyword before the variable names but it didn't work for me, yet I saw in other forums that there were people who apparently had used that syntax successfully. So again it is a matter of personal observation. For me using Apache 2.0, only the above syntax works. Also if I use $ in order to expand the environment variables it doesn't work so for example instead of writing ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib I had to write explicitly the expanded values myself, that is, ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/db_1/lib:/u01/app/oracle/product/11.2.0/db_1/network/lib Once this is done, restart httpd # service httpd start If everything went well, normally you will see the OCI8 entry if you run phpinfo() in a test PHP script. Hope this may help others, Regards, Dariyoosh
  2. Hello there, Thank you very much for your attention to my problem. First of all, after a bit googling I understood that the environment variables inside /etc/sysconfig/httpd as I specified by using PassEnv are those used internally by apache and have nothing to do with the OS environment variables. Apparently for OS environment variables the same syntax applies as ~/.bash_profile. So instead of adding I added the following lines at the end of /etc/sysconfig/httpd However, I'm not sure that these variables are actually being taken into account by Apache because when I restart the server, here is what I can read in the log file Looking for the missing file Yet /u01/app/oracle/product/11.2.0/db_1/lib/ is exactly what I specified as LD_LIBRARY_PATH in /etc/sysconfig/httpd. So it seems that (maybe) apache doesn't see my environment variables. I proceeded accordingly as you said when I see the output of the phpinfo() in my browser I have Loaded Configuration File = /etc/php.ini Very interesting, I didn't even know that there are two different php.ini files However, it seems that on my system both of them point to the same file # php -i | grep Configuration Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini Configuration # I'm really confused ! Regards, Dariyoosh
  3. Hello everybody, I'm trying to setup a connection from PHP to an oracle database by using OCI8. According to the documentation, upon a successfull installation, I'm supposed to see some information about OCI8 in phpinfo(). Problem: Nothing shows up in phpinfo about OCI8 Just to see what would be the output I run the very same PHP test script in the article <?php $conn = oci_connect('myuser', 'mypassword', 'localhost/DB01'); $stid = oci_parse($conn, 'select table_name from user_tables'); oci_execute($stid); echo "<table>\n"; while ( ( $row = oci_fetch_array ( $stid, OCI_ASSOC+OCI_RETURN_NULLS ) ) != false ) { echo "<tr>\n"; foreach ($row as $item) { echo " <td>". ($item !== null ? htmlentities($item, ENT_QUOTES) : " ")."</td>\n"; } echo "</tr>\n"; } echo "</table>\n"; ?> And the output was Fatal error: Call to undefined function oci_connect() in /var/www/html/myscript.php on line ... Which shows that something serious is missing. As a result, I would like to ask you to kindly take a look to the below details about how I proceeded in order to setup OCI8 and to see where I made mistake(s) Here are some details about my working platform OS: Linux Fedora Core 17 (64 bits) DBMS: Oracle Enterprise Edition 11gR2 (11.2.0.1.0) PHP Version: 5.4.13 Apache version: 2.2.23 I installed OCI8 based on the following article (except that I already had both server and client installed on the same physical machine, therefore I didn't need to install/reinstall the instant client) http://www.oracle.com/technetwork/articles/technote-php-instant-084410.html So being as ROOT I run the following # pecl install oci8 Which gave me the following output After that I added to php.ini I also run the following command in the terminal So looking at the above bold output, I think we can say that there is however some link between the installed oci and my oracle server. Also, I added to the /etc/sysconfig/httpd configuration file the following environment variables which had already been defined in ~/.bash_profile Once the variables were defined I restarted the httpd service httpd restart Yet, the same problem, no oci8 in phpinfo() Could someone kindly make some clarification? Thanks in advance, Dariyoosh
  4. Hello there, Thank you very much for this nice and clear description. Just one more question (as I'm newbie ) which method among the following is more common and is considered to be a good style of programming? (so that I follow it in the future) 1 - Simply call the function (according to the position of the parameters) by directly providing the value 2 - Call the function by writing functionName(paramName1 = value1, paramName2=value2, . . .) Although that according to what you said, PHP takes into account only the position (just to make the code more explicit for the reader) 3 - using an associative array Thanks a lot, Regards, Dariyoosh
  5. Dear all, I have a question about function call in PHP and I would appreciate if you could kindly make some clarification. Generally, I prefer to call my functions by name, that is, instead of writing functionName(paramValue, paramValue, . . .) I prefer to provide the name of the formal parameters as they were specified in the function prototype. functionName(param1Name=paramValue, param2Name=paramValue, . . .) Well, maybe it's just a matter of personal taste, but It seems to me more elegant and in particular for someone who reads my code might be more clear and easier to understand what I provide exactly in terms of parameters while calling the function. And this could be even more helpful, particularly if the function includes so many arguments among them several with default values. Yet, I've just found (I'm Newbie ) that PHP, actually doesn't care about the fact that the name of the effective parameters are different of those of formal parameters. Consider the following example function myFunction($param1, $param2) { echo "param1 = " . $param1 . "<br>"; echo "param2 = " . $param2 . "<br>"; } myfunction ( $param1=300, $param2="id-01001GGKK" ); As you can see in this example the name of the effective parameters in the function call correspond to those specified in function prototype, resectively, param1 and param2. Yet, I tested successfully the following myfunction ( $size=120, $code="id-010012F" ); Although the name of the parameters were completely different, again the function was executed successfully without any problem. Is that normal? In addition, the only way that I found to enforce the parameters names was to use an associative array including the list of parameters. Something like this: function myFunction($paramArray) { if (isset($paramArray["param1"]) AND isset($paramArray["param2"])) { echo "param1 = " . $paramArray["param1"] . "<br>"; echo "param2 = " . $paramArray["param2"] . "<br>"; } else die("Bad argument list"); } Yet, it's not clear. I would like that each parameter name be visible. So, I would like to ask, is there any other way to enforce the effective parameter names to be the same as those specified in the function prototype? One other reason I ask this question is that until now, whenever I wanted to call a built-in PHP function, I used to check its documentation in order to first understand its functionality and second to view in detail its parameter list, formal parameter names to use them in my code. And I was thinking that I was doing fine and PHP takes them into account!! Thanks in advance, Regards, Dariyoosh
  6. Thanks, from the link you provided I conclude that it is moderated and notes become part of the documentation Thanks for the reply Regards, Dariyoosh
  7. Hi, What I'm going to ask may seem to many among you a very trivial/strange question. Actually I'm a beginner in PHP and obviously I need to read regularly the online documentation for different topics related to PHP (in particular functions). Whenever I check the documentation for a given subject, let's say a function, I can read the official presentation with examples, but then, at the bottom of the page I often see many people who have written their comments. Sometimes, these comments seem to me really interesting and helpful. Yet, I would like to ask, are these moderated and approved comments? I mean, do they reflect the PHP official documentation point of view? and therefore the suggested solutions could safely be used on my projects? or it's just simply personal opinions based on personal experience? Thanks in advance, Regards, Dariyoosh
  8. Thank you very much both of you for your time and your attention to my question. I will pay attention to phpinfo() for future reference. For just viewing the PHP directives, I wrote the following which provides the info <?php phpinfo(INFO_CONFIGURATION); ?> Regards, Dariyoosh
  9. Well, it seems that I made a mistake. I edited the file using vim and when I saw ; display_errors= I thought this was the line to modify and uncomment, but in fact that was just the description section in the "Quick Reference". The actual line to modify is actually further down in the file. Sorry for my mistake, it works now! Regards, Dariyoosh
  10. Hello everyone OS: Fedora Core 17 (x86_64) Browser: Firefox 18.0 PHP version: 5.4.11 Apache version: 2.2.22 I would like to know whether it is possible to print different kinds of PHP errors (at least parsing errors) in the browser screen. for example <?php myVariable = 12 ?> This should give a syntax/parse error because there is not $ before the variable name nor the ";" at the end of the statement. I modified the file /etc/php.ini by removing comments for the two following options: Then I restarted the apache service # service httpd restart Yet, I don't see any change, and whenever there is an error, I just have a blank page in the browser. Any idea? What are the further actions to be taken in order to print errors and warnings on the screen? (Of course, I want to do this only for development/training purpose, here we are not talking about a production environment) Thanks in advance, Regards, Dariyoosh
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.