What is the purpose of the wget startup file option "add-hostdir"? - backup

The wget 1 man pages describe the option "add-hostdir" as follows:
Enable/disable host-prefixed file names. ‘-nH’ disables it.
Unfortunately, I am too ignorant to understand this.
Since "-nH" disables it, it must have something to do with spanning hosts, but it isn't described there either.
Can someone explain what it does?
I am using wget 1.19.1

Consider simple example
wget -r http://www.example.com
create directory www.example.com and place index.html inside it
wget -r -nH http://www.example.com
just places index.html in current working directory, that is you have one level less (top one) of catalog hierarchy when using -nH.
Speaking simply with -nH will not create catalog for each domain.

Related

Configure .htaccess with mod_rewrite one level up approach

The structure of my project is
/var/www/mysite
------pages
------scripts
------other
In it's corresponding virtual host the configuration is:
ServerName mysitename.com
DocumentRoot /var/www/mysite/pages/
Because of that, when serving the index.php from the pages folder, the resources(scripts/images etc ) are not found, as expected, because the page is trying to load them like so. http://mysitename.com/scripts/storage.js.
This of course makes sense.
How would you approach solving this? I am aware that by setting some mod_rewrite rules you can conditionally rewrite urls, is that a way to go about it? Im mainly interested in seeing what my options are here rather than getting one solution like, move your .html file up one layer.
There are 2 possible solutions:
Using alias in your Apache server config (of course you need to have control over Apache config). An example of alias command:
Alias /scripts /var/www/mysite/scripts
<Directory /var/www/mysite/scripts>
Options Indexes
Allow from all
</Directory>
Create a symbolic link inside pages/ directory. For example on *nix systems use this command to create symlinks:
cd pages
ln -s ../scripts .
ln -s ../other .

PHPmyadmin and Wordpress directories access denied

Running wordpress locally on a centOS 7 server running the latest apache, PHPmyadmin and mariadb-server.
IP/wordpress and IP/phpmyadmin on systems within the local network yields "403 forbidden" "you dont have permission to access (directory) on this server."
How can I fix this to allow the website to be seen on the public internet?
Could be a lot of things.
In your main Apache configuration file (e.g. /etc/httpd/conf/httpd.conf on Arch Linux), confirm your DocumentRoot path. The files you want to serve must reside there, or in sub-directories from there (If not, you might want to use an Alias to specify another path). Since you call IP/wordpress and IP/phpmyadmin, then you probably have directories called wordpress and phpmyadmin under your DocumentRoot path.
You also want to check the Directory groups in your Apache configuration file. Under those, the main culprit would be the Require directive set to all denied or something else too much restrictive like ip your_ip.
Finally, PHP can restrict path access with the open_basedir directive. Look for it in your php configuration file (e.g. /etc/php/php.ini on Arch Linux). If the line is commented, you're fine. But if a path is specified, your wordpress and phpmyadmin files must reside there.
Depending on your setup, any directive mentioned above could be in another Apache configuration file (e.g. /etc/httpd/conf/extra/* on Arch Linux).
Take a look at Apache and PHP online documentation for information about those directives.
Probably there is an issue with your directory privileges.
Use the follwing command to check it:
cd your_site_directory
ls -l
You can have a look to have a better understanding on directory privileges here.
As mentioned here apache runs under "apache" user.
Have a look at this post here to fix the issue.
All files should belong at least to apache group. To do it you can use
cd your_site_directory
chgrp -R apache ./*

Creating multiple files for different rewrite rules all using the same http conf file?

Im quite new to rewrite rules so there may be a very simple way of doing this but i cant seem to find much information on it.
Anyway i have a rewriterules file containing about a thousand rules for many different sites, so is there any way to create multiple files just for easier handling of the large amount of rules ?
For example i have three sites:
A.com
B.com
C.com
I want a seperate file for each sites redirects, but also want one universal file for rules that are applicable to all of them ?
Is there anyway to do this ?
If you can use the symbolic links, .htaccess file including all RewriteRules is located to setting directory [Setting Dir].
Therefore in site A document root, you set the symbolic link as
$ cd [Document Root A]
$ ln -s [SettingDir]/.htaccess .htaccess
in the same way, in site B, you set
$ cd [Document Root B]
$ ln -s [SettingDir]/.htaccess .htaccess
...

Not following symbolic link after changing remote server PHP

After changing remote servers (but not the content being hosted in it), my symbolic links are no longer being followed by apache through virtual hosts.
When I go into the terminal and perform ls -alt it shows that the symlink is there and correct.
The path where the symlink is going to (and suppose to be going to is correct) and the content expected is still there.
I have performed svn switch on the root of the content that the symlink is going to so its updated to the current server.
I have checked and opened up all file permissions for the content and subdirectories
I have tried svn switch on the content that s symlinking to the shared content, but am presented with this error:
'.' appears to be part of version 1.7, please upgrade your client version.
I deleted the folder with symlink and re-checked it out through the new server, this is where the symlink doesnt work anymore.
Some of my older projects that were checked out through the old server do follow the symlink to the content with the svn re-directed to the new server.
Also my virtual host which states the option to follow symlinks has multiple places where the same symlink path is used. Each folder inside this vhost has the same substructure to it, but oddly some symlinks work, and others dont.
Any ideas on what I could try to get apache to follow the sym links?
Thanks a lot
Following symlinks is OFF by default on most Apache installs, because they're a security risk - they allow easy violation of document root "jails". if you allow symlinks, it's trivial to have something like ln -s / /site/documentroot/browse and now your entire filesystem is open for viewing by the world.
If you insist on allowing them, then you'll need
Options +FollowSymLinks
in the appropriate <directory>, <virtualhost> or .htaccess1. Relevant docs: http://httpd.apache.org/docs/current/mod/core.html#options

How to avoid user/perms headaches on VPS web server?

I'm using a VPS for the first time and I'm wondering the best way to set up this server that makes sense and has as little effort with permissions setting as possible.
So I use /var/www (all files owned by www-data) for system-wide stuff like PostfixAdmin, phpMyAdmin, etc. For actual domains, they're in ~/www/. So my structure is like this:
~/
www/
domain1.com
domain2.com
logs/
domain1.com
domain2.com
The problem is, certain web apps like WordPress want many files to be writable, and the Apache user is www-data. I've found that even if I chgrp -R www-data .; chmod -R g+w . in a domain, WordPress still complains until the file is actually owned by www-data.
This server has no FTP and will allow me to SFTP in only via key, no passwords. I'm trying to keep this as secure as possible. But if I SFTP in, I'm creating files as myself, not www-data.
I'm looking for advice on how to set up this system so I can just drop in files, edit them, and all the permissions are what they need to be for Apache to have write permissions for whatever it needs to do.
Thanks!
Aha! Solution was to edit /etc/apache2/envvars and change these lines accordingly:
export APACHE_RUN_USER=myusername
export APACHE_RUN_GROUP=myusername
And to also chown /var/lock/apache2 to myself.