How do I execute PHP on a cPanel server? - php

I have a LAMP application that works. I can deploy this in 15 minutes on a Linux server. I was handed a VPS to deploy it. All I get is WHM. I created an account and that got me a login to cPanel and to the box. cPanel ran some wizard that told me to put my "web source files" in /public_html There is an /cgi-bin inside of that. I cannot get any web assets to be visible from any of those folders. All I get is 404 not found. chmod 777. 404 not found.
My simple question is this: how could I get a simple hello world PHP script to run on a cPanel server? I've been building web pages since before we called them web pages. I do not need to know anything about PHP itself I want to know how to get the cPanel managed server to run PHP scripts. All the documentation I can find on cPanel assumes you've been using it forever. I just need some basic information. Where do I put my PHP code ?????

This is the way cPanel works. If you host your website on shared IP address (main IP address of your server), you cannot access your website using IP address directly. You will always redirect to "http://IP/cgi-sys/defaultwebpage.cgi URL.
To access your website without pointing our domain to your server, you can use temporary URL. By default, it is enabled on the cPanel server. You can access the temporary URL using the following URL:
http://IP/~cpanel_user
Please note that the temporary URL does not work under the following configuration:
If you have enabled mod_userdir tweak and didn't exclude default host
If your server is configured to use mod_ruid2
Hope this information will help you with future use.

Related

how to rewrite -host-header in ngrok in order to open a sub-website in xampp running on localhost

