PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label centos8. Show all posts
Showing posts with label centos8. Show all posts

Monday, December 5, 2022

[FIXED] What path to use when installing PHP OCI8 Linux Centos 8

 December 05, 2022     centos8, linux, oci8, oracle, php     No comments   

Issue

I'm having a problem and very confuse at the moment.

I tried to install oracle instant client on my linux centos 8. What I achieved so far is httpd, php72 and mariadb is working fine. I can run my php file in the server.

I am following this tutorial to enable php oci8 in my LAMPP stack.

https://medium.com/@azharnian/cara-install-oci8-php-7-di-centos7-851abbb5d15

But stuck on this step which is

sudo pecl install oci8

Command prompt ask to provide the path to the ORACLE_HOME directory. Refer to the image.

enter image description here

I download and place my oracle-instant-client zip package in my /home/user/oracle

What I tried so far in this step is :

sudo sh -c "echo instantclient, /usr/lib64/php/modules"
sudo sh -c "echo instantclient_19_8, /usr/lib64/php/modules"
sudo sh -c "echo instantclient_19_8, /home/user/oracle/instantclient_19_8"
instantclient_19_8, /usr/lib64/php/modules/oci8.so
instantclient_19_8, /home/user/oracle/instantclient_19_8

Errors :

checking build system type... Invalid configuration `/usr/lib64/php/modules/oci8.so': machine `/usr/lib64/php/modules/oci8.so' not recognized

What exactly this step want me to write ?

Appreciate if someone can show me the right way on this. Many thanks.


Solution

Download and unzip the Instant Client sdk ZIP file into the same directory /home/user/oracle/instantclient_19_8 so it looks something like:

  /home/user/oracle/instantclient_19_8:
  -r-xr-xr-x@  1 cjones  staff       5780  3 Jul 14:44 BASIC_LICENSE
  -rw-r--r--@  1 cjones  staff       1632  3 Jul 14:44 BASIC_README
  -r-xr-xr-x@  1 cjones  staff       5780  3 Jul 14:44 SDK_LICENSE
  -rw-r--r--@  1 cjones  staff       1626  3 Jul 14:44 SDK_README
  -rwxr-xr-x@  1 cjones  staff      41696  3 Jul 14:44 adrci
  -rwxr-xr-x@  1 cjones  staff      59272  3 Jul 14:44 genezi
  lrwxrwxrwx   1 cjones  staff         17 29 Jul 08:39 libclntsh.so -> libclntsh.so.19.1
  lrwxrwxrwx   1 cjones  staff         17 29 Jul 08:39 libclntsh.so.10.1 -> libclntsh.so.19.1
  lrwxrwxrwx   1 cjones  staff         17 29 Jul 08:39 libclntsh.so.11.1 -> libclntsh.so.19.1
  lrwxrwxrwx   1 cjones  staff         17 29 Jul 08:39 libclntsh.so.12.1 -> libclntsh.so.19.1
  lrwxrwxrwx   1 cjones  staff         17 29 Jul 08:39 libclntsh.so.18.1 -> libclntsh.so.19.1
  -rwxr-xr-x@  1 cjones  staff   80804848  3 Jul 14:44 libclntsh.so.19.1
  -rwxr-xr-x@  1 cjones  staff    8019360  3 Jul 14:44 libclntshcore.so.19.1
  -r-xr-xr-x@  1 cjones  staff    3608240  3 Jul 14:44 libipc1.so
  -r-xr-xr-x@  1 cjones  staff     478096  3 Jul 14:44 libmql1.so
  -rwxr-xr-x@  1 cjones  staff    6586360  3 Jul 14:44 libnnz19.so
  lrwxrwxrwx   1 cjones  staff         15 29 Jul 08:39 libocci.so -> libocci.so.19.1
  lrwxrwxrwx   1 cjones  staff         15 29 Jul 08:39 libocci.so.10.1 -> libocci.so.19.1
  lrwxrwxrwx   1 cjones  staff         15 29 Jul 08:39 libocci.so.11.1 -> libocci.so.19.1
  lrwxrwxrwx   1 cjones  staff         15 29 Jul 08:39 libocci.so.12.1 -> libocci.so.19.1
  lrwxrwxrwx   1 cjones  staff         15 29 Jul 08:39 libocci.so.18.1 -> libocci.so.19.1
  -rwxr-xr-x@  1 cjones  staff    2338456  3 Jul 14:44 libocci.so.19.1
  -rwxr-xr-x@  1 cjones  staff  130527608  3 Jul 14:44 libociei.so
  -r-xr-xr-x@  1 cjones  staff     153600  3 Jul 14:44 libocijdbc19.so
  -rwxr-xr-x@  1 cjones  staff     115760  3 Jul 14:44 liboramysql19.so
  drwxr-xr-x@  3 cjones  staff         96  3 Jul 14:44 network
  -rw-r--r--@  1 cjones  staff    4396157  3 Jul 14:44 ojdbc8.jar
  drwxr-xr-x@  7 cjones  staff        224  3 Jul 14:44 sdk
  -rw-r--r--@  1 cjones  staff    1681792  3 Jul 14:44 ucp.jar
  -rwxr-xr-x@  1 cjones  staff     236256  3 Jul 14:44 uidrvci
  -rw-r--r--@  1 cjones  staff      74263  3 Jul 14:44 xstreams.jar

