Cannot access Ubuntu web server from other device - php

I run the built-in PHP web server on Ubuntu 12.04:
php -S 0.0.0.0:8000
Locally, I can access my website on http://192.168.xx.yy:8000. However, I can not access the site from other devices in the same LAN on that same IP-address (the request times out).
I thought the Ubuntu firewall might be blocking the request and did:
sudo uwf disable
and
sudo iptables -F
but still no luck accessing my site form other devices. Does anyone have a clue on this?

Related

Secure Linux Server Setup To Run Scripts via PHP exec()?

I'd like to run a script (phantomJS) via php exec() or shell_exec(). Everything is working fine on my development system.
I've installed phantomJS on my production server, and have run it successfully from the terminal after logging in via SSH.
But when I run it from PHP via exec() or shell_exec(), I get messages saying:
GLIBCXX_3.xx not found
GLIBC_2.xx not found
The support team at the web hosting provider is saying they don't know how to enable the server to access the script and still maintain security:
We're not familiar with the specifics of it, so we'll either have to
go through with disabling the chroot, but as our supervisor mentioned
this will allow all accounts on the server to account with each other
which is what the chroot prevents.
You can have your own system administrators look at the setup as you
do have root access, and see if they can devise a workaround, but on
our end this is the only thing we can suggest.
They are running CentOS, which is a 64-bit Linux OS.
I have very good experience with this web host up to this time, so I'm hoping there's a way to address this without changing hosts.
I have full root access to the account, so I can configure it in any way necessary.
Can anyone make some suggestions about how I might configure my production server to access phantomJS while maintaining a secure server?
UPDATE
Apparently my app is in a "chrooted environment" without full root access to GLIB on the server. The web host is saying there will be a lack of security if my php user is given full root access.
You have to remove your PhantomJS system call and create an API layer or a service that subscribes an MQ queue and then integrate it with PHP to avoid several problems, including the chroot limitation.

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

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

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!

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 ?

Categories