tomsik68 / docker-xampp

Dockerfile to build an image containing XAMPP(MySQL + PHP + PHPMyAdmin) running on Debian system with SSH server
https://hub.docker.com/r/tomsik68/xampp/
MIT License
197 stars 109 forks source link

I want to mount my php folder so i can open the page on it. #51

Closed snaffey closed 1 year ago

snaffey commented 1 year ago

Hello,

I want to mount the php folder, what i mean in this, is to open the index on my folder that i have in a workspace. Thank you!

tomsik68 commented 1 year ago

Hello, if you use this command to start the container:

docker run --name myXampp -p 41061:22 -p 41062:80 -d -v ~/my_web_pages:/www tomsik68/xampp

The folder ~/my_web_pages is where you place your php files.

snaffey commented 1 year ago

I'm a complete noob in GitHub and Linux, but can I commit that folder to my php repo?

tomsik68 commented 1 year ago

Yes, you can commit that folder to your Github repo.

There are two separate problems that you're trying to solve here:

  1. How do I version control this folder?
  2. How do I serve this folder using xampp?

For number 1, you commit the folder to your Github repo.

For number 2, you need to use the right command to start the docker container.

snaffey commented 1 year ago

Im sorry, for making you waste your time with me, but where is my_web_pages located ?

tomsik68 commented 1 year ago

my_web_pages is just an example. Instead of that, you need to pass the path to your php folder.

snaffey commented 1 year ago

The line docker run --name myXampp -p 41061:22 -p 41062:80 -d -v /workspaces/php:/www tomsik68/xampp:8 was what got it to work in the end.

I appreciate all you've done, especially this Docker, which I'm utilizing as a student because my school uses PHP and SQL.

tomsik68 commented 1 year ago

I'm happy I was able to help -- that's not always the case! No need to feel bad for what you call "wasting my time". I created this project because I wanted to and I also help because I want to.

I'm closing this issue as it sounds like we answered the question. If anything comes up, feel free to re-open or make a new one.

snaffey commented 1 year ago

Hi again, the index is working fine but I want to use another sql program instead of phpmyadmin, I'm trying to use heidiSQL or an vscode extension, I'm trying to connect to 127.0.0.1:41062 or local host:41062 and I can't, if I can't use another program there is no problem. Thanks 😄

tomsik68 commented 1 year ago

If you want to connect to SQL server, you need to use a different port. 41062 is used for the apache HTTP server.

You need to stop your existing docker container and start a new one with the -p 41063:3306 parameter, like this:

docker run --name myXampp -p 41061:22 -p 41062:80 -p 41063:3306 -d -v /workspaces/php:/www tomsik68/xampp

The -p 41063:3306 parameter exposes port 3306 of the container on your localhost port 41063. After that is done, you should be able to connect to localhost:41063 from your vscode extension.

snaffey commented 1 year ago

Ok, i know it worked, but im getting an error saying im not allowed, im using root username and root password

tomsik68 commented 1 year ago

Those credentials are for SSH server, not for SQL. For SQL, I think it's just root with empty password. If that doesn't work, just search for xampp default mysql password.

snaffey commented 1 year ago

Still nothing, I did look that I need to put skip-grant-tables in the cnf, I will look more into this.

snaffey commented 1 year ago

Yup, I did put skip-grant-tables and worked, I don't know what that does, it's working so it's fine