php-fpm + bindfs not working - php

I'm trying to setup my local web server using vagrant. My vagrant shared folder is in my home folder (~/home/vagrant/www) and I want to use bindfs to mount this folder inside /var/www.
These are the specs of my virtual machine:
Apache/2.4.23 (Ubuntu)
PHP 7.0.12
Ubuntu 14.04
I am using php-fpm to execute php scripts but after using bindfs, my site will always return File not found.
Also here is my virtualhost configuration:
<VirtualHost *:80>
ServerName project1.dev
## Vhost docroot
DocumentRoot "/var/www/project1/public"
## Directories, there should at least be a declaration for /var/www/project1/public
<Directory "/var/www/project1/public">
Options Indexes FollowSymlinks MultiViews
AllowOverride All
Require all granted
<FilesMatch "\.php$">
Require all granted
SetHandler proxy:fcgi://127.0.0.1:9000
</FilesMatch>
</Directory>
## Logging
ErrorLog "/var/log/apache2/av_anhk5lpgjldb_error.log"
ServerSignature Off
CustomLog "/var/log/apache2/av_anhk5lpgjldb_access.log" combined
## Server aliases
ServerAlias www.project1.dev
## SetEnv/SetEnvIf for environment variables
SetEnv APP_ENV dev
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
## Custom fragment
</VirtualHost>
Anyone can help me?

I manage to successfully run php-fpm + bindfs in my virtual machine. I just made sure that user who is running php-fpm and apache are the one I set in my bindfs command. My apache is run by www-user so I change my command to sudo bindfs -o perms=0755,mirror-only=www-user,force-group=www-data,force-user=www-user /home/vagrant/www /var/www and made sure that apache is also run by www-user.

Related

How to run two versions of PHP for two projects on same apache server

I have 2 different virtual hosts on my apache server. One of them needs php7.x and another need php5.x.
Is it possible to use project-specific PHP versions?
I have tried the following,
Running two PHP versions on the same server
but my apache server crashed saying there's some syntactical error in one of the fpm's config file.
Also I cant follow this solution since It advices to uninstall apache and start over again and I can't do that on a live server.
Is there any way to do this without uninstalling the apache server.
Thank you for your suggestions.
for windows on file httpd-vhosta.conf
<VirtualHost *:80>
DocumentRoot "d:/server/htdocs/"
ServerName localhost
ServerAlias www.localhost
<Directory "d:/server/htdocs/">
Require all granted
<Files ~ "\.php$">
AddHandler fcgid-script .php
#FcgidWrapper "d:/server/php/php-5.6.40-Win32-VC11-x64/php-cgi.exe" .php
FcgidWrapper "d:/server/php/php-7.1.24-Win32-VC14-x64/php-cgi.exe" .php
Options +ExecCGI
</Files>
</Directory>
ErrorLog "D:/server/apache/logs/error-localhost.log"
SetEnv APP_ON_LOCAL 1
</VirtualHost>

Permission denied when trying to access file on Apache

