I have been following the Quickstart Guide: Compose and Wordpress and can't get it to work.
I think it has something to do with my directory structure. After running all the steps I had a sub-directory called wordpress but I think all of my code referenced a sub-directory called code so I decided to rename my wordpress directory code. I then re-run docker-compose up but this also unfortunately didn't work.
UPDATE: By "can't get it to work" when I enter load the website the PHP server returns:
Not Found
The requested resource / was not found on this server
Your Dockerfile and docker-compose.yml should be inside your wordpress directory. (The one you renamed code)
Your confusion
For some reason you think there is a code directory involved. There is no directory like that in your wordpress and it's perfectly normal.
Let's break down the command that are confusing you :
In the Dockerfile :
ADD . /code
This line has for effect to copy the directory indicated (here it's . ) into the container directory indicated (here it's /code).
It's equivalent to a cp command only that you copy from the host to the container.
In the docker-compose.yml :
volumes:
- .:/code
This command is exposing a directory to a container. Here we expose the host directory . into the container directory /code.
Note : If you understood volume you might realize that the ADD instruction in your Dockerfile is unnecessary.
Why it's not working
Your docker-compose.yml and Dockerfile are above the intended working directory.
So when the docker-compose execute it copy the content of your current directory into the /code directory of the container.
So when php try to execute in /code it doesn't see the file he expect hence the Not found error.
Fix it
Either copy you Dockerfile and docker-compose.yml into the code directory (the one you renamed).
Or modify the Dockerfile and docker-compose.yml so that they point to the good directory.
By having a closer look to that quick start guide: The Dockerfile and the compose file should be inside your wordpress project folder that you created in the beginning. And also inside that wordpress folder there should be a sub-folder code. Run docker-compose from within the wordpress folder that way should work.
Unfortunately when you run the curl https://wordpress.org/latest.tar.gz | tar -xvzf - command from within your wordpress project folder it creates an other folder wordpress below your project directory. You should rename that one to code.
Related
I've cloned this php project locally and run docker-compose up --build.
It seems the cloned code is not mapped to the docker environment. Even after deleting everything I can see that the project still works on the browser.
What am I doing wrong? As I have read here the default working directory is the path of the Compose file
I have a problem modifying a JSON config file within a PHP7.4 container. Im supposed to be able to configure an HTTP GET request to make adjustments to this config file.
Ive ran the code on a PHP test server, with no issues, but cant seem to get the file permissions modified within the container.
Ive added the line RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" inside the Dockerfile, taken from Docker hub PHP-apache documentation page. This stops previously encountered file permission problems, however, when i send the container the relevant request, it doesnt show any PHP errors, but the file also isnt being modified.
My Dockerfile;
FROM php:7.4-apache
COPY src/ /var/www/html/
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
Prior to building the container ive also ran CHMOD 755 filename on all files within my /src directory.
Ive tried modifying chown permissions as well, adding users (and running the container as an admin), but im getting Docker build errors when i try to add those features. What am I missing?
Answer;
I tried upgrading my chown permissions to 777... and its working... thanks for anyone who read or looked.
chmod 777 filename|directory
I have a problem, I wrote an application but it doesn't work on sub folder. I have to prepare my program to work in sub folders. For example:
127.0.0.1/ - here is my project at the beginning, when I create it, but when someone start in like this:
127.0.0.1/store - then it doesn't work, how to fix it and where do this? Somewhere in config?
I think the setup is wrong, there are different ways to boot laravel on localhost
1. Run the following command from the project root directory
php artisan serve then go to 127.0.0.1:8000
php artisan serve --port=8080 to change the port
2. Access it from localhost by
go to -> xampp(if you're using xampp) -> htdocs
mkdir (create a folder) "store"
then cd into the folder, run the following command
composer create-project --prefer-dist laravel/laravel .
go to -> 127.0.0.1/store/public
I have to overwrite a file through Dockerfile. In particular on an Ubuntu container with Apache and PHP and I have to overwrite the file php5-cgi.conf.
I tried to use the following command:
COPY php5-cgi.conf /etc/apache2/conf-enabled/php5-cgi.conf
but I had the error: File already exists
I have also tried to use the following command
RUN cp -f php5-cgi.conf /etc/apache2/conf-enabled/
but the file is not copied when the container is running, Is there any advice on this?
Drop the file name from the destination:
COPY php5-cgi.conf /etc/apache2/conf-enabled/
The destination is an absolute path (not filename), or a path relative to the work directory, into which the source will be copied inside the destination container.
I just tested following docker file with no problem.
from debian:jessie
COPY debian_version /etc/debian_version
As PolarisUser stated in comments, you need to put debian_version in the same folder as dockerfile or use absolute path.
Another way would be mounting the file when running the container.
docker run -d -v php5-cgi.conf:/etc/apache2/conf-enabled/php5-cgi.conf --name your_container_name <imagename:tag> <startup command>
docker cp "yourfilename" "containername":/destination
Below is a working example:
docker cp config.json bigdataapp:/app/src/bigdatapp/wwwroot/assets/config/config.json
I'm using the official docker images for apache and php : https://hub.docker.com/_/php/ (the 5.6-apache tag)
I'm launching the container like this :
docker run -d -p 80:80 --name apache-php56 -v "/home/myUser/www":/var/www/html php:5.6-apache
Of course, I have all my code in "/home/myUser/www"
When I am in a directory with an index, it seems like apache is displaying the page pretty well. However if I am in a directory without index, apache tells me that I don't have permission to access.
I would like apache to show me the "classical" view when there is no index with the "Name Last modified Size Description" and I can navigate through until I find an index.
I'm pretty sure this is a simple config in the default apache2.conf that forbid me but I have no idea which.
Thanks by advance.
I had the same problem with my symfony project while using docker. The problem was that the .htaccess file was missing in the web folder.
You can create one by your self or you can install symfony/apache-pack with composer if you use symfony.
An example .htaccess can be found in the symfony documentation for web server