Can't access php files on local apache server - php

I have setup a local apache2 server, and it works and display correctly for any html files located at home/user/website, but it gives me an 404 error when i try to access php files.
i.e:
~/website ls
hello.php index.html test2.html test.php
127.0.1.1/index.html and 127.0.1.1/test2.html loads normally but 127.0.1.1/hello.php and 127.0.1.1/test.php gives me a 404
Theres no trace of error on the error.log file though there's a 404 GET on the access.log file:
127.0.0.1 - - [25/Sep/2014:00:35:01 -0300] "GET /hello.php HTTP/1.1" 404 273 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36"
I have this on the apache2.conf, not sure if it's correct:
<Directory /home/user/website>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
I configured apache2 to run with hhvm trough the scripts that comes with hhvm.
My system is ubuntu 14.04
Thanks.

I found this answer on: https://github.com/facebook/hhvm/issues/3472
I had to set hhvm.server.fix_path_info = true in /etc/hhvm/server.ini, now it works.

Related

Error proxying PHP APACHE with Nginx Proxy Manager in Docker

I am new to posting here, so sorry if I don't make it how it should be, and I could not decide what to make the title.
So, I am new to Nginx and Docker, I am wanting to use Nginx Proxy Manager to proxy all my websites that are hosted on 'php:8.1-apache' images for now.
I am proxying a website from a docker container (Named 'ApacheDefault') running a custom image of 'php:8.1-apache' through Nginx Proxy Manager (Assets Caching disabled, Block Common Exploits disabled), and I am having issues when going through the proxy that does not appear when reaching straight to the website.
When reaching through the proxy, it randomly works and then stops working.
On the root of my website, I got /test.php which is just the phpinfo function, /index.php which handle the routing, some assets in the /assets/ folder, and a /.htaccess with
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
Using 'my.domain' as an example, my domain is using Cloudflare DNS.
When reaching my.domain/test.php, I either get the regular phpinfo page or a page with this:
Warning: require_once(assets/php/config.php): Failed to open stream: No such file or directory in /var/www/html/assets/php/content.php on line 2
Fatal error: Uncaught Error: Failed opening required 'assets/php/config.php' (include_path='.:/usr/local/lib/php') in /var/www/html/assets/php/content.php:2 Stack trace: #0 /var/www/html/index.php(19): include() #1 /var/www/html/assets/php/classes/Route.php(37): {closure}('test.php') #2 /var/www/html/assets/php/classes/Router.php(40): Route->call() #3 /var/www/html/index.php(23): Router->run() #4 {main} thrown in /var/www/html/assets/php/content.php on line 2
^ "/var/www/html/assets/php/content.php" is not a file that does not exists and "assets/php/config.php" is never called in my code
The Nginx Proxy Manager log shows this (The first line landed on the error page, the second showed the regular phpinfo page):
[07/Oct/2022:16:20:22 +0000] - 200 200 - GET https my.domain "/test.php" [Client X.X.X.X] [Length 339] [Gzip -] [Sent-to ApacheDefault] "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" "-"
[07/Oct/2022:16:20:23 +0000] - 200 200 - GET https my.domain "/test.php" [Client X.X.X.X] [Length 23591] [Gzip -] [Sent-to ApacheDefault] "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" "-"
For some reason, the Length changes, and I can't get to understand why.
I tried:
Disabling Nginx caching from "Custom Nginx Configuration".
Disabling Nginx GZip (from "Custom Nginx Configuration") but could not manage to do it.
Enabling Cloudflare's Development Mode.
Thank you to anyone that can bring me the slightest help!
EDIT:
After testing a bit more I noticed something. When defining NPM (Nginx Proxy Manager)'s "Forward Hostname / IP" to my server raw IP or the website docker container's IP, the error does not appear anymore. The error only appears when using the docker container name as hostname instead of its IP. But I would like to rely on the hostname and not the IP because the IP can change, and seeing hostname is easier.
RE EDIT:
After removing my initial network connecting NPM & The Website Container and re creating it, it seems like it fixed the issue.
No idea why but i dont care, its fixed !

httpd / roundcube is throwing 500's with zero errors printed to the client or produced in the logs

