Share folders Docker - apache

I'm used to develop on vagrant but docker looks faster so I just tried it. This seems really good but I need to share the folders between my host and docker to easily update my code without recompiling docker.
I tried to add:
VOLUME /Users/ajouve/dev/test/test:/var/www/test
or
VOLUME /Users/ajouve/dev/test/test:/var/www/test:rw
in my dockerfile but the folders are nos sync
This is my complete dockfile
FROM ubuntu:12.04
MAINTAINER ajouve version: 0.1
RUN apt-get update && apt-get install -y apache2 && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN mkdir /var/www/test
VOLUME /Users/ajouve/dev/test/test:/var/www/test:rw
COPY test.conf /etc/apache2/sites-availables/
RUN ln -s /etc/apache2/sites-availables/test.conf /etc/apache2/sites-enabled/test.conf
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
EXPOSE 80
CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]
this is the test.conf
<VirtualHost *:80>
ServerName test.local
DocumentRoot /var/www/test
<Directory /var/www/test>
# enable the .htaccess rewrites
AllowOverride All
Order allow,deny
Allow from All
</Directory>
ErrorLog /var/log/apache2/test-error.log
CustomLog /var/log/apache2/test-access.log combined
</VirtualHost>
I have an empty folder when I'm trying to access to the server via a browser

You can bind the folder when you start your docker instance
with -v /src/dockerShared/:/usr/local/src
have a Look here for a example

Your host folder have to be owned by the same uid:gid of the folder inside the container.

Related

Symfony 3 / Apache - Post request gives Error 500

