OVH - Executing cron - cron

I'm trying to setup cron on OVH web host.
The script to be executed is located in :
/home/[login ftp]/www/script.sh
So I've created a cron on the OVH interface with this setup:
Command to execute : ./www/script.sh
Language : Other
The script contains :
#!/bin/bash
echo "Hello World"
If I execute the script on ssh console, everything is fine.
But, with the OVH cron, no way :
[2021-04-05 21:36:02] ## OVH ## END - 2021-04-05 21:36:02.246979 exitcode: 255
[2021-04-05 22:05:00] ## OVH ## START - 2021-04-05 22:05:00.778348 executing: /homez.1003/[login ftp]/www/test.sh
[2021-04-05 22:05:00] Cannot execute command for user '[login ftp]': Exec Format Error (err: -1)
[2021-04-05 22:05:00]
[2021-04-05 22:05:00] ## OVH ## END - 2021-04-05 22:05:00.813826 exitcode: 255
Lastly, here is my .ovhconfig file :
app.engine=php
app.engine.version=7.4
http.firewall=none
environment=production
container.image=stable64
I've tried many configurations without no success.
FYI, I also have an .htaccess on the root folder (so in /home/[login ftp]) that redirect on an other path. Could this have any consequence on the cron execution ?
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/path/to/
RewriteRule ^(.*)$ /path/to/$1 [L]

It seems that it is not possible to execute an sh file on ovh/cron. I've tried with php file and it works like a charm :
<?php
shell_exec('echo "Hello World"');
?>
I'm pretty surprise of that because there many example on the web showing an sh executable as cron. Maybe ovh has changed it policy recently.

I got a support answer today that "Other" cronjobs are no longer working and menu entry will be gone soon.

Related

Virtual Host, works but any links get instant 404 error message

I created and setup a LAMP stack, inserted the database + files + code, and went to the local host. The main page pulls up (GOOD!) but, any links on the main page, no matter what it is.. gives me this:
Not Found
The requested URL /user/register was not found on this server.
Apache/2.4.18 (Ubuntu) Server at cbirc.com Port 80
I am assuming this is a apache issue? If someone could fill me in. Its strange that the main page pulls up fine, but any links to any other part of the site gives me this error code.
If index is working, It sound that RewriteEngine was not set to ON in apache configuration, Try to add this to your .htaccess file or vhost (/etc/apache2/sites-available/yourdomaine.com) :
<ifModule mod_rewrite.c>
RewriteEngine On
</ifModule>
If you modify vhost, don't forget to restart apache :
sudo apachectl configtest #Test before restart
sudo apachectl restart
if module is not installed :
sudo a2enmod rewrite
You can also check the Base URL in your HTML if you have one

CentOS 7 Apachect1 Removing a Virtual Host

[SOLVED]
I have a CentOS 7 VPS running Apachect1 and I have just finished a project that required me to create multiple subdomains. Now that I am done I do not need them so I want to go back and clean up a bit.
I had originally created the files
/etc/httpd/sites-available/site1.domain.com.conf
/etc/httpd/sites-available/site2.domain.com.conf
/etc/httpd/sites-available/site(...).domain.com.conf
and
/etc/httpd/sites-enabled/site1.domain.com.conf
/etc/httpd/sites-enabled/site2.domain.com.conf
/etc/httpd/sites-enabled/site(...).domain.com.conf
They were working and everything and all I thought I had to do to remove these domains were to delete those files and restart apache. I did this but I can still access these websites. Any idea?
I ran these commands:
# apachectl restart
# systemctl restart named.service
# systemctl start named
# systemctl enable named
# systemct1 status httpd.service
I have even restarted my server but nothing. Sorry if I missed anything obvious, I am still new to Linux. Thank you for any help.
there are several things you can do.
the first thing is to verify /etc/httpd/conf/httpd.conf to make sure how VIRTUAL HOSTS are defined in you file and if there are declared there.
Centos httpd config file
If there are no VIRTUAL HOST THERE. you will need to make sure that those files do not exist
/etc/httpd/sites-available/site1.domain.com.conf
/etc/httpd/sites-available/site2.domain.com.conf
/etc/httpd/sites-available/site(...).domain.com.conf
You could also try this commands
service httpd stop (to stop service)
service httpd start (to start service)
Let me know if this works :)
SOLVED
So I figured out how to work around this. I am not sure why but the issue was, anytime I went to a non existing subdomain I would get redirected to /var/www/SubdomainA/index.php
The way I worked around this was I went to each of my subdomains and added a rewrite condition in the .htaccess file that said, if the subdomain is not the specified subdomain, then send it to the main site.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www|SubdomainA)\.example\.com
RewriteRule .* http://www.example.com%{REQUEST_URI} [R=301]
Hopefully this will help someone at some point.

How can i get mod_rewrite and .htaccess working with cakephp?