Then run

sudo sh -c "echo /home/user/oracle/instantclient_19_8 > /etc/ld.so.conf.d/oracle-instantclient.conf"
sudo ldconfig

(as shown in the installation instructions).

Then at the pecl install oci8 prompt enter instantclient,/home/user/oracle/instantclient_19_8. Note I don't use whitespace after the comma. I don't recall what happens if you do use a whitespace. On my typical hack machines I tend to do it all as root:

sudo su -
pecl install oci8

but you can probably do some kind of sudo sh -c option and run echo "instantclient,/home/user/oracle/instantclient_19_8" | pecl install oci8

PS there may be some useful material in https://www.oracle.com/database/technologies/underground-php-oracle-manual.html



Answered By - Christopher Jones
Answer Checked By - Clifford M. (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, October 19, 2022

[FIXED] who and w commands in CentOS 8 Docker container

 October 19, 2022     admin, centos8, containers, docker     No comments   

Issue

While playing with CentOs 8 on Docker container I found out, that outputs of who and w commands are always empty.

[root@9e24376316f1 ~]# who
[root@9e24376316f1 ~]# w
 01:01:50 up  7:38,  0 users,  load average: 0.00, 0.04, 0.00
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT

Even when I'm logged in as a different user in second terminal. When I want to write to this user it shows

[root@9e24376316f1 ~]# write test
write: test is not logged in

Is this because of Docker? Maybe it works in some way that disallow sessions to see each other? Or maybe that's some other issue. I would really appreciate some explanation.


Solution

These utilities obtain the information about current logins from the utmp file (/var/run/utmp). You can easily check that in ordinary circumstances (e.g. on the desktop system) this file contains something like the following string (here qazer is my login and tty7 is a TTY where my desktop environment runs):

$ cat /var/run/utmp
tty7:0qazer:0�o^�

while in the container this file is (usually) empty:

$ docker run -it centos
[root@5e91e9e1a28e /]# cat /var/run/utmp
[root@5e91e9e1a28e /]#

Why?

The utmp file is usually modified by programs which authenticate the user and start the session: login(1), sshd(8), lightdm(1). However, the container engine cannot rely on them, as they may be absent in the container file system, so "logging in" and "executing on behalf of" is implemented in the most primitive and straightforward manner, avoiding relying on anything inside the container.

When any container is started or any command is execd inside it, the container engine just spawns the new process, arranges some security settings, calls setgid(2)/setuid(2) to forcibly (without any authentication) alter the process' UID/GID and then executes the required binary (the entry point, the command, and so on) within this process.

Say, I start the CentOS container running its main process on behalf of UID 42:

docker run -it --user 42 centos

and then try to execute sleep 1000 inside it:

docker exec -it $CONTAINER_ID sleep 1000

The container engine will perform something like this:

[pid 10170] setgid(0)                   = 0
[pid 10170] setuid(42)                  = 0
...
[pid 10170] execve("/usr/bin/sleep", ["sleep", "1000"], 0xc000159740 /* 4 vars */) = 0

There will be no writes to /var/run/utmp, thus it will remain empty, and who(1)/w(1) will not find any logins inside the container.



Answered By - Danila Kiver
Answer Checked By - Robin (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, January 21, 2022

[FIXED] laravel centOS 8 "log file could not be opened in append mode: failed to open stream: Permission denied”

 January 21, 2022     centos8, laravel, selinux     No comments   

Issue

Generally in ubuntu changing ownership to www-data and 775 permission solve this problem. But in centos 8 this seems not enough. What I did is-

  1. Set SELinux in permissive mode
  2. Allow to write in the laravel storage folder - chcon -R -t httpd_sys_rw_content_t storage
  3. sudo chown -R nginx:nginx /path/to/your/laravel/root/directory
  4. chmod -R 775 storage/
  5. Reboot the system

Nothing is working. What to do solve this problem?


Solution

From the projects root folder try:

    sudo chmod -R gu+w storage/
    sudo chmod -R guo+w storage/
    sudo chmod -R gu+w bootstrap/cache/
    sudo chmod -R guo+w bootstrap/cache/


Answered By - jeremykenedy
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, December 29, 2021

[FIXED] Apache Permission Error on open file in Python

 December 29, 2021     apache, centos8, lamp, php, python     No comments   

Issue

I am new to web design, and I'm trying to setup an Apache web interface to some python code. I am running a test python script that just opens a new file in /var/www/html/ called output.txt and attempts to write to it. When the web page is loaded, I use shell_exec('/usr/bin/python3 /var/www/html/ptest.py'); to run my python script. The python script does run and outputs some print messages, but trying to open output.txt fails with: Traceback (most recent call last): File "/var/www/html/ptest.py", line 8, in f=open("/var/www/html/output.txt", "w") PermissionError: [Errno 13] Permission denied: '/var/www/html/output.txt'. It will also fail if the file already exists and I open to read.

I have confirmed that the script is being run by apache with getpass.getuser(), and I have tried as many different permission combinations as I can think of for /var/www/html/, including 777. I have set apache as the group for every directory from /var/ to html/. I have tried creating the file ahead of time with 777 permissions. I have checked that /var/ to html/ has group execution permission. I have tried creating and using another folder completely owned by apache.

I have looked through the apache directives to see if there is a directive I need to have, but I haven't found one yet.

I've included the code for my python script and my php page below.

EDIT: I've tried running ptest.py as apache using su -s /bin/bash apache.

ptest.py successfully runs this way, so the problem doesn't seem to be a permission associated with the apache user/group.

ptest.py

#!/usr/bin/python3
import sys
import getpass
import os
sys.stderr = sys.stdout
print(getpass.getuser())
print(os.getgid())
f = open("/var/www/html/output.txt", "w")
f.write("banana")
f.close()
print("I wrote banana, which is a berry")

banana.php

<html>
    <head></head>
    <body>
        <h2>Welcome to the Program Test</h2>
        <?php
            echo "Created Command", "<br>";
            $output = shell_exec('/usr/bin/python3 /var/www/html/ptest.py');
            echo "Executed Command", "<br>";
            echo $output, "<br>";
            echo "End of output", "<br>";
            $output = shell_exec('ls /var/www/html/');
            echo $output;
        ?>
    </body>
</html>

Solution

Credit to domino_pl leaving a comment.

It looks like typical selinux problem. Try selinux setenforce 0 – domino_pl



Answered By - Bill Jobs
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing