APC configuration not getting loaded by PHP-FPM - php

for some reason my php installation refuses to load the config for the APC Op-Cache. But looking at phpinfo() every other config file in this directory is getting loaded. Permissions seem ok. below is a look at the directories and the config file itself. And i can confirm that apcu.so exists in the extensions directory as it should. Any ideas here? im stumped.
root#friends:/etc/php5/fpm/conf.d# ls -l
total 24
lrwxrwxrwx 1 root root 32 Apr 7 2014 05-opcache.ini -> ../../mods-available/opcache.ini
lrwxrwxrwx 1 root root 28 Apr 7 2014 10-pdo.ini -> ../../mods-available/pdo.ini
lrwxrwxrwx 1 root root 29 Aug 6 13:45 20-apcu.ini -> ../../mods-available/apcu.ini
lrwxrwxrwx 1 root root 29 Apr 9 2014 20-curl.ini -> ../../mods-available/curl.ini
lrwxrwxrwx 1 root root 27 Aug 6 2014 20-gd.ini -> ../../mods-available/gd.ini
lrwxrwxrwx 1 root root 29 Apr 8 2014 20-json.ini -> ../../mods-available/json.ini
lrwxrwxrwx 1 root root 31 Aug 6 2014 20-mcrypt.ini -> ../../mods-available/mcrypt.ini
lrwxrwxrwx 1 root root 34 Feb 2 2015 20-memcached.ini -> ../../mods-available/memcached.ini
lrwxrwxrwx 1 root root 30 Aug 6 2014 20-mssql.ini -> ../../mods-available/mssql.ini
lrwxrwxrwx 1 root root 31 Apr 7 2014 20-mysqli.ini -> ../../mods-available/mysqli.ini
lrwxrwxrwx 1 root root 30 Apr 7 2014 20-mysql.ini -> ../../mods-available/mysql.ini
lrwxrwxrwx 1 root root 34 Aug 6 2014 20-pdo_dblib.ini -> ../../mods-available/pdo_dblib.ini
lrwxrwxrwx 1 root root 34 Apr 7 2014 20-pdo_mysql.ini -> ../../mods-available/pdo_mysql.ini
lrwxrwxrwx 1 root root 33 Apr 7 2014 20-readline.ini -> ../../mods-available/readline.ini
-rw-r--r-- 1 root root 22661 Apr 22 15:11 newrelic.ini
root#friends:/etc/php5/fpm/conf.d# ls -l ../../mods-available/
total 56
-rw-r--r-- 1 root root 119 Aug 6 13:47 apcu.ini
-rw-r--r-- 1 root root 68 Apr 3 2014 curl.ini
-rw-r--r-- 1 root root 64 Jul 7 2014 gd.ini
-rw-r--r-- 1 root root 68 Aug 8 2013 json.ini
-rw-r--r-- 1 root root 58 Aug 6 2014 mcrypt.ini
-rw-r--r-- 1 root root 70 Dec 19 2012 memcached.ini
-rw-r--r-- 1 root root 71 Jul 7 2014 mssql.ini
-rw-r--r-- 1 root root 71 Apr 3 2014 mysqli.ini
-rw-r--r-- 1 root root 70 Apr 3 2014 mysql.ini
-rw-r--r-- 1 root root 83 May 2 2014 opcache.ini
-rw-r--r-- 1 root root 75 Jul 7 2014 pdo_dblib.ini
-rw-r--r-- 1 root root 66 Apr 3 2014 pdo.ini
-rw-r--r-- 1 root root 74 Apr 3 2014 pdo_mysql.ini
-rw-r--r-- 1 root root 76 Apr 3 2014 readline.ini
root#friends:/etc/php5/fpm/conf.d# cat ../../mods-available/apcu.ini
extension=apcu.so
apc.enabled=1
apc.shm_size=128M
apc.ttl=3600
apc.user_ttl=7200
apc.gc_ttl=3600
apc.max_file_size=1M

Related

Set default PHP version of apache2 to a specific version

