and I've read a bunch of related posts here on SO and have gotten the following ideas here:
First, my website is shared-hosted at 1and1.com. And my objective is to call exec() in my PHP code to run ffmpeg to convert short videos (30 seconds) from format A to format B.
1) Now, because of my shared hosting situation (the 1and1 web server my website runs on is shared with other 1and1 customers) -- 1and1's administrator probably has their server in 'safe' mode, so that my desire to exec() in PHP to do the ffmpeg conversion of a video -- will fail.
(Supposedly there is a 'safe mode' shared directory but that's a hoop to jump through with 1and1).
2) And even if 1and1 does not mind if, from my PHP code, I call 'exec( ffmpeg -i yada yada)' for converting between video formats -- I've heard it's unseemly to do that. I'm led to believe I need a dedicated server and not a shared server. Which sounds weird because (a) the web site will never scale to massive # of users, and (b) when I run ffmpeg on my 2 1/2 year-old laptop, Windows Vista, running Xampp as my localhost development web server, the conversion happens like right now. Very fast.
Are the above restrictions correct ('safe mode' on shared web hosting, running ffmpeg is a no-no without a dedicated box)?
I'd like to think that 1and1 would not even notice if my web site did a few (say, under 20) short-video conversions per day.
Also if anyone can recommend the proper web hosting company for my situation I would be in your debt. Thanks.
I believe safe mode would allow you to use exec because 1and1 would have you chrooted so any program you run would not be able to access other users. But, you might want to check the AUP to see if the prevent those kind of processes (that consume a lot of resources).
For the best performance you should use a VPS server in which you can control your php environment. ffmpeg has potential to be very resource intensive, so for best performance a VPS/dedicated would be best. Also, using ffmpeg on shared hosting would impact performance on other sites as well.
Any VPS would do, but because you asked for a recommendation, I would recommend BlueMileCloud.
PS: You should never call a process directly from exec. You should add it to a queue, so the script does not wait for the process to finish and cause the site to hang.
Related
Let me start off by saying that I know this is not the preferred way to run python, but I have had this website for several years and am looking to add additional functionality. If I try to move the site to a new host and server setup, I am afraid I will mess everything up.
I am using Godaddy shared server for my website, and I access it using cpanel. The website is a Wordpress blog but also has a few tools I built using PHP and SQL database to store the output. I want to create a chatbot using Python but from what I understand, I can't use Django on a shared Godaddy server.
Is there a way for me to run Python scripts given my limitations?
Is the best alternative for me to start a second server and build an API to process the conversation and send it back to my current website?
Shared hosting solutions tend to limit the software that can run on then. The last time I used GoDaddy, they had only a php stack, so probably no, you won't be able to use Python there.
But that's fine, you shouldn't!
If you plan on using Python, I recommend you to get a Vps, or switch to a cloud service, like Openshift.
You can find cheap and reliable Vps servers nowadays, so go for it.
I have hostgator cpanel web server. And I want to run exe file on it with php. Is it possible to do that? On window computer it is possible to start a program with the help of php command exec() with command line arguments. I'm looking for a solution so that I can do the same on my web server too.
The first thing you must understand is the difference between a web host and a dedicated server. On a dedicated server, you do what you want whereas a shared hosting server is shared among hundreds, sometimes thousands of users.
That difference is reflected in the price and justifies severe restrictions that need to be imposed by the host to maintain a good overall service level.
That said, functions of the exec() and system() family are also available for Linux, but you won't be able to run Windows executables on Linux without additional tools such as Wine which certainly won't be available on a shared host.
If your hosting sever running UNIX-like OS, Linux,
for example, it's not possible, you have to look for alternative binaries on that server.
i am new in this material so i have 2 questions to ask in this 1 post
first of all, i am a PHP developer who wants to host my application into my own PC
(my application is something like social media assuming will have many users)
(i dont want to use any Public WebHosting / VPS , considering cost and security of my data)
and i decided to make my own webserver for my Start-Up Company
but the very problem here is the cost to buy a Server is too expensive if we compare to Desktop PC
and my question no 1 is
For a WebServer based on PHP (Apache) which used Sql Server as a Database , can i just use Desktop PC instead of using Server?
(considering it will online 24hours / day and processing big amount of request. Assuming i have many users online at the same time)
If let's say i bought 1000$ Desktop PC which i maximize the money at Processor, Memory and Storage
will it worth more than if i bought 1000$ Server which i maximize the money at Processor, Memory and Storage also
question no 2 is
if i must use Server instead of Desktop PC as my Webserver, i will use Windows Server as my OS,
but if i can use a desktop PC , can i use Windows 7 Professional instead of using Windows Server?
because some website told me that Windows 7 Professional is not as powerful as Windows Server For a Normal Server (but i dont know about WebServer)
and i dont really know what's the disadvantage if i use Windows 7 Professional instead of using Windows Server as OS for this PHP application
I'll address your first question :
The main issue with a PC as a server is availablity and security.
Servers are secured and configured in a way that will prevent most issues that you would normally wouldn't think about, like disabling eval, disabling exec, disabling file_get_contents on default, and many other things, hosting companies provide support and assistance on a wide variety of topics.
(Automatic backups of sql, machine users and files also).
the 2nd issue is that if your house loses power, your website is down. if your hd crashes, it takes hours and hours to replace, reinstall, reconfigure and re-deploy your website.
Don't expect your new app to be the next LinkedIN or Twitter or facebook when it comes to traffic and usage, Just start with a small hosting company for the cost of a few $ a year(you can get really cheap hosting, but you get what you pay for) and upgrade accordingly.
With 1000$ you can buy really good hosting with superb stats for quite a long time.
My suggestion is start with a web hosting, and grow slowly, most hosting companies will allow you to upgrade.
You can use your local machine as a developer environment, but the actual deployment should be done on a server.
The first question is the internet bandwith. At data centers the bandwith is usually much better than at home PC.
The second question - the 'white' IP address, that can be accessible from everywhere. Not all internet service providers provide this service.
So, i think you can give a try, if you have good ISP provider.
Also i think you can use linux instead of windows, if your project is a PHP based site.
What do you use as sql database? MySQL, PostGreSQL, MariaDB or Microsoft SQL server?
I think Windows is only needed, if you want to use Microsoft SQL. In all other cases Linux can be easier to use and cheaper alternative.
I need to set up cron/automatic taks on windows(shared)/linux(shared)/wamp servers.
the problem is that the project is running on multiple environments.
so what is the best way to set up cron/scheduled taks ?
Actually what i need to do is check email servers for new emails and if something found save it to the local DB. If you have any alternative other than cron job then please let me know.
Thanks.
EDIT:
As i mentioned in the question i have multiple emails/filtering , so i need to run something on background to fetch data periodically. CRON in linux and Scheduled Tasks on Windows.
But the real problem is that i am doing it on a shared hosting ( or it depends the client ) so i cannot use CRON/Scheduled Tasks.
Ex : Project is installed on GOdaddy windows shared hosting , it is a windows server so no support for CRON(normally) and they wont allow to use Scheduled Tasks.
the question is : is there any alternative for CRON/Scheduled Tasks
?
Short Answer
I don't know alternatives to CRON/ScheduledTask which would fulfill your need.
I suggest you outsource the schedule to another server, see my possibilities below.
I came up with the following possibilities:
Shared hosting with CRON jobs (easiest)
Look for a shared hosting provider who lets you add cron jobs (e.g. through webspace management). HostEurope (german) would be such a host.
You own a dedicated (virtual) server
Given you deploy this project to multiple shared servers but own a dedicated (virtual) server for yourself:
Make your script publicly available but guard it with a strong authorization mechansims. (hard-to-guess request token, white-list certain IPs as callees, ...).
Set up a cron job on your own server which calls the script on the client's webhost.
You don't own a server
As the last possibility but you don't own a dedicated server.
Setup a virtual machine at some cloud provider (e.g. OpenShift) and add the cronjob there. Don't use this instance for other jobs and it should fullfill your needs perfectly (Reference: https://openshift.redhat.com/community/blogs/getting-started-with-cron-jobs-on-openshift)
Requirements don't meet infrastructure (likely!)
Your client/project has requirements which don't fit a shared hosting environment. You are strongly encouraged to get a hosting plan fulfilling your true needs. Price differences between shared hosting and first virtual servers or dedicated hosting aren't so steep that investigating is out of question.
As everyone else suggested if this is a web page you can use wget to run it.
If it is a CLI script you will have to run it with php /directory/filepath.php
If the actual question is HOW you are going to periodically run it you will have to use
cron on *NIX and scheduled tasks on windows server.
If you want to automatically install the cron you will have to check the OS and act depending on whether the OS is windows or *NIX.
A google search will give you results on how to do it in both environments.
Edit after reds clarification
As Samuel Herzog pretty nicely says, on shared hosting you (usually) have a control panel.
Most well known for linux are:
Cpanel: http://www.siteground.com/tutorials/cpanel/cron_jobs.htm
Plesk: http://www.hosting.com/support/plesk/crontab
Webmin: Setting up a cron job with Webmin
And for windows I only have some familiatiry with plesk for which the procedure is the same as before.
If you dont have control panel but have shell access (linux) you could follow this tutorial.
If you dont have control panel but have remote desktop (windows) you could follow this tutorial.
If you dont have any of the above you should follow Samuel Herzog suggestion about a vm on a cloud provider or consider upgrading to a VPS or a dedicated server.
I'm trying to implement a socket server that will run in most shared PHP hosting.
The requirements are that the Socket server can be installed, started and stopped from PHP automatically without the user doing anything. It doesn't matter what language the socket server is written in, as long as it will run on the majority of shared hosting globally.
Currently, I've written a Socket Server with PHP that implements an Object Cache:
http://code.google.com/p/php-object-cache/
source: http://code.google.com/p/php-object-cache/source/browse/trunk/socket.class.php
However, PHP has to be compiled with sockets support, and not many servers run with PHP sockets support.
My real question is: What language should I implement the socket server in, and have maximum platform support and be invokable from within PHP.
In other words, what scripting language is the most common on PHP enabled Servers?
Or do I have to write the socket server in a compiled language to have it works across all servers?
Lets leave IIS out of the picture at the moment, just Linux servers. I don't think many PHP sites are running on IIS...
edit:
Sorry I think my question is not clear.
I'd like to know, what languages is best suited for creating a socket server given the following requirements:
The language must exist in shared hosting, alongside PHP running in Apache (not CLI).
The sockets support must be enabled natively, not via a required extension.
PHP must be able to write the deamon to file as well as start and stop the deamon.
I'm not asking for a solution for a single server. It has to run natively on the majority of shared hosting servers.
Any server can be stopped or started by PHP under Linux. Of course, if you are running a server which accepts sockets from the internet, then you can just connect directly to the server and tell it to shutdown. No need to go via PHP!
As for "starting a server from PHP", well, under Linux, anything can be started from pretty much anything. Just shell out to start the process and have it drop into daemon mode.
I'm a Perl fan myself. Not surprisingly, there's a
Perl Daemon library available.
If your hosting provider offers Perl script support, then you probably have permission to use "system" or backticks command. Then you can very likely start a daemon. However, you will need to use a non-privileged port (over 1024). Also, you should ASK THEM FIRST! They may not appreciate you tying up ports on their server. This is very definitely something you should discuss with your hosting provider.
It really depends on what the install requirements are. Often the easiest and most standard way to write a socket server is to write an inet.d service. This is a standard daemon on my unix machines, and it will fork a process and handle the socket level details. If you want your service to run on port below 1024 on Unix, this is one of the easier ways to get it done. However, the initial install requires root to configure inet.d.
If you shared hosting allows PHP to do an exec call, then you could start the daemon that way. Keep in mind though, it'll need to run above port 1024. You next need to decide if your program is going to be multi-threaded or multi-process. Typically Java programs are multi-threaded, while an Apache instance is normally multi-process.
Lastly, the host may have a firewall in place. This helps prevent shared hosting accounts from becoming part of a bot-net. If the firewall rules don't allow connections to other ports, you won't be able to connect to it remotely.