I have a Symfony 3 API and I'm trying to register a user but I have an error 500 when executing a POST request (GET request works). It's probably a problem with my Apache configuration because I don't have any errors in my logs files. A var_dump('ok') at the top of my function also give me error 500.
My Apache configuration:
<VirtualHost *:80>
ServerName subscription.api.local
ServerAlias www.subscription.api.local
DocumentRoot /var/www/subscription_backend/web
DirectoryIndex /app.php
<Directory /var/www/subscription_backend/web>
AllowOverride None
Order Allow,Deny
Allow from All
FallbackResource /app.php
</Directory>
<Directory /var/www/subscription_backend>
Options FollowSymlinks
</Directory>
<Directory /var/www/subscription_backend/web/bundles>
FallbackResource disabled
</Directory>
ErrorLog /var/log/subscription-error.log
CustomLog /var/log/subscription-access.log combined
</VirtualHost>
Line added in my hosts file:
127.0.0.1 subscription.api.local www.subscription.api.local
My projet is in ~/Projects/subscription_backend directory and I use a symbolic to /var/www/subscription_backend :
sudo ln -s ~/Projects/subscription_backend /var/www/subscription_backend
Permissions of "~/Projects/subscription_backend directory":
Permissions of "/var/www/subscription_backend directory":
lrwxrwxrwx 1 www-data www-data 55 avril 19 21:45 /var/www/subscription_backend -> /home/khan/Projects/subscription_backend/
What's wrong with my configuration ? Why GET request works but not POST ?
Thx
Finally, i solved the problem.
First,fix permissions https://symfony.com/doc/3.3/setup/file_permissions.html:
cd ~/Projects/subscription_backend
rm -rf var/cache/*
rm -rf var/logs/*
HTTPDUSER=$(ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data [n]ginx' | grep -v root | head -1 | cut -d\ -f1)
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX var
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX var
composer install
Then install memcache extension:
sudo apt-get install memcached
sudo apt-get install php-memcached
sudo apt-get install php-memcache
sudo service apache2 restart
Clear cache:
bin/console c:c
bin/console c:c --env=prod

Apache forbidden access with Docker

I build this image on docker-compose.yml
version: '2'
services:
webserver:
build: ./docker/webserver
image: image_name
ports:
- "80:80"
- "443:443"
volumes:
- /Users/user_name/Sites/site:/var/www/html
And have this commands on Dockerfile
FROM php:7-apache
RUN apt-get update -y && apt-get install -y libpng-dev && apt-get
install -y libcurl4-openssl-dev
RUN docker-php-ext-install pdo pdo_mysql gd curl
RUN a2enmod rewrite
RUN service apache2 restart
BUT I get
Forbidden
You don't have permission to access / on this server.
Apache/2.4.10 (Debian) Server at localhost Port 80
when I go to localhost.
I work with Mac.
I have used the docker files to other project and all worked great.
what am I missing?
Log response
Cannot serve directory /var/www/html/: No matching DirectoryIndex
(index.php,index.html) found, and server-generated directory index
forbidden by Options directive
Looks like apache is not finding an index page to serve. Ensure your volume mapping is correct (enter the image with docker exec and check contents of /var/www/html folder). If your files are there, ensure that you have an index.html or index.php file for apache to be served.
If you change to apache document root to something non-standard outside of /var/www you will need to grant access in your vhost:
DocumentRoot /workspace/my-project
<Directory /workspace/my-project>
Require all granted
</Directory>

403 error on XAMPP change document root

I have installed XAMPP on Linux Mint. Got it running OK, then I wanted to change the htdocs folder location to another partition.
I made these changes to httpd.conf:
DocumentRoot "/media/alex/776FAD4B34B3CF0A/XAMPP htdocs"
<Directory "/media/alex/776FAD4B34B3CF0A/XAMPP htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
and also did:
cd /media/alex/776FAD4B34B3CF0A
sudo chmod -R 777 "XAMPP htdocs"
but I keep getting a 403 error, despite restarting Apache.
Any suggestions please!
Thanks
This looks pretty much exactly like your problem, doesn't it? :)
What's probably missing is this (assumung that your Apache is running under www-data):
sudo adduser <username> www-data
sudo chown -R www-data:www-data /media/alex/776FAD4B34B3CF0A
sudo chmod -R g+rw /media/alex/776FAD4B34B3CF0A
Eventually that won't be enough though and you gotta go with
chown -R www-data:www-data
But that's more like your last resort...

Need help installing fork cms 4.5.0 on apache 2.4.25

I am trying to install fork cms on my laptop. I checked the system requirements for all php extensions and made changes to apache configuration including:
LoadModule rewrite_module modules/mod_rewrite.so
and
AllowOverride FileInfo in 3 separate locations.
To be honest I am new to this so I need to do more reading as to the implications of those changes.
The fork cms files are in the root of my server, which is htdocs in xampp.
When I type localhost/forkcms I get the access forbidden error 403.
I am unsure what else I need to change in order to allow for the installation to begin.
Any help will be greatly appreciated.
In your vhost.conf file you'll have to add this and replace directory with path to your project's root
<Directory "C:/xampp/htdocs/projectroot">
AllowOverride All
</Directory>
After doing that and it still not works, try setting the debug flag on within index.php (Root)
// get environment and debug mode from environment variables
$env = getenv('FORK_ENV') ?: 'prod';
$debug = getenv('FORK_DEBUG') === '1';
$env = 'dev';
$debug = 1;
If that still doesn't work, try and clear the cache by using bash capable command like too.
php app/console cache:clear
cd tools && ./remove_cache
You might have some permission issues as you're working with Windows.
chmod -R 777 app/console
chmod -R 777 app/logs
chmod -R 777 app/cache
chmod -R 777 src/Frontend/Cache
chmod -R 777 src/Frontend/Files
chmod -R 777 src/Backend/Cache
This should do the trick, if it doesn't help just let me know.
I recently had trouble getting forkcms to install on localhost with xampp.
I tried many answers, but the final solution was to open httpd.conf and change
DocumentRoot "C:/xampp/htdocs" to DocumentRoot "C:/xampp/htdocs<Name of my project>"
This changes the default root to the directory where you installed forkcms, it should be changed back after you finish your work on forkcms.
Another solution might be to rename the htdocs folder to something else, make another htdocs folder and put the root files from forkcms in there.
I also had to enable the intl plugin from the php.ini file by removing the ; from ;extension=php_intl.dll

run lxr perl module as scripts under apache 2.4

I have been trying to get it right for the past couple of days, but could not. I am not a LAMP guy.
I installed Apache 2 from the default Ubuntu repositories. Here is the contents of the /etc/apache2 directory:
/etc/apache2$ ls
apache2.conf conf-enabled magic mods-enabled sites-available
conf-available envvars mods-available ports.conf sites-e
And here are the contents of the sites-enabled directory:
/etc/apache2/sites-enabled$ ls
000-default.conf
Here is what I added to 000-default.conf:
Alias "/lxr" "/usr/local/share/lxr"
<Location /lxr>
allow from all
Require all granted
</Location>
And here is the contents of the perl module at this link.
My problem is: when I visit the link http://localhost/lxr/source , I get it as a text file, it is not executed as a script.
How can I fix this?
Thank you!
You have first to install mod_perl on your system. If you are in a debian-like distribution, suche as ubuntu, you can use :
sudo apt-get install libapache2-mod-perl2
Then enable this module on apache :
sudo a2enmod perl
and restart the apache server
sudo service apache2 restart
You will also have to add some configuration such as :
PerlModule Apache::Registry
Alias /cgi-bin/ /usr/lib/cgi-bin
<Location /cgi-bin>
SetHandler perl-script
PerlHandler Apache::Registry
PerlSendHeader On
Options +ExecCGI
</Location>
Read this article for more information.