Apache could host a web server but "php -S" can't - php

I'm new to web development.
I installed Apache and PHP separately, not using XAMPP. Then I notice that after I create a PHP project, I could put it into htdocs folder and launch httpd from Apache and working fine. But if I use php -S localhost:80 -t my_folder, no matter which port I'm using, I can't access it via any browser or cURL.
My computer is running Windows 10 with Anniversary update and ZoneAlarm. I'm not quite sure if these information are related. Please let me know if I need to provide more information to identify the problem.
Thanks!

Related

How to start a php backend app on Ubuntu remote host AWS

I have scp'ed a php backend app (rest server) to a remote ubuntu host on aws. When I was testing it locally I would just do a simple php -S localhost:8888 for testing the service locally. But now that I have it on a remote host (aws) which has a public ip address, I'm not sure how to start the app. How do I start this app?
So when I try to access the app from any where such as:
http://<server_addr>/api/get/record/1
I'll get expected response payload and 200 response code
To make it work try
php -S 0.0.0.0:8888
That way the server is going to listen on any interface. It doesn't work externally because it is listening only on the 127.0.0.1 interface.
With php -S localhost:8888 if you make a request with wget or curl, connected via ssh to the php server, it should get the content.
As the other answer says, try apache. The php built-in server is just for local development as the docs estipulate.
This web server was designed to aid application development. It may
also be useful for testing purposes or for application demonstrations
that are run in controlled environments. It is not intended to be a
full-featured web server. It should not be used on a public network
http://php.net/manual/en/features.commandline.webserver.php
Edit: Oh, and here you have the AWS docs on how to setup the apache server:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html
To host a PHP based application you will need a webserver with php module enabled. For example you can use apache httpd server (I would suggest you to use if your website is php based). Once your server is installed you should be able to access it on http://yourserveraddress:serverport
To install http with php module on an ubuntu machine you just need to run this command (in most of the cases).
sudo apt-get install apache2

How to allow XAMPP Apache listening to multiple network ports?

I have xampp apache on my laptop. I have written an Android app and was able to run PHP script from the app using this
Now I'd like apache to control request from different PORTs ; for instance right now, my Apache's (http-conf file) listens to 192.168.1.40:8011 for my PHP scripts (located in htdocs xampp folder).
I'd like Apache to also listen to another port on behalf of another server (Geoserver) lets say for instance 192.168.1.40:8012.
That way, it will direct my PHP request to xampp htdocs PHP scripts and direct my Geoserver WMS request to 192.168.1.40:8012/geoserver/Projet_NAME/wms
Could you help me do that ?
Like this You want
https://serverfault.com/questions/28041/how-do-i-make-apache-web-server-listen-on-two-different-ports
If u find anything useful please abort it
Refer this link
Link 1 How to change XAMPP apache server port?
Link 2 http://www.complete-concrete-concise.com/web-tools/how-to-change-the-apache-port-in-xampp
Hope you can get some solutions from it
If you find it Helpul please abort it and if not just let me know

Want To Turn Off Drupal App So I can Run Meteor App In server

I am not familiar with drupal or php. I had some developers do my website and they installed it on my digital ocean server.
However I learned how to code and redid the site to my liking, using meteor instead.
I am using 'mup' to deploy the app, and I already did this in a test domain, so it works fine. The problem is that in my real domain, I have the drupal app running, and I don't know how to turn it off.
If it was meteor I could do something like 'mup stop' and it would terminate the process on port 80. But I have been looking how to do this with drupal and the LAMP stack but I don't know how to do it.
IMPORTANT: I have an existing database that I will need in the future from the drupal app, so reseting the server is not really an option. I just want to stop it from running.
This worked! Killed the process running on port 80 and my site was working!
sudo kill `sudo lsof -t -i:80`
Drupal is not an app it's a website. If you want to stop the drupal website then stop apache server with command "service apache2 stop" or any equivalent command which stops your web server only.
Or else you can remove pointing your domain to the particular ip address where drupal website is hosted so that your website will not open in that domain.
Thanks

Cannot Get Laravel Welcome Page to Show

