Adding to sites-availible on Apache - linux

I'm configuring Apache and the setup documentation has me creating a file in .etc.apache2/sites-availible named after my site (example.com) but doesn't say what type of file this is. I tried to just write it up in TextEdit, but then it saves it as example.com.txt. There is already a default there, but it doesn't seem to have a file type. So how can I may a similar file type to put the virtual host code in?

The extension of the file would not matter. In fact, you can just edit the default file that is already there.
Apache Documentation just recommends you to create a separate file for your domain, sine it is cleaner and easier to maintain.
Once you create that file, and add all the corresponding e.g. vhost configuration, you can run:
sudo a2ensite your_file_name
to tell apache to use your file from now on.

The filetype:
.conf
Put in it all the VirtualHost directives for your domain...

Related

Cpanel is not giving me option to change the root directory for one of my domains

I need to change the root directory for one of my domains,
But in my cpanel i dont find any options, just hard cores of system, but i have very basic knowledge about systems and servers.
How i can change that directory as easy as possible? I just need to change something because im gonna install laravel, and i want to change the public html to the public of laravel.
I was looking for the file that has the apache config, but it says like "the current config doesnt need to be changed or updated, bacause can be overryde", so i tought in Cpanel maybe i got an option for this.
Thanks, By the way i got an VPS, not shared. Using CENTOS 7.9.
Thanks and good night ^^
In cPanel, you can't change main domain directory/document root. If you want to change the document root, just change the main domain to another/random domain. Then add the domain that you want to change the root directory as addon domain
It's not recommended overriding Apache config. It's may break your system. WHM/cPanel exists to manage domains without a system admin knowledge
Do you try change this using console in Centos?
maybe will be better using console and open the file that contain the directory root

How to update ssh configuration files in NixOs

I've been playing with NixOs and was wondering how one can modify a config file.
For example I tried to modify the ssh configuration file /etc/ssh/ssh_config (to allow root ) but
I can't save the file, as it's only a link.
I understand that modifying a file manually is not the way to do (because the system needs
be aware of the modification), so what is the NixOs way to do it ?
See programs.ssh options.
Also note there's an extraConfig for further text in ssh_config.

Is there a security difference between storing files outside of the DocumentRoot versus "deny from all" htaccess directives?

Knowing that a deny from all directive will traverse all sub-directories and files below it, and ignoring the obvious caveats of "if you forget" to copy the .htaccess file or if you typo creating an .htaccess file...
Is there a risk in security between storing non-public files outside of the DocumentRoot versus placing an .htaccess file with a deny from all directive in each non-public directory in the DocumentRoot?
There are a few things to consider here:
.htaccess is only going to protect your file from access over the
web. For example, suppose you have a typical FTP server setup with
virtual users who are restricted to the document root. If an
attacker gains access to your FTP server (which is not that
far-fetched given how insecure most FTP configurations are), they
will have access to both the .htaccess file and any of your
protected files that are in the document root.
That was just one example that may not apply to your environment,
but the idea that I'm really trying to get at is that .htaccess
files don't give you that much depth in your security. They protect
you in one context (access over the Internet) but not in others.
Your server administrator has the ability to disable specific .htaccess
directives, to disable certain Apache modules (which your .htaccess file
may use), and even to disable the use of .htaccess files period. If you
don't have control over your Apache configuration (which I'm assuming
is the case since you're choosing to overwrite it with an .htaccess file),
you also don't really have control over whether your .htaccess file is going
to be respected. It really comes down to your relationship with your
host/server administrator and what they decide to allow.
Finally, if the .htaccess file is writable by the user your Apache
server is running as, a determined hacker can modified that file.
Ex. if you're using Wordpress, many popular themes will demand write
access to the .htaccess file so that they can control URL rewriting.
I'd imagine some other Content Management Systems do the same.
With all that said, using an .htaccess file (or directly altering your Apache configuration files) may still be a perfectly valid security measure for you. It depends on what your environment as a whole looks like -- how your server is configured, what you're trying to protect, etc. Hopefully I at least gave you some things to think about.

php.ini configuration changes in shared hosting account

Am trying to override the default php.ini configuration using .htaccess / ini_set, but the configurations are not getting reflected while executing the script. Here the PHP is installed as fastcgi and am in a shared hosting account. Is there any way to change the php.ini settings or I need to upgrade my account to virtual dedicated server. Please help in this regard.
Thanks for your answers,
to be more elaborate, i want to change the max_execution_time of my php script as am handling with a huge log file need to be parsed. This script exceeds the default configuration in php.in (i.e) 30 secs. As my site is in the shared hosting, am not able to configure it in php.ini, they given a (php.ini)file in the document root ans ask us to configure the values but that is not reflecting.I tried the dynamic way using ini_set, same result.
The include path is .:/usr/local/php5/lib/php
I doubt you will be able to modify everything in the php.ini file on a shared host. The host could've turned the whole ini_set() function off for all I know! A virtual dedicated server might be what you're looking for (I have never encountered this stuff, as I run my own servers).
Just wondering, what are you trying to set?
Try to create a new php.ini file in the directory from where you are executing your script with your required php.ini environment variables.. Also, if it's cPanel hosting that you are using.. there's one more setting that you need to change in the cPanel.. you might be allowed access to turn this setting on or off depending on your web host. I'll post the setting in a moment.. Please confirm if you use cPanel hosting?
For most shared hosting environments, having a copy of php.ini file in your public_html directory works to override the system default settings. A great way to do this is by copying the hosting company's copy. Put this in a file, say copyini.php
<?php
system("cp /path/to/php/conf/file/php.ini /home/yourusername/public_html/php.ini");
?>
Get /path/to/php/conf/file/php.ini from the output of phpinfo(); in a file. Then in your ini file, make your amendments
Delete all files created during this process (Apart from php.ini of course :-) )

question about htaccess file

what is htaccess file? how to create and write that? what is the advantage of using htaccess file?
.htaccess files provide a way to make configuration changes on a per-directory basis. See the official Apache documentation for .htaccess files.
.htaccess allows you to override Apache's (and other servers') main configuration file for a particular directory (and all its subdirectories). To use .htaccess you simply create a new file and name it ".htaccess" (yes, the name is very unusual because it actually consist of only a very long file extension), upload it to you server (if you want to affect your entire site than put is in your root folder), and finally add some directives.
If you wand to see what sort of things you can configure with .htaccess check out this very accessible tutorial: 5 most useful applications of the .htaccess file.
For something more comprehensive visit guide .htaccess.
Hope this helps
This is majorly used for configuration on server the generally things involve in usage are following.
-(redirecting server to specific file)
Redirect permanent /index.html (new path)
For more you can refer to http://httpd.apache.org/docs/2.0/howto/htaccess.html#related

Resources