Currently the PHP version showing if I call phpinfo() is 8.0.19.
I need to change it to 8.0.15.
I already build 8.0.15 from source and changed the CLI PHP version successfully by using update-alternatives.
php -v
PHP 8.0.15 (cli) (built: Jun 7 2022 10:21:21) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.15, Copyright (c) Zend Technologies
But phpinfo still shows 8.0.19.
How can I set it to 8.0.15 globally?
I'am using Ubuntu 22.04
/etc/apache2/mods-enabled
lrwxrwxrwx 1 root root 36 Jun 1 14:30 access_compat.load -> ../mods-available/access_compat.load
lrwxrwxrwx 1 root root 28 Jun 1 14:30 alias.conf -> ../mods-available/alias.conf
lrwxrwxrwx 1 root root 28 Jun 1 14:30 alias.load -> ../mods-available/alias.load
lrwxrwxrwx 1 root root 33 Jun 1 14:30 auth_basic.load -> ../mods-available/auth_basic.load
lrwxrwxrwx 1 root root 33 Jun 1 14:30 authn_core.load -> ../mods-available/authn_core.load
lrwxrwxrwx 1 root root 33 Jun 1 14:30 authn_file.load -> ../mods-available/authn_file.load
lrwxrwxrwx 1 root root 33 Jun 1 14:30 authz_core.load -> ../mods-available/authz_core.load
lrwxrwxrwx 1 root root 33 Jun 1 14:30 authz_host.load -> ../mods-available/authz_host.load
lrwxrwxrwx 1 root root 33 Jun 1 14:30 authz_user.load -> ../mods-available/authz_user.load
lrwxrwxrwx 1 root root 32 Jun 1 14:30 autoindex.conf -> ../mods-available/autoindex.conf
lrwxrwxrwx 1 root root 32 Jun 1 14:30 autoindex.load -> ../mods-available/autoindex.load
lrwxrwxrwx 1 root root 30 Jun 1 14:30 deflate.conf -> ../mods-available/deflate.conf
lrwxrwxrwx 1 root root 30 Jun 1 14:30 deflate.load -> ../mods-available/deflate.load
lrwxrwxrwx 1 root root 26 Jun 1 14:30 dir.conf -> ../mods-available/dir.conf
lrwxrwxrwx 1 root root 26 Jun 1 14:30 dir.load -> ../mods-available/dir.load
lrwxrwxrwx 1 root root 26 Jun 1 14:30 env.load -> ../mods-available/env.load
lrwxrwxrwx 1 root root 29 Jun 1 14:30 filter.load -> ../mods-available/filter.load
lrwxrwxrwx 1 root root 27 Jun 1 14:30 mime.conf -> ../mods-available/mime.conf
lrwxrwxrwx 1 root root 27 Jun 1 14:30 mime.load -> ../mods-available/mime.load
lrwxrwxrwx 1 root root 34 Jun 1 14:30 mpm_prefork.conf -> ../mods-available/mpm_prefork.conf
lrwxrwxrwx 1 root root 34 Jun 1 14:30 mpm_prefork.load -> ../mods-available/mpm_prefork.load
lrwxrwxrwx 1 root root 34 Jun 1 14:30 negotiation.conf -> ../mods-available/negotiation.conf
lrwxrwxrwx 1 root root 34 Jun 1 14:30 negotiation.load -> ../mods-available/negotiation.load
lrwxrwxrwx 1 root root 29 Jun 7 13:03 php8.0.conf -> ../mods-available/php8.0.conf
lrwxrwxrwx 1 root root 29 Jun 7 13:03 php8.0.load -> ../mods-available/php8.0.load
lrwxrwxrwx 1 root root 33 Jun 1 14:30 reqtimeout.conf -> ../mods-available/reqtimeout.conf
lrwxrwxrwx 1 root root 33 Jun 1 14:30 reqtimeout.load -> ../mods-available/reqtimeout.load
lrwxrwxrwx 1 root root 30 Jun 2 11:42 rewrite.load -> ../mods-available/rewrite.load
lrwxrwxrwx 1 root root 31 Jun 1 14:30 setenvif.conf -> ../mods-available/setenvif.conf
lrwxrwxrwx 1 root root 31 Jun 1 14:30 setenvif.load -> ../mods-available/setenvif.load
lrwxrwxrwx 1 root root 36 Jun 2 08:38 socache_shmcb.load -> ../mods-available/socache_shmcb.load
lrwxrwxrwx 1 root root 26 Jun 2 08:38 ssl.conf -> ../mods-available/ssl.conf
lrwxrwxrwx 1 root root 26 Jun 2 08:38 ssl.load -> ../mods-available/ssl.load
lrwxrwxrwx 1 root root 29 Jun 1 14:30 status.conf -> ../mods-available/status.conf
lrwxrwxrwx 1 root root 29 Jun 1 14:30 status.load -> ../mods-available/status.load
/etc/apache2/mods-available
-rw-r--r-- 1 root root 100 Mar 23 02:00 access_compat.load
-rw-r--r-- 1 root root 377 Mar 23 02:00 actions.conf
-rw-r--r-- 1 root root 66 Mar 23 02:00 actions.load
-rw-r--r-- 1 root root 843 Mar 23 02:00 alias.conf
-rw-r--r-- 1 root root 62 Mar 23 02:00 alias.load
-rw-r--r-- 1 root root 76 Mar 23 02:00 allowmethods.load
-rw-r--r-- 1 root root 76 Mar 23 02:00 asis.load
-rw-r--r-- 1 root root 94 Mar 23 02:00 auth_basic.load
-rw-r--r-- 1 root root 96 Mar 23 02:00 auth_digest.load
-rw-r--r-- 1 root root 100 Mar 23 02:00 auth_form.load
-rw-r--r-- 1 root root 72 Mar 23 02:00 authn_anon.load
-rw-r--r-- 1 root root 72 Mar 23 02:00 authn_core.load
-rw-r--r-- 1 root root 85 Mar 23 02:00 authn_dbd.load
-rw-r--r-- 1 root root 70 Mar 23 02:00 authn_dbm.load
-rw-r--r-- 1 root root 72 Mar 23 02:00 authn_file.load
-rw-r--r-- 1 root root 78 Mar 23 02:00 authn_socache.load
-rw-r--r-- 1 root root 74 Mar 23 02:00 authnz_fcgi.load
-rw-r--r-- 1 root root 90 Mar 23 02:00 authnz_ldap.load
-rw-r--r-- 1 root root 72 Mar 23 02:00 authz_core.load
-rw-r--r-- 1 root root 96 Mar 23 02:00 authz_dbd.load
-rw-r--r-- 1 root root 92 Mar 23 02:00 authz_dbm.load
-rw-r--r-- 1 root root 104 Mar 23 02:00 authz_groupfile.load
-rw-r--r-- 1 root root 94 Mar 23 02:00 authz_host.load
-rw-r--r-- 1 root root 74 Mar 23 02:00 authz_owner.load
-rw-r--r-- 1 root root 94 Mar 23 02:00 authz_user.load
-rw-r--r-- 1 root root 3.3K Mar 23 02:00 autoindex.conf
-rw-r--r-- 1 root root 70 Mar 23 02:00 autoindex.load
-rw-r--r-- 1 root root 64 Mar 23 02:00 brotli.load
-rw-r--r-- 1 root root 64 Mar 23 02:00 buffer.load
-rw-r--r-- 1 root root 62 Mar 23 02:00 cache.load
-rw-r--r-- 1 root root 889 Mar 23 02:00 cache_disk.conf
-rw-r--r-- 1 root root 89 Mar 23 02:00 cache_disk.load
-rw-r--r-- 1 root root 95 Mar 23 02:00 cache_socache.load
-rw-r--r-- 1 root root 70 Mar 23 02:00 cern_meta.load
-rw-r--r-- 1 root root 58 Mar 23 02:00 cgi.load
-rw-r--r-- 1 root root 115 Mar 23 02:00 cgid.conf
-rw-r--r-- 1 root root 60 Mar 23 02:00 cgid.load
-rw-r--r-- 1 root root 76 Mar 23 02:00 charset_lite.load
-rw-r--r-- 1 root root 60 Mar 23 02:00 data.load
-rw-r--r-- 1 root root 93 Mar 23 02:00 dav.load
-rw-r--r-- 1 root root 83 Mar 23 02:00 dav_fs.conf
-rw-r--r-- 1 root root 79 Mar 23 02:00 dav_fs.load
-rw-r--r-- 1 root root 68 Mar 23 02:00 dav_lock.load
-rw-r--r-- 1 root root 58 Mar 23 02:00 dbd.load
-rw-r--r-- 1 root root 460 Mar 23 02:00 deflate.conf
-rw-r--r-- 1 root root 84 Mar 23 02:00 deflate.load
-rw-r--r-- 1 root root 64 Mar 23 02:00 dialup.load
-rw-r--r-- 1 root root 157 Mar 23 02:00 dir.conf
-rw-r--r-- 1 root root 58 Mar 23 02:00 dir.load
-rw-r--r-- 1 root root 64 Mar 23 02:00 dump_io.load
-rw-r--r-- 1 root root 60 Mar 23 02:00 echo.load
-rw-r--r-- 1 root root 58 Mar 23 02:00 env.load
-rw-r--r-- 1 root root 66 Mar 23 02:00 expires.load
-rw-r--r-- 1 root root 72 Mar 23 02:00 ext_filter.load
-rw-r--r-- 1 root root 89 Mar 23 02:00 file_cache.load
-rw-r--r-- 1 root root 64 Mar 23 02:00 filter.load
-rw-r--r-- 1 root root 66 Mar 23 02:00 headers.load
-rw-r--r-- 1 root root 176 Mar 23 02:00 heartbeat.load
-rw-r--r-- 1 root root 182 Mar 23 02:00 heartmonitor.load
-rw-r--r-- 1 root root 1.3K Mar 23 02:00 http2.conf
-rw-r--r-- 1 root root 62 Mar 23 02:00 http2.load
-rw-r--r-- 1 root root 62 Mar 23 02:00 ident.load
-rw-r--r-- 1 root root 68 Mar 23 02:00 imagemap.load
-rw-r--r-- 1 root root 82 Mar 23 02:00 include.load
-rw-r--r-- 1 root root 402 Mar 23 02:00 info.conf
-rw-r--r-- 1 root root 60 Mar 23 02:00 info.load
-rw-r--r-- 1 root root 116 Mar 23 02:00 lbmethod_bybusyness.load
-rw-r--r-- 1 root root 116 Mar 23 02:00 lbmethod_byrequests.load
-rw-r--r-- 1 root root 114 Mar 23 02:00 lbmethod_bytraffic.load
-rw-r--r-- 1 root root 114 Mar 23 02:00 lbmethod_heartbeat.load
-rw-r--r-- 1 root root 121 Mar 23 02:00 ldap.conf
-rw-r--r-- 1 root root 60 Mar 23 02:00 ldap.load
-rw-r--r-- 1 root root 70 Mar 23 02:00 log_debug.load
-rw-r--r-- 1 root root 76 Mar 23 02:00 log_forensic.load
-rw-r--r-- 1 root root 58 Mar 23 02:00 lua.load
-rw-r--r-- 1 root root 62 Mar 23 02:00 macro.load
-rw-r--r-- 1 root root 56 Mar 23 02:00 md.load
-rw-r--r-- 1 root root 7.6K Mar 23 02:00 mime.conf
-rw-r--r-- 1 root root 60 Mar 23 02:00 mime.load
-rw-r--r-- 1 root root 120 Mar 23 02:00 mime_magic.conf
-rw-r--r-- 1 root root 72 Mar 23 02:00 mime_magic.load
-rw-r--r-- 1 root root 668 Mar 23 02:00 mpm_event.conf
-rw-r--r-- 1 root root 106 Mar 23 02:00 mpm_event.load
-rw-r--r-- 1 root root 571 Mar 23 02:00 mpm_prefork.conf
-rw-r--r-- 1 root root 108 Mar 23 02:00 mpm_prefork.load
-rw-r--r-- 1 root root 836 Mar 23 02:00 mpm_worker.conf
-rw-r--r-- 1 root root 107 Mar 23 02:00 mpm_worker.load
-rw-r--r-- 1 root root 724 Mar 23 02:00 negotiation.conf
-rw-r--r-- 1 root root 74 Mar 23 02:00 negotiation.load
-rw-r--r-- 1 root root 855 May 17 18:49 php8.0.conf
-rw-r--r-- 1 root root 101 May 17 18:49 php8.0.load
-rw-r--r-- 1 root root 822 Mar 23 02:00 proxy.conf
-rw-r--r-- 1 root root 62 Mar 23 02:00 proxy.load
-rw-r--r-- 1 root root 87 Mar 23 02:00 proxy_ajp.load
-rw-r--r-- 1 root root 347 Mar 23 02:00 proxy_balancer.conf
-rw-r--r-- 1 root root 115 Mar 23 02:00 proxy_balancer.load
-rw-r--r-- 1 root root 95 Mar 23 02:00 proxy_connect.load
-rw-r--r-- 1 root root 95 Mar 23 02:00 proxy_express.load
-rw-r--r-- 1 root root 89 Mar 23 02:00 proxy_fcgi.load
-rw-r--r-- 1 root root 93 Mar 23 02:00 proxy_fdpass.load
-rw-r--r-- 1 root root 189 Mar 23 02:00 proxy_ftp.conf
-rw-r--r-- 1 root root 87 Mar 23 02:00 proxy_ftp.load
-rw-r--r-- 1 root root 93 Mar 23 02:00 proxy_hcheck.load
-rw-r--r-- 1 root root 2.5K Mar 23 02:00 proxy_html.conf
-rw-r--r-- 1 root root 97 Mar 23 02:00 proxy_html.load
-rw-r--r-- 1 root root 89 Mar 23 02:00 proxy_http.load
-rw-r--r-- 1 root root 97 Mar 23 02:00 proxy_http2.load
-rw-r--r-- 1 root root 89 Mar 23 02:00 proxy_scgi.load
-rw-r--r-- 1 root root 91 Mar 23 02:00 proxy_uwsgi.load
-rw-r--r-- 1 root root 97 Mar 23 02:00 proxy_wstunnel.load
-rw-r--r-- 1 root root 85 Mar 23 02:00 ratelimit.load
-rw-r--r-- 1 root root 70 Mar 23 02:00 reflector.load
-rw-r--r-- 1 root root 68 Mar 23 02:00 remoteip.load
-rw-r--r-- 1 root root 1.2K Mar 23 02:00 reqtimeout.conf
-rw-r--r-- 1 root root 72 Mar 23 02:00 reqtimeout.load
-rw-r--r-- 1 root root 66 Mar 23 02:00 request.load
-rw-r--r-- 1 root root 66 Mar 23 02:00 rewrite.load
-rw-r--r-- 1 root root 58 Mar 23 02:00 sed.load
-rw-r--r-- 1 root root 66 Mar 23 02:00 session.load
-rw-r--r-- 1 root root 99 Mar 23 02:00 session_cookie.load
-rw-r--r-- 1 root root 99 Mar 23 02:00 session_crypto.load
-rw-r--r-- 1 root root 93 Mar 23 02:00 session_dbd.load
-rw-r--r-- 1 root root 1.3K Mar 23 02:00 setenvif.conf
-rw-r--r-- 1 root root 68 Mar 23 02:00 setenvif.load
-rw-r--r-- 1 root root 78 Mar 23 02:00 slotmem_plain.load
-rw-r--r-- 1 root root 74 Mar 23 02:00 slotmem_shm.load
-rw-r--r-- 1 root root 74 Mar 23 02:00 socache_dbm.load
-rw-r--r-- 1 root root 84 Mar 23 02:00 socache_memcache.load
-rw-r--r-- 1 root root 78 Mar 23 02:00 socache_redis.load
-rw-r--r-- 1 root root 78 Mar 23 02:00 socache_shmcb.load
-rw-r--r-- 1 root root 66 Mar 23 02:00 speling.load
-rw-r--r-- 1 root root 3.1K Mar 23 02:00 ssl.conf
-rw-r--r-- 1 root root 97 Mar 23 02:00 ssl.load
-rw-r--r-- 1 root root 749 Mar 23 02:00 status.conf
-rw-r--r-- 1 root root 64 Mar 23 02:00 status.load
-rw-r--r-- 1 root root 72 Mar 23 02:00 substitute.load
-rw-r--r-- 1 root root 64 Mar 23 02:00 suexec.load
-rw-r--r-- 1 root root 70 Mar 23 02:00 unique_id.load
-rw-r--r-- 1 root root 324 Mar 23 02:00 userdir.conf
-rw-r--r-- 1 root root 66 Mar 23 02:00 userdir.load
-rw-r--r-- 1 root root 70 Mar 23 02:00 usertrack.load
-rw-r--r-- 1 root root 74 Mar 23 02:00 vhost_alias.load
-rw-r--r-- 1 root root 66 Mar 23 02:00 xml2enc.load
Try the following:
sudo a2dismod php8.0.19
sudo a2enmod php8.0.15
It should work, or see this.
Edit:
Considering there's no specific module for 8.0.x version for apache, it seems that you have to purge php, and install only the desired 8.0.15 version, as someone did here. Although that would solve your problem (most likely, not tested), it would remove php8.0.19 from your system, so if you need it for any other thing, you'd have to take that into consideration.

