I have a cgi script that I know works (as far as the code is concerned), but which cannot be accessed through my website. My hosting provider simply states that I need to edit the .htaccess file, but I have no idea what options/handlers I need to set in order to make the contents of a directory execute like c++.
How is this done?
You can't on this service provider. A quick search of the Bluehost Kb gave this: https://my.bluehost.com/cgi/help/48
Our LINUX web servers have the capability to run CGI scripts in your own "cgi-bin" directory. Scripts may be written in Perl, Python and CGI languages.
Here are some helpful tips to follow when installing scripts:
Upload to your cgi-bin directory to ensure proper file permission settings.
All scripts on our server must have permissions set to 755 (rwx-rx-rx). If you need help in changing script permissions, please see our article about setting file and user permissions.
Upload in ASCII transfer mode (and NOT BINARY mode)
The first line of each script must read: a) #!/usr/bin/perl (for Perl) b) #!/usr/bin/python (for Python)
Ensure the permissions are set to 755
However, there is nothing stopping you just trying just putting your exe in the cgi-bin dir and seeing if it runs, but this probably won't work.
In this case, you'd need to relink any C++ against the local target server, and I doubt that Bluehost would facilitate this -- just too much support hassle for the few $ / month that you pay.
Related
I've tried every solution I've found in the last two days on this and other sites. None work.
I'm trying to set two OS level environment variables/commands for the apache user account on centos 6.10. Apache version is 2.2.5. See final paragraph for why I'm having to do this. Alternative solutions are also welcome.
Specifically these commands/variables:
. /opt/rh/python27/enable
export set CLOUDSDK_PYTHON=/opt/rh/python27/root/usr/bin/python2
I have:
Put them in /etc/sysconfig/httpd and /etc/init.d/httpd
Tried various version of these commands
Switched apache to use bash, created .bashrc in /var/www/, gave apache ownership and set permissions correctly and put them in there. I realize this is bad practice, its a test server and I was out of other ideas.
I can't get them to persist beyond a single exec statement in php (where I still have to call both listed commands) or a single su -s /bin/bash apache -c "[command]" execution.
Does anyone know how to get these to persist for the apache user?
Why am I doing this?
I am doing this because Google Cloud Cloud SDK has PHP code that doesn't work so I'm left with either using CURL or passing exec statements, both of which require this environmental variable nonsense for the executing user. To run Google Cloud SDK commands you have to have version 2.7 of python installed, which you can't upgrade to on centos 6.10 without breaking the OS, unless you install it concurrently somewhere else per: http://jhurani.com/linux/2018/07/30/GCSDK-on-centos6.html doing that means I have to set whatever user account is executing code to use the new version of python. Which is apache in this case. Works fine on my normal user account, but I can't get the apache account to respect these changes beyond a single execution, even though everything I read says that it should.
Any help would be appreciated. Thanks for you time and any insight you'd care to share.
Could you try to export the variables in /etc/sysconfig/httpd
export mydocroot=/var/www/html
Then configure the Virtual Host
<VirtualHost *:80>
DocumentRoot ${mydocroot}
</VirtualHost>
Finally restart the service
systemctl restart httpd
In addition, I found that you can also do it through the .httaccess file with SetEnv assuming that it's enabled on the website.
SetEnv SPECIAL_PATH /foo/bin
That's all you need to add the environment variable into the .htaccess file
Problem
The question pretty much says it all. I used the plugin: "cf local" to get the .droplet file for my app in PCF. However, I have no idea how to expand or view the contents of the file.
What I tried
I tried adding a .zip at the end, but that did not work.
I tried viewing in NotePad, but that did not work.
Notes
We are using a Diego back-end which prevents us from using "cf files".
It shouldn't matter but we are deploying a .NET application
Related: Is it possible to download all files of an application in Cloud Foundry?
It's a gziped tar archive. Try adding a .tgz or .tar.gz extension. You may need a third party archive tool, I don't know if Windows will open that file by default. 7zip or something comparable should open it.
Daniel was on the right track, however I wanted to post exactly what I used as an alternative to an extraction utility.
I found that the easiest way is to use bash, within Windows. When we installed Github desktop there was an option to use bash and most of us, in my area, have done this.
If you have already installed it then: Goto Preferences an choose your Git-Shell. Under default Shell you can choose between: CMD, Git Bash, Powershell or Custom.
Once that is in place you can navigate to the folder where the .droplet file lives and execute the following command:
tar -xvzf app-name.droplet
This will extract the contents into a folder called "app" in the current directory which has the contents of your asset that would be in PCF.
I have a code that is 100% fully functional when compiled in g++ and run in terminal. The code uses wget and curl. When I compile it in to a cgi file and have my html webpage call the script then the curl part of the code does not do anything.
What curl is doing is that it is downloading a webpage which is very critical for my program. I have my apache2 server setup, the cgi file is in cgi-bin folder and everything works except the curl doesnt work in the compiled cgi file.
What are some of the ways to fix this? I have tried many things and none of them seem to work. Thank You
It's most likely to be either permissions, paths, or environment variables. Try TEMPORARILY relaxing all permissions - maybe making your curl setuid root and adding in code to check return values and error codes from all your system calls. Try outputting all your environment variables in Terminal and in CGI mode and diffing them.
I am very new to apache and django, so execuse me if this question is simple. I am trying to deploy an existing site to an apache server. For the time being, the site is still in development so I am only deploying it as a virtualhost on my local machine.
I am using Django's WSGI module in the deployment. In my site's config file, I have the following aliases:
Alias /media/ /home/tester/Desktop/siteRootDir/media
Alias /content/ /home/tester/Desktop/siteRootDir/content
WSGIScriptAlias /c /home/tester/Desktop/siteRootDir/deploy/site.wsgi
When I run apache and go to localhost/c I was getting the (13)PermissionDenied error in the apache log. To get around that error, I (admitedly stupidly) ran
chmod -R 777 /home/tester/Desktop/siteRootDir
I know that is not the way to deal with the issue, but I just wanted the site to work so I can continue its development.
So my question is, what are the correct permission settings to the siteRootDir directory and its sub-directories such that the site will run and I do not expose unnecessary files in the directory.
Also, I realize that this is not an ideal set up and I will likely run into problems when I deploy the site in production. Can anyone please suggest a better organizational approach to this?
Thanks!
The tightest permissions possible would be 0600 for files and 0700 for dir's and as a owner the user owning the apache processes. This user differs per OS and flavor (e.g. for OSX it's www, for Debian/Ubuntu it's www-data).
This would probably too tight for a development server. At least would you like to be able to modify all your files through your IDE of text editor, so either you should add ACLs for yourself (i.e. the user that edits the Django files, templates and static files).
Also, in a production server you want the apache user to be able to write to directories that hold web uploaded content. That would be somewhere in your static files section (or on a different dedicated static files server).
I am writing a CGI program in C++. It is supposed to run on version 2.2 of the Apache HTTP Server and it needs to connect to Oracle Database 10g.
I tried to run this CGI program without httpd and it could connect to the Oracle database successfully, but once I ran it through the httpd server it wrote the following message in error_log.
Error while trying to retrieve text for error ORA-12546
How can I solve this problem?
That generally means that you have encountered an ORA-12546 error, but that your client library doesn't have the actual error messages installed. That's not a problem, you can search for the error numbers here. In your case, it's "TNS:Permission denied".
Does your CGI user have permission to access tnsnames.ora?
Just a guess, but a common cause for this type of thing is that the ORACLE_HOME environment is not set for your CGI program. Apache usually starts up at boot time ans so skips all the /etc/profile type stuff.
You will need to ensure both ORACLE_HOME is set, and depending on your system setup you may also need LD_LIBRARY_PATH updated to include $ORACLE_HOME/lib. You either need your program to set the environment, or have a SetEnv directive in your apache config. Bet way to see if this is the issue is just write a test CGI which dumps all the environment variables.
Now if the CGI is running under mod_perl its a bit trickier because mod_perl tends to be pretty anal about environment security. Think we ended up using the Perl*Something*Require directive to set it up within the perl. Sorry for being vague, was years ago....