Docker Compose LAMP stack not serving index.php - php

I'm doing some freelance work and the people I'm working with use a LAMP stack with docker. I've never used docker before and I am having some issues. They all use Macs, while I have windows so they have not been able to help me. I've been working on this on and off for the last 12 hours and cannot get my index.php page to show up. I'll go over the steps I've taken so far and provide the file structure.
I was working in windows powershell
Installed Docker Desktop from here
I followed the steps here to create a new docker-machine
2a. The command I ran was 'docker-machine create -d hyperv --hyperv-virtual-switch "DockerVS" default'
I then ran 'docker-machine env'
Then I ran '& "C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe" env | Invoke-Expression'
Then, while in the same directory, I grabbed the project from GitHub, changed directory into the location with the .env and docker-compose.yml files. then ran the command 'docker-compose up -d'
At this point, I was supposed to be able to run 'docker-machine ip default', paste that IP into my browser and see the page. That is what all my coworkers had done with their macs, at least. If it matters, the IP is 10.0.0.117
Now something is definitely running there, it attempts to get the "index.php" file, but it returns "File not found" to the browser. The page is also running phpMyAdmin, so if I type in 10.0.0.117:8080 to the browser, I see this page. So I'm confident that I'm on the right track, I just assume I've done something minor.
So the solutions I've attempted. My first guess was that I needed a port similar to :8080 that make the php page pop up. I ran 'docker-compose ps' and I tried the ports 443, 3360, and 9000 which I all see here:
Naturally no go. Next I tried various paths, and then tried all the aforementioned ports and paths together. The paths I tried were
/index.php
/index.html
/index
/index.htm
The above four with /public-html in front
The above with /LAMPProject in front
The file structure looks like this:
So all in all, that is what I am working with. It's a fairly simple docker LAMP set up before I start working on bigger stuff. Any advice at all would be very welcome.

I think you should map your phpmyadmin port to another one like 8081 instead 80, apache container mapped to 80 too.

Related

Not able to open localhost/phpmyadmin with nginx

Before starting I installed XAMPP. Now am trying to use nginx instead of Apache. For that I did the following steps:
Installed nginx (1. c:>cd nginx 1.8.0 2. start nginx). installed successfully.
Now am not able to load php files and localhost/phpmyadmin.
There are a handful of reasons for this behavior. Could you run through some of the following options? If they don't outright solve the issue they should provide greater context to help us resolve this.
What happens when you attempt to pull up the "localhost/phpmyadmin" website? If it attempts to save a file then nginx may not be properly configured to interact with the PHP interpreter to process the PHP code and provide it to the web server (nginx).
In the directory of your nginx installation there should be a "sites-available" directory containing a plain text "default" file. In this server you should find a declaration of a server block which, in turn, contains an identifier for the document root referred to as "root." Does this point to the directory containing the phpMyAdmin source code?
Are you able to pull up just "localhost"?
If option 3 is unsuccessful you can run something like "netstat -na | findstr /c:':80'". This will tell you if nginx is actually listening on port 80.
If option 3 is unsuccessful but option 4 shows results, you may want to pull up the listening IP address (or your assigned/static IP if it shows 0.0.0.0:80) in your web browser. For example: "192.168.1.100/phpmyadmin"
I hope this triage helps find the underlying cause of your issue.
I open the apache with Xampp from the IP direction and it works ok, that is in localhost it not work and in IP direction work fine.

Vagrant + VirtualBox + Dashbrew = not working