sh: 1: python3: not found when running from php

I'm trying to run a python script from php and it gives me this error
sh: 1: python3: not found
The php code is
exec('python3 ./myscript.py data.json 2>&1', $output);
It runs ok from the terminal, I even tried running python3 from terminal as www-data and it works
$ sudo -u www-data python3 -V
Python 3.5.3
Executing with the full path exec('/usr/local/bin/python3 ./myscript.py data.json 2>&1', $output); gives the same result.
Server SO is Debian GNU/Linux 8 (jessie) and I'm using nginx
This worked for me in an Ubuntu + apache2 environment but I don't know what I'm missing here.
I've read this but it doesn't have a solution, and also this, but all the ways to do an exec gives me the same problem.
Also the exec returns error code 127 command not found, shebang is #!/usr/bin/env python3, and if I do exec('echo $PATH') it shows /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
I need to execute the script from php or from any user interface because the user needs to upload a file and then the script executes and returns the file modified. I need that a dozen of users have access to do this without having to install an execute a python script locally.
Output of ls -l /usr/bin | grep python
lrwxrwxrwx. 1 root root 26 Jan 25 2017 dh_pypy -> ../share/dh-python/dh_pypy
-rwxr-xr-x. 1 root root 1056 Jan 24 2017 dh_python2
lrwxrwxrwx. 1 root root 29 Jan 25 2017 dh_python3 -> ../share/dh-python/dh_python3
lrwxrwxrwx. 1 root root 23 Sep 26 2018 pdb2.7 -> ../lib/python2.7/pdb.py
lrwxrwxrwx. 1 root root 23 Sep 27 2018 pdb3.5 -> ../lib/python3.5/pdb.py
lrwxrwxrwx. 1 root root 31 Jan 20 2017 py3versions -> ../share/python3/py3versions.py
lrwxrwxrwx. 1 root root 26 Jan 25 2017 pybuild -> ../share/dh-python/pybuild
lrwxrwxrwx. 1 root root 9 Jan 24 2017 python -> python2.7
lrwxrwxrwx. 1 root root 9 Jan 24 2017 python2 -> python2.7
-rwxr-xr-x. 1 root root 3779512 Sep 26 2018 python2.7
lrwxrwxrwx. 1 root root 9 Jan 20 2017 python3 -> python3.5
lrwxrwxrwx. 1 root root 16 Jan 20 2017 python3-config -> python3.5-config
-rwxrwxrwx. 2 www-data www-data 4751184 Sep 27 2018 python3.5
lrwxrwxrwx. 1 root root 33 Sep 27 2018 python3.5-config -> x86_64-linux-gnu-python3.5-config
-rwxrwxrwx. 2 www-data www-data 4751184 Sep 27 2018 python3.5m
lrwxrwxrwx. 1 root root 34 Sep 27 2018 python3.5m-config -> x86_64-linux-gnu-python3.5m-config
lrwxrwxrwx. 1 root root 10 Jan 20 2017 python3m -> python3.5m
lrwxrwxrwx. 1 root root 17 Jan 20 2017 python3m-config -> python3.5m-config
lrwxrwxrwx. 1 root root 29 Jan 24 2017 pyversions -> ../share/python/pyversions.py
lrwxrwxrwx. 1 root root 33 Jan 20 2017 x86_64-linux-gnu-python3-config -> x86_64-linux-gnu-python3.5-config
lrwxrwxrwx. 1 root root 34 Sep 27 2018 x86_64-linux-gnu-python3.5-config -> x86_64-linux-gnu-python3.5m-config
-rwxr-xr-x. 1 root root 3229 Sep 27 2018 x86_64-linux-gnu-python3.5m-config
lrwxrwxrwx. 1 root root 34 Jan 20 2017 x86_64-linux-gnu-python3m-config -> x86_64-linux-gnu-python3.5m-config

