Apache PHP and Rails in subdirectory - php

I need to setup rails in subdirectory with phusion passenger php being in root directory. I got it working but the rails static files are 404.
The apache config is below:
<DirectoryMatch "^/home/folder_name/public/invite/*">
SetEnv GEM_HOME /home/folder_name/.gems
PassengerEnabled On
PassengerAppRoot /home/folder_name/public/invite
RailsEnv production
PassengerBaseURI /invite
</DirectoryMatch>
<DirectoryMatch "^/home/folder_name/public/invite/public/*">
Allow from all
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
#Require all granted
</DirectoryMatch>
Anybody have an idea?

I'm not familiar with DirectoryMatch but it takes a regular expression. which would look more like this:
<DirectoryMatch "^/home/folder_name/public/invite/public/.*">

Related

Laravel project hosted with Apache virtuahost different port and into a subfolder

I have a windows server (2012), with an Apache 2.4 hosting some php apps.
The default PHP version is a 7.2 version.
I want to host on it a Laravel project, using PHP 8.1.
So I specified a new virtualhost with a different port number.
But what I really want is this :
my-domain.example.com/my-laravel-project => redirect to my-domaine.example.com:8001
So I set up a ProxyPass and ProxyPassReverse.
But I can't make it work.
I don't have any other choice right now (no subdomain possible), no global upgrade to PHP8.1 (too risky).
This is the configuration :
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass "/my-laravel-app" "http://127.0.0.1:8001/my-laravel-app"
ProxyPassReverse "/my-laravel-app" "http://127.0.0.1:8001/my-laravel-app"
</VirtualHost>
<VirtualHost *:8001>
DocumentRoot "E:/PHP8.1Projects/"
Alias "/my-laravel-app" "E:/PHP8.1Projects/my-laravel-app/public"
FcgidInitialEnv PHPRC "E:\\php8.1"
<Files ~ "\.php$">
Options Indexes FollowSymLinks ExecCGI
AddHandler fcgid-script .php
FcgidWrapper "E:\\php8.1\\php-cgi.exe" .php
</Files>
DirectoryIndex index.php
AddDefaultCharset UTF-8
</VirtualHost>
I already spent hours, I tried multiple things but I always got a problem.
Thanks for any help
Just download Devserver and the Laravel Module.
With the Laravel Manager you can can install several Laravel versions and create a specific environment (PHP version, Apache version, MySQL version, modules...) for each one.

Updated php now having issues with phpmyadmin

We have an amazon linux server. It was running php 5.3 we wanted to update to 5.6 to see if it would solve an issue with a plugin on our wordpress installation. I installed php 5.6 and am now having issues getting back into phpMyAdmin and our wordpress site which I think isn't loading because of the database problem.
When I go to /phpMyAdmin I get Forbidden
You don't have permission to access /phpMyAdmin on this server.
I've found a few threads on here suggesting things such as placing the following in my phpMyAdmin.conf file:
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
#Require ip 127.0.0.1
#Require ip ::1
Require all granted
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
I have tried this, also I added Allow from 'my static ip'. I have also restarted httpd still nothing. The other thing that is happening is I'm getting the Amazon Linux AMI Test Page when I go to what should be our wordpress website, I'm not sure if these are the same problem but I assume it is related.
The website in question is calendar.childmags.com.au
I think you have to off the strict mode. For the temporary solution you can use
For all DB:_
SET ##global.sql_mode=''
For current DB:-
SET sql_mode = ''

How to get the REMOTE_USER variable with PHP under linux [duplicate]

Previously I used the IIS server as PHP server. Currently, it is the apache.
On IIS I could access to the variable $_SERVER ['REMOTE_USER'] which returns the username and domain (eg domain\user) but after installing XAMPP this variable is not available.
What I should do to get this variable get again?
My app is on local network with no-internet connection
Finally got it to works! :D
Download the module from here https://www.apachehaus.net/modules/mod_authnz_sspi/ (x86 for 32 bit and x64 for 64 bit apache)
Copy the mod_authnz_sspi.so from Apache24\modules folder and place it in the modules folder of your Apache folder on your webserver
Under the httpd.conf file (Config file for your apache) place this line of code. Try to load this as the last module:
LoadModule authnz_sspi_module modules/mod_authnz_sspi.so
Make sure that the following modules are uncommented
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_core_module modules/mod_authz_core.so
PS: both the above modules are required for this to work.
Place the following code in your httpd.conf file
<Directory "path/to/your/htcdocs/folder">
Options None
AllowOverride All
Order allow,deny
Allow from all
#AuthName "SSPI Protected Place"
AuthType SSPI
SSPIAuth On
SSPIAuthoritative On
SSPIOfferBasic On
SSPIOmitDomain On
Require valid-user
</Directory>
Restart your apache servive and hopefully it should restart without any issues.
Now in order to recognise the user , use the following code on a php page
echo $_SERVER['PHP_AUTH_USER'];
That's all.
I'm using:
XAMPP Control Panel 3.2.1
APACHE 2.4
<Directory "path/to/your/htcdocs/folder">
Options None
AllowOverride All
Order allow,deny
Allow from all
#AuthName "SSPI Protected Place"
AuthType SSPI
SSPIAuth On
SSPIAuthoritative On
SSPIOfferBasic On
SSPIOmitDomain On
Require valid-user
</Directory>
If you use ModRewrite or other I suggest you to keep
Options Indexes FollowSymLinks Includes ExecCGI
otherwise you'll get an error like
[rewrite:error]: Options FollowSymLinks and SymLinksIfOwnerMatch are both off, so the RewriteRule directive is also forbidden due to its similar ability to circumvent directory restrictions
You can only access the remote user if Apache has actually authenticated the user, check the apache auth howto.
I battled with this for a long time, it turned out that I had to install VC redistributable to make it work.