I'm trying to get cakephp working locally on my mac - yosemite. I have apache and php working locally in my /~user/Sites directory... I can hit a php ini file ok and have an install of wordpress in another directory.
I've hooked it all up apart from getting the urls rewriting... I followed the steps on the cake site:
http://book.cakephp.org/2.0/en/installation/url-rewriting.html
Now all I get is 404 not found!.
The three .htaccess files have the default content with an additional RewriteBase pointing to the folder its installed in, in my Sites folder.
Any ideas what I'm doing wrong? I've read the other posts on this and none of them helped!
Thanks
First, confirm mod_rewrite is enabled by (on command line):
# a2enmod rewrite
If it just got enabled using the command above, restart apache:
# /etc/init.d/apache2 restart
These types of errors should hit your error.log .. while trying to load the site, hold the error log open:
# tail -f /var/log/apache/error.log
and try to access your page again.
If this doesn't help you solve the problem, paste in your rewrite rules so we can take a peak.

Make zend framework 2 work without Virtual Host

I had finished my first web application using Zend Framework 2 and I'm about to put it online. But may web host doesn't allow me to change my vhost configuration! The .htaccess file is allowed.
My .htaccess file in Public folder is like this:
RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
My Folder Directory Structure is like this:
-ProjectName
-config
-module
-vendor
- zendframework
-public
- css
- img
- JS
- index.php
Index.php File:
<?php
/**
* This makes our life easier when dealing with paths. Everything is relative
* to the application root now.
*/
chdir(dirname(__DIR__));
// Decline static file requests back to the PHP built-in webserver
if (php_sapi_name() === 'cli-server' && is_file(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) {
return false;
}
// Setup autoloading
require 'init_autoloader.php';
// Run the application!
Zend\Mvc\Application::init(require 'config/application.config.php')->run();
So my question is: How to set up my ZF2 app with only .htaccess files?
Also I want to call default my "Front" Module Call While my site www.example.com run.
Your Answer will be appreciated.
Thanks in advance.
It seems that you need to enable the mod_rewrite module and restart Apache.
Zend Framework 2 requires that you have Apache's *mod_rewrite* module enabled.
The *mod_rewrite* module is used to rewrite requested URLs based on some rules,
redirecting site users to another URL.
In Debian or Ubuntu Linux
To enable Apache mod_rewrite module, type the following commands:
cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/rewrite.load ./rewrite.load
The command above creates a symbolic link in the mods-enabled directory,
this way you enable modules in modern versions of Apache web server.
Finally, restart Apache web server to apply your changes.
I> A symbolic link in Linux is an analog of a shortcut in Windows.
In Fedora, CentOS or Red Hat Linux
In these Linux distributions, mod_rewrite is enabled by default, so you don't need to do
anything.
Restarting Apache Web Server
After editing configuration files, you usually have to restart Apache HTTP Server
to apply your changes. You do this with the following command (in Debian or Linux Ubuntu):
sudo service restart apache2
or the following (in Fedora, CentOS or Red Hat):
sudo service restart httpd
As a result, you should see output like below:
* Restarting web server apache2
apache2: Could not reliably determine the server's fully qualified
domain name, using 127.0.0.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully
qualified domain name, using 127.0.0.1 for ServerName [OK]

500 Internal Server Error when using .htaccess with RewriteEngine

I am on the shared host Bounceweb and I am trying to add some rewrite rules to make my links look prettier.
One of these rules is to make the url: http://mysite.com/upload point to: http://mysite.com/upload.php. I have this in my .htaccess file:
RewriteEngine on
RewriteRule ^upload$ upload.php
but all it's giving me is a 500 Internal Server Error. I looked at my logs and this comes up a lot:
[alert] [client 81.179.29.185] /home/minecraf/public_html/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
Does this mean my host doesn't support .htaccess? Pretty lame if they don't. I've already tried changing the permissions of .htaccess to 777 and it doesn't help.
Thanks!
\xef\xbb\xbf are three invisible junk characters (at least from Apache's perspective) called the Unicode BOM, or byte order mark. Apache thinks that those characters are part of the command that follows right after. This is what you see in the log, though the characters are escaped so they're visible to the naked eye. \xef\xbb\xbfRewriteEngine
In your editor, especially if your editor is Notepad, make sure you're saving your file without a BOM. This should be selectable in the save as dialog or elsewhere.
It might be the mod_rewrite module is not loaded.
Windows xampp : Open xampp/apache/conf/httpd.conf and uncomment mod_rewrite module.
Windows wamp : Open wamp/bin/apache/Apache2.x.x/conf/httpd.conf and uncomment mod_rewrite module.
Ubuntu : a2enmod rewrite && service apache2 restart
or cp /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
Then reload apache
To remove the BOM in unix use vi and below command
: set nobomb
: wq
Try this:
a2enmod rewrite
/etc/init.d/apache2 restart
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
rewriterule ^upload$ upload.php
</IfModule>
try this.
I had this problem and solved it with:
sudo a2enmod rewrite
sudo service apache2 restart
Just save your .htaccess file with UTF-8 encoding (without BOM) and upload.
Recommended to use Notepad++. (in my case that helped).
atb

Resources