I am migrating mail servers from OVH/Centos7 to AWS/Amazon Linux; part of my setup uses roundcube webmail.
I have copied all of my config and supporting files from one instance to the other, however can not seem to make the webmail app load as expected. Anything and everything produces a 500 with no useful errors displayed anywhere.
All apps and subdirectories are owned by apache:apache
With the following error config in php.ini
display_errors = On
error_reporting = E_ALL
log_errors = On
This is the ONLY log entry created when navigating to my URL:
w.x.y.z - - [27/Dec/2018:03:56:03 +0000] "GET / HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
The log entry clearly shows the 500, but produces no errors. In addition, the error log file within the roundcube directory is also empty.
The response to the client is empty, just a 500.
$curl https://mail.example.com/
Header is 500:
$curl https://mail.example.com/ --head
HTTP/1.1 500 Internal Server Error
....
If I cd to the roundcube directory and try to evaluate the index, it returns nothing:
$cd /path/to/roundcube
$php index.php
$
I have tried to disable every single roundcube plugin, in config/config.inc.php
$config['plugins'] = array();
Every single other app and web page works, after the transplant; roundcube is the only thing which is throwing 500's and not producing any error messages...
syslog is empty of relevant messages.
What can I possibly do to further investigate why this might be failing?

can't open web page on my virtual lamp server ubuntu 12.04

i can't open one php script on my virtual ubuntu 12.04 lamp server, i tried at an online host and it works fine but at home didn't work.
what i already did:
i intall php 5.4 like the online host
change permisions on folder
change user folder
install php 7 (but the scripts tell php 5.4-5.5)
and i get this error page when i try to open: The requested URL /loja/login was not found on this server.
and the log apache tell :
[client 192.168.0.10] File does not exist: /var/www/script/login
"GET /loja/ HTTP/1.1" 307 769 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
192.168.0.10 - - [02/Apr/2017:00:12:23 -0300] "GET /loja/login HTTP/1.1" 404 502 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36""
what is wrong on my lamp server? onlines hosts works very well.
the script: https://mega.nz/#!dpskSCDS!vmlxWXVjByV67wv41DO8MqDMPgfjBpxxj_p7uoxmfjQ
Hi please add your php files on your htdocs folder it's /opt/lampp/htdocs
also do this
This will change the ownership of the /opt/lampp/htdocs/ to you:
sudo chown username:groupname /opt/lampp/htdocs
Example : (My username is test and my group name is also test)
sudo chown test:test /opt/lampp htdocs
This will change the folder's permissions to be read, write and executed by you:
sudo chmod 777 /opt/lampp/htdocs

Why error 403 when using alias and not redirect directives in apache2 server config?

I am new to apache and webservers in general but I have a problem with accessing phps with alias URLs from the web. This is what my config looks like:
ServerAdmin something#gmail.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
AliasMatch "^/index$" "/"
AliasMatch "^/about$" "/about.php"
AliasMatch "^/editor$" "/editor.php"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
The php files that I want to display are located in DocumentRoot folder, and I've made sure root and all its subdirectories and files have permissions 755. What confuses me is that instead of Alias I use Redirect it works fine, except that the browser URL field shows .php which is not desirable. So how come permission is not granted with aliasing but with redirecting? Below is a log entry of attempting to access with site conf file as written above:
127.0.0.1 - - [27/Jan/2017:04:11:55 +0100] "GET /about HTTP/1.1" 403 422 "http://example.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"
Any help is appreciated, Cheers
You should use the full path for the target:
AliasMatch "^/index$" "/var/www/example.com/"
AliasMatch "^/about$" "/var/www/example.com/about.php"
AliasMatch "^/editor$" "/var/www/example.com/editor.php"
In this case, the simpler Alias is also valid:
Alias "/index" "/var/www/example.com/"
etc.
References
https://httpd.apache.org/docs/2.4/mod/mod_alias.html#aliasmatch
AliasMatch and RegEx

Nothing but 'run(); ' when browsing to my local project, how do I fix this?

I just added a new project. I made a mistake in the projectname.conf file in sites-available from apache2, which led me to reinstalling apache2.
After reinstalling and re-enabling my projects all I get on every page of every project is
..
<body>
run();
</body>
..
I've run a composer update, restarted the service, restarted my pc, checked my config files, tried disabling the new project.
There is nothing in my error log, and this is my access.log:
127.0.0.1 - - [15/May/2015:01:40:47 +0200] "GET / HTTP/1.1" 304 181 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0"
Maybe I'm forgetting something for the apache2 reinstall? I don't think I did anything different as to last time I installed it.
Looks like you haven't setup PHP correctly.
Take a look at this great guide, maybe you're forgetting to link the PHP config to Apache2.

Categories