I am able to read a file but unable to write it

I was following this video https://www.youtube.com/watch?v=gC8sLGB8SSM&index=77&list=PL442FA2C127377F07 . I am using fedora. I am able to read a file using this code:
$fileHandle = fopen('test.txt', 'r') or die('Unable to open test.txt');
echo fread($fileHandle, filesize('test.txt'));
But when I change 'r' to 'w', it dies and prints 'Unable to open test.txt'.
To check that I have permissions to read and write to a file, I typed this on terminal, ls -l /var/www/html. It showed:
total 8
-rwxr-xr-x. 1 Hemil apache 131 Jul 6 11:09 index.php
-rw-rw-r--. 1 Hemil Hemil 12 Jul 6 11:09 test.txt
I noticed that apache did not have the permission to read and write to a file, I did this: sudo chown Hemil:apache /var/www/html. But again when i checked the permissions, it prints the same as above.
EDIT: I forgot to add that I am not on a server. I am on localhost.
EDIT: On #Nic3500 's recommendation, i add the following:
ls -al /var:
total 108
drwxr-xr-x. 23 root root 4096 Apr 25 12:09 .
dr-xr-xr-x. 18 root root 4096 Jul 7 08:17 ..
drwxr-xr-x. 2 root root 4096 Apr 25 12:06 account
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 adm
drwxr-xr-x. 17 root root 4096 Jul 5 10:21 cache
drwxr-xr-x. 2 root root 4096 May 31 10:46 crash
drwxr-xr-x. 3 root root 4096 Apr 25 12:06 db
drwxr-xr-x. 3 root root 4096 Apr 25 12:06 empty
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 ftp
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 games
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 gopher
drwxr-xr-x. 3 root root 4096 Jun 15 03:23 kerberos
drwxr-xr-x. 59 root root 4096 Jul 5 11:55 lib
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 local
lrwxrwxrwx. 1 root root 11 Apr 25 12:03 lock -> ../run/lock
drwxr-xr-x. 18 root root 4096 Jul 5 11:52 log
drwx------. 2 root root 16384 Jul 4 22:54 lost+found
lrwxrwxrwx. 1 root root 10 Feb 7 15:11 mail -> spool/mail
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 nis
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 opt
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 preserve
lrwxrwxrwx. 1 root root 6 Apr 25 12:03 run -> ../run
drwxr-xr-x. 11 root root 4096 Apr 25 12:06 spool
drwxrwxrwt. 16 root root 4096 Jul 7 18:26 tmp
-rw-rw-r--. 1 root root 63 Apr 25 12:09 .updated
drwxr-xr-x. 4 root root 4096 May 1 14:24 www
drwxr-xr-x. 2 root root 4096 Feb 7 15:11 yp
ls -al /var/www
drwxr-xr-x. 4 root root 4096 May 1 14:24 .
drwxr-xr-x. 23 root root 4096 Apr 25 12:09 ..
drwxr-xr-x. 2 root root 4096 May 1 14:24 cgi-bin
drwxr-xr-x. 2 Hemil apache 4096 Jul 6 16:17 html
ls -al /var/www/html
drwxr-xr-x. 2 Hemil apache 4096 Jul 6 16:17 .
drwxr-xr-x. 4 root root 4096 May 1 14:24 ..
-rwxr-xr-x. 1 Hemil apache 102 Jul 7 16:55 index.php
-rw-rw-rw-. 1 Hemil apache 12 Jul 6 11:09 test.txt