My server is on DigitalOcean cloud. I am using Ubuntu with Apache web server. My home computer is running Windows 7. I am using putty for terminal.
Followed all of the directions on https://laracasts.com/series/laravel-5-fundamentals/episodes/1. Made it up to 8:40, where it directs you to run php -S localhost:8888 -t public. I run that, then open a web browser and tried the following:
-http://mywebsite.com:8888
-http://www.mywebsite.com:8888
-http://mywebsite.com/learning-laravel-5/public
-http://mywebsite.com/learning-laravel-5/public/index.php
None of the above work.
In Google Chrome, the first two options where I list the port number, I get a page saying This webpage is not available. ERR_CONNECTION_REFUSED. In IE, I just get a page with big font saying "This page can't be displayed."
For the last two options, I just get a completely blank page. In the console, I get this error: Failed to load resource: the server responded with a status of 500 (Internal Server Error).
I'm trying to pick up a web app framework to broaden my php skill set. Can someone help me out? What am I doing wrong/what is the video tutorial missing that I have to do in order to get Laravel up and running?
php -S localhost:8888 -t public is meant for running a site locally, which is what the video is showing.
If you are using a Digital Ocean droplet with Ubuntu and Apache, you will need to configure Apache to use /public as the document root and have Laravel installed in the /var/www directory.
From there you can visit the droplet's IP address (http://XXX.XXX.XXX.XXX) instead of the domain name (unless you have configured the DNS for that domain name). You won't need the port in the URL either, since Apache will be serving it on the default port 80.
This probably is not the answer you want, but here's my advice based on setting up a few VPSs on Digital Ocean. Step back. Spin a new VPS. Keep your old one around, if you want, but start afresh.
Create a new droplet
Setup your SSH and PuTTY and make sure that works
Setup your FTP (if you're using it)
Setup your DNS
Setup your Apache config files. DO has a very good tutorial on this: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-14-04
Now, work on getting your "Hello world" html page to show when you access your domain www.yourdomain.com, yourdomian.com. Don't fixate on ports at this point, just get a minimal server running. This might help too: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
Make an saved "image" of this basic working setup so you can spin a new VPS if you need to.
Now that you have a server that loads your domain index page, you can start to install your Laravel.
In a nutshell, I'd advise you to establish a stable working server platform before you try to install and launch a more complex technology like Laravel, or Rails, etc.
Tutorials often make complex technologies seem easy, the 10-minute expert, but there is tremendous complexity masked under the hood of these frameworks. Start simple and build on a server one piece at a time. You have to walk before you run.
I use Laravel often, but my experience with servers is more relevant here. Everything you've said indicates an access problem, and knowing how hosting companies work, they probably have that port blocked (along with all other non-standard ports).
You can test this using PuTTY, open it up and enter the host name of your server. Change the port to 80 and change close on window exit to never, then connect. Enter:
GET / HTTP/1.1
Host: yourwebsite.com
Then press enter twice and the server will process the result. It should show you the HTML of your home page.
Now try it again with port 8888 and see if you can even connect. If you can connect then it's not a port issue, but my guess is you'll get a fatal error Network error: Connection refused, which means the port is closed or blocked via firewall.
Even though DigitalOcean give you complete control over the server, the connection probably still runs through their firewall. It's possible that you have your own firewall, but otherwise if the server runs through their firewall and the port is blocked nothing you can do on the server will open that port.
did you try chmod -R 0777 storage ?

How to unbind the php built-in server from a directory?

I created a local WordPress site and in XAMPP set it up with Virtual Hosts so the address test-wp.dev was the home adress. All was working fine and then for some reason I decided to turn off apache, leave mysql on and try the build in server.
So I navigated to C:/xampp/htdocs/test/wordpress/ and ran php -S localhost:8080
It worked fine. However, today I went to go back to test-wp.dev using the Apache server and it keeps redirecting to localhost:8080. I don't want to use the built in server now. I want Apache.
Where do I "unbind this" or free up that port or whatever. I don't want to have to run the built in server for that folder anymore.
Thanks.
Windows 7
PHP 5.6

Categories