I am trying to expose my website to internet, using ngrok, my website lives in xampp server which is running on my local machine. the path to my website is this: C:\xampp\htdocs\TheWebsite
when i use the following command for running ngrok client:
ngrok http -host-header=rewrite TheWebsite:8081
the client gets connected to ngrok server, but when i try to access my website on internet using http://234k2h4k24.ngrok.io which is the url ngrok provides for me, i end up with this error:
The connection to http://234k2h4k24.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address TheWebsite:8081.
Make sure that a web service is running on TheWebsite:8081 and that it is a valid address.
The error encountered was: dial tcp: lookup TheWebsite: no such host
how exactly one should set the value for -host-header switch in order to to get the sub-directories (websites) living in htdocs folder in xampp server environment??
I have searched this site and also all over the Internet and i found some quick answers but they confused me even more. like this one:
https://helgesverre.com/blog/expose-local-webserver/
which doesn't even provide a small example
and this: Tunnel a localhost subdirectory through ngrok?
just the same as previous one (no example)
A real good answer needs to provide at least one complete example (i mean, if you want to answer this question, please provide a full example of ngrok command for the path of my website (TheWebsite). thank you
for this purpose i needed to define virtual hosts for each of my websites!
I found the answer in a related question at stackoverflow.com and here it is:
Tunnel a localhost subdirectory through ngrok?
this question leads you to this page which lets you know how to define virtual hosts in order for your local machine to identify where is the requested website, just take a look and you will learn in it no time. here is the page:
http://forum.wampserver.com/read.php?2,127757
although its for wamp but it is the same for xampp server too!

Issue loading remote PHP app via Virtual Directories in IIS

I’m currently running a wordpress IIS server for site hosting (lets call it Web01), then running a separate IIS server for web application hosting. (Apps01)
I’m trying to utilize virtual directories on Web01 to dish out the content provided by Apps01 on my website.
So Apps01 hosts an IIS application called FileRun in an IIS site simply called “FTP”. going to http://localhost shows the application launches properly and I can login and use it just fine.
On Web01, I created a virtual directory under my main web IIS site called “ftp” as well as provided it with proper "connect as" account permissions, performed test to verify successful connections and I can expand and see the virtual directory contents etc.... When I attempt to go to http://www.example.com/ftp from Web01. It loads a page stating “ION Loader is required” however, I already have this ION Loader, loaded on Apps01 and it is functional. (as it is part of the FileRun, install). So at this point I used PHP Manager to redirect Web01 on FTP Virtual Directory to point to PHP content on Apps01 since that is where the program is located. Now I'm receiving an internal 500 error when trying to load http://www.example.com/ftp from Web01.
I check the remote PHP servers logs (Apps01) and see the following errors:
[11-Jan-2018 11:46:58 America/New_York] PHP Warning: PHP Startup: Unable to load dynamic library '\apps01\PHP\v5.6\ext\php_sqlsrv.dll' - The specified module could not be found.
in Unknown on line 0
It appears to repeat this same error but with all php modules that are trying to be accessed from the remote Web01 server.
Any thoughts? Issues appear to be happening when running php based applications via virtual directories in IIS only. I tested by creating a test.php page with simple text. If I go to example.com/ftp/test.php, content loads fine. So it appears to be spefically an issue with PHP (either something about the UNC path in the VD settings or php.ini settings that need to be changed to allow this type of access etc...) I just can't find a clear answer for this issue with online searches.
P.S.
I searched on this site and found someone with a similar issue as me. However, their solution is not a real solution and will not work for me. He stated he simply copied the contents from the remote server onto the local Web server... I need the two servers separate so each can process its own roles independently (aka I need app server to process resources for app usage and web server to process web requests etc...)
How to enable the Virtual Directory Support php?

switching wordpress website from test to live in plesk

So i am having a problem, there is a website which have been hosted on plesk and currently to access that website i have to change my hosts file in system32 folder and put the IP and website domain name to access that file. Now i want to remove that so that i can access my website without editing my hosts file. How can i do that?
Note: I didn't made those settings on that website where i have to edit my hosts file to access the website and the website is made in wordpress.
I really dont have idea what to do because i have always used wamp to use it on localhost. Please Help guys!! thanks alot.
The issue is that your website does not have public DNS records and you should create them.
As you want to host it on Plesk server let me explain on example:
Let's assume that you have created a website and called it example.com. For development and tests you used wamp server on your local machine and to reach website you edited local hosts file.
Now you want to move it to production, so what you need to do:
First you should register your domain. You can do it with some registrar like GoDaddy.
Next you need to create this domain in Pleks > Subscriptions > Add Subscription. On this step Plesk will create a DNS zone for your domain on local DNS server.
After that you have two options:
1. Allow Plesk to host and serve DNS zone. In this case you need to configure Plesk server as name servers for your website on registrar side.
2. Use another DNS server, for example provided by your hosting provider, and configure zone for your website manually.
Finally you need to wait until zone will be propagated world-wide and your website will become accessible.
You can read more about DNS here, here and here.

How to clone my website (cakephp) to localhost?

I have installed Wampserwer on my computer, and I have access to files on hosting via WinSCP.
Website is running on CakePHP
Can anyone, please, explain what steps do I need to do, to make a copy of my website on localhost. I cant find any usefull instructions
Thanks!
localhost is working
access via winscp to files
Copy the files to your computer
If your site uses a database, you have import that one, too + create a user/password
You have to configure your webserver for Cake. Find instructions here: http://book.cakephp.org/3.0/en/installation.html#installing-cakephp (in your case, search for Apache)

XAMPP-Project not working on different computers

So, I Have REST URL to register like this :
http://localhost:8080/task_manager/v1/register
And then, I try the URL in Google Chrome Advanced Rest Client.
Everything goes smoothly.
And now I decided to test the URL on another computer.
So I copy paste the file to another computer and test the URL once again.
But the result is I got 404 ERROR, Object not found.
Did I hit something wrong ?
I copy all the file correctly.
This is weird.
UPDATE : I use all the folder which contains all the files and I using same version of XAMPP & PHP on that both computers
Localhost targets on your computer, means the actual machine the files are on. If you are using php > 5.3 you can use php's build in development server with
php -S __YOUR LOCAL IP__ : 8000
and access the site from all the computers within your network
For example, if you run
php -S 192.168.0.1:8000
on your development machine, you can access it via
http://192.168.0.1:8000/
from every device connected to your local network
As you have written in your comment you have copied all the files, it is most likely that you either don't have php, apache or a webserver (MAMP,WAMP,...) installed (or started) on the other machine, or you just didn't copy the files to the correct folder.
an url beginning with localhost refers to the computer where it's called from. See wikipedia localhost.
To provide the same behavior on another computer you need to copy the whole project and install the used server software e.g. apache, mysql etc. pp. or access the project from another computer in the same network using the internal network IP instead of localhost.
FYI: localhost is almost the same like the loop-IP 127.0.0.127
so on the computer where it works there should also work: http://127.0.0.127:8080/task_manager/v1/register
Now replace the 127.0.0.127 with the IP of your computer when testing it on another computer
You need to run your project on a webserver like your local.

Categories