php7.1-mbstring won't be loaded even though it's installed

For some reason, I can install pretty much any PHP extension, except for mbstring. I have installed php7.1.14 via sudo apt-get install php7.1 and then installed all my required extensions with sudo apt-get install php7.1-mysql php7.1-json... etc. I did the same for php7.1-mbstring but for some reason it won't get loaded:
forge#staging:~/test$ php -m
[PHP Modules]
Core
ctype
date
dom
fileinfo
filter
hash
iconv
json
libxml
openssl
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
[Zend Modules]
I've already tried adding extension=mbstring and extension=mbstring.so to my /etc/php/7.1/fpm/php.ini and /etc/php/7.1/cli/php.ini but no succes. mbstring.ini also exists in /etc/php/7.1/mods-available:
forge#staging:~/test$ ls -l /etc/php/7.1/mods-available/
total 200
-rw-r--r-- 1 root root 72 Feb 18 2017 bcmath.ini
-rw-r--r-- 1 root root 66 Feb 9 10:41 bz2.ini
-rw-r--r-- 1 root root 74 Feb 18 2017 calendar.ini
-rw-r--r-- 1 root root 71 Feb 18 2017 ctype.ini
-rw-r--r-- 1 root root 68 Feb 18 2017 curl.ini
-rw-r--r-- 1 root root 66 Feb 9 10:41 dba.ini
-rw-r--r-- 1 root root 66 Feb 18 2017 dom.ini
-rw-r--r-- 1 root root 70 Feb 18 2017 exif.ini
-rw-r--r-- 1 root root 74 Feb 18 2017 fileinfo.ini
-rw-r--r-- 1 root root 69 Feb 18 2017 ftp.ini
-rw-r--r-- 1 root root 64 Feb 18 2017 gd.ini
-rw-r--r-- 1 root root 73 Feb 18 2017 gettext.ini
-rw-r--r-- 1 root root 66 Feb 9 10:41 gmp.ini
-rw-r--r-- 1 root root 71 Feb 18 2017 iconv.ini
-rw-r--r-- 1 root root 364 Dec 19 2016 igbinary.ini
-rw-r--r-- 1 root root 68 Feb 18 2017 imap.ini
-rw-r--r-- 1 root root 68 Feb 18 2017 intl.ini
-rw-r--r-- 1 root root 68 Feb 18 2017 json.ini
-rw-r--r-- 1 root root 68 Feb 9 10:41 ldap.ini
-rw-r--r-- 1 root root 76 Feb 18 2017 mbstring.ini
-rw-r--r-- 1 root root 72 Feb 18 2017 mcrypt.ini
-rw-r--r-- 1 root root 176 Feb 12 2017 memcached.ini
-rw-r--r-- 1 root root 74 Dec 7 2016 msgpack.ini
-rw-r--r-- 1 root root 71 Feb 18 2017 mysqli.ini
-rw-r--r-- 1 root root 72 Feb 18 2017 mysqlnd.ini
-rw-r--r-- 1 root root 79 Feb 18 2017 opcache.ini
-rw-r--r-- 1 root root 69 Feb 18 2017 pdo.ini
-rw-r--r-- 1 root root 74 Feb 18 2017 pdo_mysql.ini
-rw-r--r-- 1 root root 74 Feb 18 2017 pdo_pgsql.ini
-rw-r--r-- 1 root root 77 Feb 18 2017 pdo_sqlite.ini
-rw-r--r-- 1 root root 70 Feb 18 2017 pgsql.ini
-rw-r--r-- 1 root root 70 Feb 18 2017 phar.ini
-rw-r--r-- 1 root root 71 Feb 18 2017 posix.ini
-rw-r--r-- 1 root root 76 Feb 18 2017 readline.ini
-rw-r--r-- 1 root root 71 Feb 18 2017 shmop.ini
-rw-r--r-- 1 root root 72 Feb 18 2017 simplexml.ini
-rw-r--r-- 1 root root 68 Feb 18 2017 soap.ini
-rw-r--r-- 1 root root 73 Feb 18 2017 sockets.ini
-rw-r--r-- 1 root root 74 Feb 18 2017 sqlite3.ini
-rw-r--r-- 1 root root 73 Feb 18 2017 sysvmsg.ini
-rw-r--r-- 1 root root 73 Feb 18 2017 sysvsem.ini
-rw-r--r-- 1 root root 73 Feb 18 2017 sysvshm.ini
-rw-r--r-- 1 root root 68 Feb 9 10:41 tidy.ini
-rw-r--r-- 1 root root 75 Feb 18 2017 tokenizer.ini
-rw-r--r-- 1 root root 67 Feb 18 2017 wddx.ini
-rw-r--r-- 1 root root 66 Feb 18 2017 xml.ini
-rw-r--r-- 1 root root 72 Feb 18 2017 xmlreader.ini
-rw-r--r-- 1 root root 72 Feb 18 2017 xmlwriter.ini
-rw-r--r-- 1 root root 66 Feb 18 2017 xsl.ini
-rw-r--r-- 1 root root 66 Feb 18 2017 zip.ini
What could be the issue here?!