php files in phpmyadmin folder not executable

i have phpmyadmin on my amazon server installed ( in /usr/share/phpMyAdmin folder)
my phpMyAdmin.conf seems correct
i was able to access it from my browser before by typing https://xxx.xxx.xxx.xxx/phpmyadmin
After i restored my amazon instance from a snapshot , i can not access it anymore
i get this error :
Not Found
The requested URL /phpMyAdmin/navigation.php< was not found on this server.
Then i noticed Apache doesn't serve php files in that directory at all
Even when i put a minimal php file in that folder for test and point to it in browser, it will return it as a text file and i can see php codes in it!
I searched about it and found many similar issues, but none of them helped me
can anyone help me to find source of this issue?
ps: i have several virtual servers on my server and they are working fine.
here is a part of my phpMyAdmin.conf :
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
<Directory /usr/share/phpMyAdmin/>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
#Deny from All
Allow from all
Allow from ::1
</IfModule>
</Directory>
use this to run files inside htdocs localhost/navigation.php

How do fix apache error "not within configured docroot" under Ubuntu

Greetings experts and gurus, I am looking for some help with an apache php configuration problem.
I have been running several websites from an apache2 setup on an ubuntu server for some time now without problems using the line NameVirtualHost * in my etc/apache2/conf.d/virtual.conf file. I recently updated the server version to the latest lts version and I am now unable to run php files.
I am running all my sites for the location "/home/www/[site-name]/htdocs" and I have setup and enabled all my sites in /etc/apache2/sites-available. I have also disabled the default site.
for each sites file I have specified the following:
# Indexes + Directory Root.
# DirectoryIndex index.html index.htm index.php
DocumentRoot /home/www/[site-name]/htdocs/
# CGI Directory
ScriptAlias /cgi-bin/ /home/www/[site-name]/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>
# Logfiles
ErrorLog /home/www/[site-name]/logs/error.log
CustomLog /home/www/[site-name]/logs/access.log combined
I restart apache and enter the url for a php test page on my server and I am met with an "Internal Server Error". When I check the error log I get:
Script "/home/www/[site-name]/htdocs/test.php" resolving to "/home/www/[site-name]/htdocs/test.php" not within configured docroot.
For some reason when looking into the error, suphp came up a lot. According to this link:
Don't be fooled into thiking this has anything to do with the Apche virtual host document root, this is actually another setting in the suphp config file. Including the paths which contained the RoundCube scripts fixed this one. For example:
docroot=/var/www:/usr/share/roundcube:/var/lib/roundcube:${HOME}/public_html
You need to edit your /etc/suphp/suphp.conf file and change the docroot to whatever is appropriate.
It looks you missed the virtual hosts configuration for every site name:
<VirtualHost IP:80>
ServerName yourdomainname
ServerAlias www.yourdomainname
DocumentRoot /home/www/[site-name]/htdocs/
ScriptAlias /cgi-bin/ /home/www/[site-name]/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>
ErrorLog /home/www/[site-name]/logs/yourdomainname.ua-error.log
CustomLog /home/www/[site-name]/logs/yourdomainname-access.log combined
</VirtualHost>
<Directory "/home/www/[site-name]/htdocs/">
Options FollowSymLinks
AllowOverride None
Order allow,deny
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
Thanks for all the help, I got there in the end. It seems that upgrading to Ubuntu 10.04 turned on suPHP. It has ended up being a good thing as the reason why I was getting errors was down to file management in my htdocs getting sloppy.
To fix my issues I had to do several things:
First I turned on suphp error messages in /etc/apache2/sites-available/[site-name]. This gave me the true error, which told me that some of my pages had the wrong permissions. I then set all my folder permissions in www to 755 and the files to 644. I also had to lower the min_uid and min_gid fileds in suphp.conf to 33.

Categories