using directadmin resetting counter in counter.pl script running on website - perl

my client side has counter.pl script running on homepage. that displays visitors counter
the client wants to change the visitor counter value.
when i checked the code in index.html,it points cgi-bin/counter.pl script
But wen i try to search cg-bin folder ther are only two files counter.jpg and .htaccess
now how to find the counter.pl script and edit ...!!!??
thanks in advance for any help

Check the web server configuration to see where the cgi-bin directory really is. If you're using apache then you want to look for something like this:
ScriptAlias /cgi-bin/
in the httpd.conf and related files. The actual cgi-bin directory is often located somewhere outside the DocumentRoot directory.

Related

three ways to let PHP and a regular user edit the same files

I am a web developer, and for some upcoming projects I would like to use a file-based CMS. This means that many of the files I create at the start must be editable by the PHP user later, but also remain editable for my user (and also the other way around). My PC runs Debian 9, which I love but am not super knowledgeable about, and I have also just set up a local network server with Debian 9 for backups and possibly file sharing. (I'm using Webmin to configure this, which reflects my level of command line skills).
On my online shared hosting server, the PHP user and the FTP user seem to be the same, and 644/755 permissions work fine, this is also recommended by the CMS I'm using. I would like to mimic this on my computer so I don't have to fiddle with permissions all the time. But how do I do this? Currently, my regular user (anna) does not have access to www-data's files and vice versa. Putting them in the same group still means changing file permissions. Making anna the PHP user is a Bad Idea (as far as I understand it) because anna has sudo permissions.
So far I have researched three possible solutions that I don't really know very much about, and I would like to know which is the best route to take.
Develop locally on my computer and use apache-mpm-itk or suPHP to let PHP edit the files (I got that idea from this question on ServerFault).
Develop locally on my computer and rsync the files to my server with grunt-rsync, and somehow get rsync to set the ownership to www-data (another ServerFault thread helping here).
Mount the project's server directory, which is owned by www-data, on my computer with SSHFS and then either edit the files on the server directly or copy them over from my local directory with grunt-copy.
What do you think: from a security and ease of use perspective, which is the best way? Or do you know an even better one?
Thank you for taking the time to read and think about this!
Anna~
I figured it out! I finally ended up reading about running PHP as CGI instead of as an Apache module, and that this would solve my permissions problem. Plus, as far as I understand it, there are no extra security precautions to take when I'm the only one working with it on my local computer.
In case someone comes across this who might find it helpful, here's what I did (basically following these instructions):
I installed php7.0-fpm
Edited /etc/apache2/sites-enabled/000-default.conf and put the following just before </VirtualHost>:
DirectoryIndex index.php
<LocationMatch "^(.*\.php)$">
ProxyPass fcgi://127.0.0.1:9000/var/www/html
</LocationMatch>
I activated the Apache module proxy_fcgi (via Webmin, which apparently does an automatic Apache restart)
In /etc/php/7.0/fpm/pool.d/www.conf I commented out a listen line and put another below like this:
; listen = /run/php/php7.0-fpm.sock
listen = 127.0.0.1:9000
I then restarted PHP-FPM with this command: /etc/init.d/php7.0-fpm restart (a little different from the instructions, I'm on Debian 9). After that, phpinfo() gave me the Server API "FPM/FastCGI".
And finally, I changed the user and group from www-data to anna in three places, twice in /etc/php/7.0/fpm/pool.d/www.conf and then once more in /usr/lib/tmpfiles.d/php7.0-fpm.conf (this last bit may be Ubuntu/Debian specific, my thanks go to Keith for a comment on StackExchange).
And that was it! :-)

Change default directory for website in Amazon EC2 Linux instance

I want to be able to install a Zend - based site on Amazon EC2 Linux instance. To be able to do that, I need to have the main directory name as "public" rather than "html" as is default for EC2.
How can I change the path to the site's default directory from /var/www/html/ to /var/www/public/ ?
Thank you in advance for your help!
Oliver is on the right track. You need to do 2 things:
Update the DocumentRoot statement within the httpd.conf file to your new home directory.
Restart your web service for the change to take effect.
So for example, do the following command:
sudo vi /etc/httpd/conf/httpd.conf
Then look for the following line by typing /DocumentRoot + ENTER in the vi editor:
DocumentRoot "/var/www/"
Now just change the document root directory to whatever you want.(In the vi editor, move the cursor where you want it, press i to switch to insert mode, modify the code, then press ESC to get out of insert mode.) You can (and probably should) also change any <Directory statements that immediately follow, as these relax some access standards and shouldn't apply at a level above your web root. For example, you may see this:
#
# Relax access to content within /var/www.
#
<Directory "/var/www">
I recommend changing this to:
#
# Relax access to content within /var/www/html/drupal.
#
<Directory "/var/www/html/drupal">
Changing the comment is purely for consistency should anyone else review your code later. There are probably at least 2 statements that fit this pattern in the file, so look for and change them.
Save your changes when finished by typing :x and pressing ENTER.
Finally, a crucial step: restart your web service! This is a commonly overlooked step. The command will vary based on your server setup, but will probably be very close to:
sudo service mysqld restart
Check your website when finished to make sure it's going to the right default folder when you just use the domain name with no additional folders. Good luck!

Where is httpd.conf file of a domain? (Plesk, Apache, CentOS, Dedicated Server.)

I'm trying to disable access logging (access_log) for domains. I can't find a way to do it yet, I thought if httpd.conf file exist of a domain maybe I can look into that. So do you know where is httpd.conf file of a domain?
Try
locate httpd.conf
on the commend line.
Note that in newer Apache setups, the configuration is spread across multiple files, but they won't be far from where you find httpd.conf.
I had the same problem, but reading #user1055645 comment in the question, about follow the file:
/etc/httpd/conf.d/zz010_psa_httpd.conf
I found the configuration file here:
/etc/httpd/conf/plesk.conf.d/vhosts/domain.com.conf
If you want to disable access_log you can edit this file and comment with an # the beginning of this line:
CustomLog /var/www/vhosts/system/giornalone.it/logs/access_log plesklog
At the end restart apache server to make the changes take effect.

Configure Apache2 to allow clients to run Perl Scripts in cgi-bin

I have two perl scripts; one acts like the client (and queries); the other acts like the server and returns information. On an Apache server (not my own) they work perfectly.
However, on my ubuntu/Linux_box with Apache2 (that I set up) they do not; I get a 404 not found error. The cgi-bin directory is located at usr/lib/cgi-bin. What specific files/settings etc have to be changed/altered/etc. And, what specific changes/alterations/etc. need to be made?
Edit:
I changed the httpd.conf and tried both of the following (but neither worked):
ScriptAlias /diag/ /usr/lib/cgi-bin
ScriptAlias /diag/ /usr/lib/cgi-bin/
I am using a perl script as the client, and it did not work. For illustration purposes I attempted to locate the file with the browser shown in the 2nd pic.
If they are receiving 404, it means that the file does not even exist in the correct location. In the httpd.conf look for the "ScriptAlias" directive that has an entry for cgi-bin, should be something like
ScriptAlias /cgi-bin/ /some_folder/cgi-bin
Once you know the correct folder, the 404 error should go away.
Two other points -
1. For cgi files, ensure that the execute bit is set.
2. Verify that the location of perl matches the one in the perl script.

How to configure MAMP to serve perl CGI scripts (NOT localhost!)

I'm using MAMP-pro to serve my domain to the outside world.
I'm not a very experienced sys-admin, though I've slogged my way through a few basic things. I know what apache is, and I can read-most-of but not generate-without-guide related .conf files.
I've got a perl script which I've tested from the command line and it works (outputs as desired.)
When I try to access said script from the browser, I get 404.
I've tried placing the script at:
/Users/me/Sites/mydomain.com/htdocs/mycgi.pl
/Users/me/Sites/mydomain.com/cgi-bin/mycgi.pl
/Users/me/Sites/mydomain.com/htdocs/cgi-bin/mycgi.pl
and accessing it as:
http://www.mydomain.com/mycgi.pl
http://www.mydomain.com/cgi-bin/mycgi.pl
and all the various combinations, all to no avail (404.)
The script and its container directory have permissions 755.
So, what other steps am I missing? Are there any good set-up guides? I tried the MAMP-Pro manual, but it is filled with such information as "the cancel button cancels the current operation" and not really anything useful. Google turned up several hits that all seem to talk about how to make this work on localhost, but I'm trying to serve this to the outside world.
Any hints?
Thanks!
The official online documentation has a section on virtual hosts. When creating a host for www.mydomain.com you can choose the DocumentRoot which is called "Disk location" within MAMP PRO. If you still get a 404 error, take a look into the error_log for a more specific reason (i.e., where Apache tries to find the file in question).