My htaccess is not working properly

Here is my .htaccess content:
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /mtd/index.php?page=$1 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /mtd/index.php?page=$1&destination=$2&package=$3 [L]
The following link works correctly:
http://localhost/mtd/our-company.html [Rewrite Rule 1]
The page successfully passes the $_GET values index.php?page=page-name
Yet, the following link is Showing 404 Error
http://localhost/mtd/tours/nepal/index.html [Rewrite Rule 2]
This URL should pass $_GET values like:
index.php?page=tours&destination=nepal&package=index
This was working on Windows 8.1 with XAMPP Server and Remote Server with cPanel, but after I shifted to Ubuntu (Latest) with LAMP Stack, it is no longer working.
after executing command ls -al
root#Neeraz:/var/www/mtd# ls -al
total 1740
drwxr-xr-x 15 neeraz root 4096 Jan 28 13:54 .
drwxrwxrwx 70 root root 4096 Jan 30 14:40 ..
drwxrwxrwx 10 root root 4096 Dec 17 15:56 admin
-rwxrwxrwx 1 root root 15992 Oct 23 12:25 ahome.html
-rwxrwxrwx 1 root root 3226 Nov 24 14:23 booknow.php
drwxrwxrwx 3 root root 4096 Jan 6 22:45 css
-rwxrwxrwx 1 root root 621280 Aug 15 15:56 delight-mockup.jpg
-rwxrwxrwx 1 root root 2531 Dec 10 17:47 find.php
-rwxrwxrwx 1 root root 1544 Nov 24 15:20 HandleTour.php
-rwxrwxrwx 1 root root 346 Feb 3 10:28 .htaccess
drwxrwxrwx 3 root root 4096 Jan 5 15:54 images
drwxrwxrwx 2 root root 4096 Oct 24 18:59 img
-rwxrwxrwx 1 root root 12098 Dec 16 14:00 index1.php
-rwxrwxrwx 1 root root 12372 Jan 29 06:20 index.php
drwxrwxrwx 2 root root 4096 Dec 23 15:15 jquery
drwxrwxrwx 3 root root 4096 Jan 28 13:58 Libs
-rwxrwxrwx 1 root root 13156 Jan 28 14:13 MainPage.php
-rwxrwxrwx 1 root root 1211 Jan 5 22:29 menu0.php
-rw-rw-r-- 1 neeraz neeraz 642 Jan 28 13:57 menulayout.php
-rwxrwxrwx 1 root root 476327 Aug 16 16:08 mt-delight1.jpg
-rwxrwxrwx 1 root root 474429 Aug 16 16:07 mt-delight.jpg
drwxrwxr-x 3 neeraz neeraz 4096 Jan 28 11:35 nbproject
-rwxrwxrwx 1 root root 9892 Sep 19 10:46 nepal.html
drwxrwxrwx 2 root root 4096 Jan 7 00:27 _notes
-rwxrwxrwx 1 root root 684 Oct 25 09:00 PagesLoader.php
-rwxrwxrwx 1 root root 1189 Nov 21 00:00 pie.php
drwxrwxrwx 2 root root 4096 Oct 29 18:16 SpryAssets
-rwxrwxrwx 1 root root 45 Dec 17 16:02 test.php
drwxrwxrwx 2 root root 4096 Dec 29 14:19 TourGallery
-rwxrwxrwx 1 root root 9266 Sep 5 13:29 tour.html
-rwxrwxrwx 1 root root 18333 Jan 5 14:05 tours.php
drwxrwxrwx 2 root root 4096 Oct 27 16:18 TrekkingMap
drwxrwxrwx 3 root root 4096 Dec 29 14:19 uploaded
drwxrwxrwx 2 root root 4096 Dec 15 19:39 uploads
root#Neeraz:/var/www/mtd#
You need correct RewriteBase and make to place this rule in /mtd/.htaccess:
RewriteEngine On
RewriteBase /mtd/
RewriteRule ^([^/]+)/([^/]+)/([^/.]+)\.html$ index.php?page=$1&destination=$2&package=$3 [L,QSA]
RewriteRule ^([^/.]+)\.html$ index.php?page=$1 [L,QSA]

Categories