I try to run very basic php app using apache and docker compose and have a problem with apache settings. When I try to access any static file in subdirectory I get lack of permissions. PHP calls seem to work fine.
So:
when I try to request localhost/LICENSE.txt I get the license.
when I try to access localhost/test.php or localhost/app/test.php it works fine
when I try to access localhost/app/test.html I get Forbiddenin
the browser andclient denied by server configuration:
/var/www/localhost/htdocs/src/app/test.html` in error log
Of course files I try to request are in the right locations.
Here's apache version I am trying to run:
/var/www/localhost/htdocs # httpd -v
Server version: Apache/2.4.33 (Unix)
Server built: Mar 27 2018 11:32:10
Here's my host config:
<VirtualHost *:80>
ServerAdmin test#example.com
DocumentRoot /var/www/localhost/htdocs/src
ServerName schmidt.local
<Directory "/var/www/localhost/htdocs/src">
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
RewriteEngine On
</Directory>
<LocationMatch "^/(.*\.php(/.*)?)$">
ProxyPass fcgi://php-fpm:7000/var/www/localhost/htdocs/src/$1
</LocationMatch>
</VirtualHost>
So as you can see I already have request instead of allow as suggested here.

Setting document root for Laravel project on Apache virtual host

I inherited a php/Laravel app that was running on an Apache server that I don't have access to. My task is to get it running on another Apache server. I'm pretty good with php but relatively new to Laravel and very new to Apache configuration.
I have figured out how to get the Laravel app running on Apache that is running on an Ubuntu VM (VirtualBox.) I can access the Laravel app in a browser on the Ubuntu VM via http://localhost. I can also access the Laravel app in a browser from the Internet via http://appname.com/public. However, if I just use http://appname.com, then I just get a folder listing of /var/www/appname.
I have tried several modifications to the /etc/apache2/available-sites/appname.conf file but haven't quite got it right yet, apparently. I have also read a number of posts around the nets about making modifications to various other config files including php config files and Apache config files. It seems like these other mods (while they may be workable) shouldn't be necessary.
Here is my current /etc/apache2/available-sites/appname.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName appname.com
ServiceAlias www.appname.com
DocumentRoot /var/www/appname/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Any advise is appreciated.
Bob
You need to allow the mod_rewrite in the apache server and allowSymLinks.
Source
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName appname.com
ServiceAlias www.appname.com
DocumentRoot /var/www/appname/public
<Directory "/var/www/appname/public">
Options FollowSymLinks
ReWriteEngine On
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
in the DocumentRoot Directory i would also allow MultiViews
<Directory "/var/www/appname/public">
Options FollowSymLinks MultiViews
ReWriteEngine On
</Directory>
You may need to also do
sudo a2enmod rewrite
to enable module rewrite.
Edit 1:
In my .conf files i got them with the quotes and they are working.
Did you enable the modudle rewrite?
Besides some options i also have the "/" folder with the next config.
<Directory "/">
Options FollowSymLinks
AllowOverride All
ReWriteEngine On
</Directory>
and here i'll write my full code of public directory
<Directory "/var/www/appname/public">
Options FollowSymLinks MultiViews
Order Allow,Deny
Allow from all
ReWriteEngine On
</Directory>
Try it and see if it works, after delete the options that you don't like to use.
Follow the steps and all will be good and easy,
1). Type following command in terminal
cd /etc/apache2/sites-available
2). Make a new config file
sudo cp 000-default.conf appname.dev.conf
3. Open the new config file and paste the following code
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin yourmail#example.com
ServerAlias appname.dev
DocumentRoot /var/www/html/appname/public
<Directory /var/www/html/appname/public>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
<FilesMatch \.php$>
#Change this "proxy:unix:/path/to/fpm.socket"
#if using a Unix socket
#SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
4). CTRL+x, then press y then press enter and run following command in terminal
sudo a2ensite appname.dev.conf
5). Type following command and edit the /etc/hosts file
sudo nano /etc/hosts
127.0.0.1 appname.dev
press CTRL x then press Enter and type following command
sudo service apache2 restart
6). Now your app will execute on appname.dev successfully.

Index of / with blank page output on server

I uploaded my PHP(codeigniter) project on server. But when I run it I get below window
Index of /
Name Last modified Size Description
Apache Server at 'ip address here' Port 80
project folder is in /var/www/
DocumentRoot is set in projectName.conf directory as /var/www/projectName
Make sure your site .conf points to the public folder and not the site root.
<VirtualHost *:80>
ServerName site.co.uk
DocumentRoot /var/www/site.co.uk/public
<Directory "/var/www/site.co.uk/">
Options -Indexes +FollowSymLinks
Order allow,deny
Allow from all
AllowOverride FileInfo All
Require all granted
</Directory>
</VirtualHost>
You have to make sure about 3 points for this issue
Need .htaccess file in /var/www/projectName/.htaccess which is provided by Codeigniter
Must have rewrite module enabled.
If you are using Ubuntu OS and apache2 then execute sudo a2enmod rewrite in your terminal to enable this.
Must allow override URL by .htaccess rule in apache.conf for /var/www folder.
If you are using Ubuntu OS and apache2 then edit file /etc/apache2/apache.conf and change AllowOverride none to AllowOverride All in block/section of <directory /var/www> and then restart apache by sudo service apache2 restart command.

Apache2 with web.py and php - php services not working

I have deployed my web.py application using apache2 and the configuration looks as follows.
<VirtualHost _default_ *:80>
ServerAdmin admin#project.com
DocumentRoot /var/www/html
ErrorLog /var/www/Engine/log/error.log
CustomLog /var/www/Engine/log/access.log combined
WSGIScriptAlias / /var/www/Engine/Engine.py
Alias /static /var/www/html
AddType text/html .py
WSGIDaemonProcess www-data threads=15
WSGIProcessGroup www-data
WSGIApplicationGroup %{GLOBAL}
</VirtualHost>
<Directory /var/www/html>
allow from all
</Directory>
Problem:
I have some php services hosted inside /var/www/html/apis . Those used to work before configuring with mod_wsgi, but when i request now, it says 404 error.
Question:
How to configure both Python and php services work together?
Try adding:
Alias /apis/ /var/www/html/apis/
Also see:
http://blog.dscpl.com.au/2014/09/hosting-php-web-applications-in.html

Categories