I am new to PHP. Coming from the Java - Servlet would, the whole idea of installing virtual machines to do local development is a bit confusing. I am familiar with virtual machines, just not using them for development purposes.
I attempted to use Homestead from Laravel (since this is the framework I'll be using). I have attempted it probably 10 times. Each met with failure. I also attempted to use PuPHPet however I was met with a "File not found" in my browser upon loading it. No matter what tutorial I follow I end up with some kind of issue.
Now I am trying Dashbrew. A new Vagrant build that is supposed to be simple for beginners. I went through the installation without a hitch. However upon trying to navigate to the dash board for the application (dashbrew.dev) nothing happens. Chrome shows that it is trying to request information, evident by the loading wheel on the tab spinning backwards.
What do I need to do to get this working?
I have MAMP working with Laravel so I could use that. But I wanted to familiarize myself with Vagrant a bit.
If you need any additional information, just leave a comment.
EDIT: Here's what my hosts file looks like...
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
## vagrant-hosts-provisioner-start id: 971cff21-8d99-4aa7-b9b2-ff03403af9f8-0
## vagrant-hosts-provisioner-end
## vagrant-hosts-provisioner-start id: 9b67e862-ea30-4232-9c4a-4c1eb45d8464-0
## vagrant-hosts-provisioner-end
## vagrant-hosts-provisioner-start id: c93caf02-00af-4df0-9d9d-bdaf3c3f34eb-0
## vagrant-hosts-provisioner-end
## vagrant-hosts-provisioner-start id: c83f58db-fd9d-47f1-9aad-685f3e97c6a4-0
## vagrant-hosts-provisioner-end
This is what prints in the terminal up running vagrant up
I also attempted to use PuPHPet however I was met with a "File not found" in my browser upon loading it. No matter what tutorial I follow I end up with some kind of issue.
This is because you probably didn't have an index file in the vhost's directory.
For example, if your vhost foo.dev's document root is /var/www/foo.dev/public, going to http://foo.dev would be hitting your VM's /var/www/foo.dev/public directory, looking for an index.php file.
I had the same problem. chmod the dashbrew directory to 777. I also changed ownership of the dashbrew directory to my username.

Apache/PHP - localhost stopped working. How do I get it to work again?

I have installed Apache2.2 on my computer, PHP 5, and MySQL. Everything was working fine until last night. Suddenly, I could no longer connect to the localhost. I think my computer was infected with a trojan, but that has since been removed and I am unable to reconnect to my localhost.
I have updated my hosts file Windows(C:)/Windows/System32/drivers/etc hosts in notepad: see attachment.
I have tested my connection in the CMD prompt see attachment.
You'll notice [::]1, but after updating my host file, it now displays as 127.0.0.1
Additionally, port 80 IS LISTENING
instead of my web browser loading the page as localhost/vote/home.php NOW it loads as file:///C:/Websites/Vote/home.php AND NOW my PHP no longer works i.e. not being pulled into my web page.
...can't establish a connection to the server at localhost.
Why is my local host not working? Thoughts? Thank you in advance.
Additionally, my web browser page does not time out when requesting localhost....
(I'm a new user so I am unable to post images)?
× 257296
if you put localhost/vote/home.php into your browser's address bar you should get an unabled to connect error,
not a redirect to a file. The only time the address bar will show file:///C:/Websites/Vote/home.php is if you open
that file directly in your browser.
Your details about why apache isnt working are not to clear, but you can try a couple of things.
First, how did you install apache, is it a service? you can check this by going to control panel > Administrative Tools > Services and
see if apache is in that list. If its, you have to start it, if its not then apache is not installed as a service and
you need to start it by running the executable. Go to the whichever directory your httpd executable is and run it.
Some things to try:
Make sure Apache is actually running, that it haven't failed during startup.
Check if it's listening to the expected port (80, or whatever you have configured it to)
> netstat -nb
Check your hosts file to make sure nothing fishy is going on there. localhost should point to 127.0.0.1, but maybe it's been set to point somewhere else by your virus thing.
If you can't figure it out, you can always try to remove/uninstall and try to set it up again. If this is a developer machine, I can recommend using the WAMP package installer instead of setting it all up yourself. It provides fairly easy switching between php/apache/mysql versions and easy switching on and off of most regular apache and php modules.
run command prompt as administrator and go to Apache bin folder (usually 'cd \apache\bin' ) and type httpd -k start. it worked for me with the same issue.
I had the exact issue. If you have a XAMPP control panel pull it up. There you will see XAMPP Control Panel Image the different modules that you have open... Apache will be one of them. In the 'Actions' column you will have 'Stop' adjacent to it. Hit the 'Stop' and wait about 1 minute for everything to calm down. The button will change to 'start' so hit it. This will reset Apache. It worked for me...Good Luck.
If you don't have the control panel on your desktop, go into your programs list and drop-down the XAMPP icon. The control panel is right there. Just click it and it will show

No www folder is found in apache 2.2

I want to start learning php, I install apache 2.2 and I want to run my first.php file, I look for www folder in the installation folder of ApacheSoftwareFoundation but I couldn't find it.
here's the files in the apache
I tried to put my php file in htdocs but it doesn't work , can some one help ?
Edit
Doesn't work means when I make http:localhost/first.php , returns Unable to connect
Now the apache is running, when I open htt'://localhost/
returns "it works"
but when I open any php file, it opens as-is ?!
You'll need to check a couple of things...
Make sure the Web Server is running ,either the service
or the program, is running and that you have the correctly configured the Virtual Directories.
If the web server just outputs the
content of the .php file, it could
mean that you don't have mod_php
installed. Meaning the server does
not have the Mime type registered so
it will just try to treat it as a
text file ...
And as your on windows you might consider using something like XAMPP. It gives you a Full Working AMP (Apache Mysql Php) Stack with one install and a easy control manager to start/stop the servers. Other wise do a couple of Google searches on how to install the php module for your Web Server on Windows
Update
To start the server try executing the executable bin/httpd.exe .
Now the apache is running, when I open
http://localhost/ returns "it works"
but when I open any php file, it opens
as-is ?!
A default installation of Apache on windows does not include the necessary modules to run PHP. After installing Apache, you must either:
Install PHP separately and follow the instructions described here to configure Apache to use the installed version of PHP to serve .php files. I've been through this and took me hours to get every thing to work.
Recommended for you: uninstall Apache; install WAMP instead.
if you look in your httpd.conf file you will find the default root directory, it doesnt have to be called www. It is the htdocs by default.
error 500 covers a whole host of things. from compile error, to permissions.
Have you put a simple file of
<?php
echo "test";
?>
As your test php page to rule out other issues?
You need to:
Construct your URI correctly: http://localhost/first.php (with the //)
Ensure that Apache is running
all files in htdocs can be referenced from outside
Just put a basic file named index.php
and visit site http://localhost/
In general type in http://localhost/filename
You say that you get a connection error when you try to go to your webpage. Since it looks like you're using Windows Vista or 7, make sure you're running Apache as an administrator; it can't bind to port 80 otherwise. Also check that other programs like Skype aren't binding to port 80. If you still can't find the problem, check the error log. (logs/error.log by default I think)
The problem is that Apache was installed but not started
If you are using xampp start it and then start apache through control panel
for others look for similar instruction

Symfony project on CPanel account

For a bit of history - this is the first time I attempted to setup a test symfony project, just to have a play with it.
The symfony project was setup in the following location:
~/symfony_projects/myproject/
Now, with cpanel, the httpd.conf is automatically generated (but I'm sure you knew that), and it uses ~/public_html/ as the web root and splits it up by domain name (virtual hosts) - so for this example, lets say it's ~/public_html/example.com/.
So the symfony project is all setup now, the next problem was trying to figure out how to setup the server so it points to the /web part of the project - this is where I found it tricky.
I tried doing the following:
ln -sf ~/public_html/libs/Symfony/data/web/sf ~/symfony_projects/myproject/web/sf
ln -sf ~/symfony_projects/myproject/web/* ~/public_html/example.com
That unfortunately didn't work though. When trying to go to http://www.example.com it just gave me a 500 error.
Any other options here? Taking into consideration that I cannot modify the httpd.conf. And even if I could, it's auto-generated and would rather not (in cpanel).
* Update *
I just tried what was suggested by #Dan, but with the same issue - getting HTTP Error 500 (Internal Server Error). So, it looks like something else is the issue.
I checked my error_logs but didn't see anything useful there. Is there any other way I can check to see what the problem is?
* Another Update *
Just tried http://example.com/frontend_dev.php and it works perfectly - gives no errors at all, which makes it kind of hard to debug the production controller.
So the Development controller works flawlessly and the production is spitting out the 500 error - any ideas? :/
I just copy everything out of web/ (including css/, js/, etc. subfolders) one level higher, then edit the index.php/yourapp_dev.php files' require statements to reflect the change in path. Add some rewrite rules to forbid direct access to the rest of the directories and you're all set on servers where you can't change the document root.
If you look at the http.conf virtual host entry for the symfony project the last line in generally a commented out include statement. If you uncomment that line you add any extra virtual host configs you need into that file. Then just restart apache. Anything in the file will then be appended in place of the include statement.

Categories