Apache configuration 2.4 - linux

I need to perform the following configuration on my Apache server, version 2.4, with CentOS system.
The instructions I received are as follows:
Configuring Another Web Server to Serve the Files If another web
server is using port 80 on the same server as Centova Cast, you will
need to use this method.
This method depends upon your knowledge of the other web server you
are using; you must be familiar enough with your web server of choice
to configure it appropriately. Centova Technologies cannot provide
support or assistance with any changes to your web server's
configuration.
To allow "Let's Encrypt" to validate your domain ownership, you must
configure your web server such that any requests for files under the
following URI (replacing example.com with your own domain name):
http://example.com/.well-known/acme-challenge/ ...are configured to
serve files from the following directory:
/usr/local/centovacast/etc/ssl/acme-challenges/ So for example, if you
create a file called
/usr/local/centovacast/etc/ssl/acme-challenges/test.txt, you should be
able to visit http://example.com/.well-known/acme-challenge/test.txt
in your browser and see the contents of the test.txt file.
A few example configurations are provided below. Please note, however,
that differences in your web server configuration may require
additional settings not mentioned here.
Example apache:
Alias /.well-known/acme-challenge /usr/local/centovacast/etc/ssl/acme-challenges
<Directory /usr/local/centovacast/etc/ssl/acme-challenges>
Options None
AllowOverride None
Apache 2.x
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>
Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
I've tried everything and I can't get it to work, how should the correct configuration be done?
My configuration file is located at: /etc/httpd/conf/httpd.conf

Related

How do I make apache2.4 configuration specific to a particular virtualhost so it doesn't affect other virtualhost on a centos server

I have put in my include file which is in this directory /etc/apache2/conf.d/userdata/std/2_4/myusername/sub.domain.com/proxy.conf.
On the file I did proxy reverse to localhost port 5000 for my net core app.
Then I did a post virtualhost include using include editor.
When I try to reach other domain on same VPS I get server temporarily unavailable to handle request error.but when I uncommented the proxy reverse on my include file i was able to reach other domain.
So my question is given the procedure I have taken, why is an include specified for a particular virtualhost affecting other virtualhosts on the server.
Proxy reverse code in the include file is code below
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/ ```
And this include was applied to virtualhost for the particular sub domain, don't know why it affects other virtualhosts.
Then I did a post virtualhost include using include editor.
If this means outside the <virtualhost> then its no wonder it affects all virtualhosts -- outside of <virtualhost> is global.
what i did was i opened up the post_virtualhost_global.conf file found in /etc/apache2/includes/.
then i removed the include statement from the post_virtualhost_global.conf file, then it worked, i dont seem to understand how, but it worked perfectly anyway. i have also applied same practice for subsequent virtualhost proxyreverse includes i have done afterward.

Unable to point Domain to the right public_html in Centos web panel and AWS

I have:
Set AWS EC2 Instance for Centos 7 up
Installed Centos Web Panel.
Associated an Elastic IP to my Insance
In Route 53 of AWS I added a record for my domain which was pointing to the Static IP of my instance.
And in My Domain DNS I provided Nameservers provided by AWS Route 53 for my instance.
I created a new Account in Centos WP and provided the domain.
But still when I open the domain in browser it is loading default Apache page in Centos that is in /usr/local/apache/htdocs/index.html.
which should actually point to /home/username/public_html/index.php
I tried to:
Manually edit the httpd.conf file in Apache
And point domain to user directory
I succeeded, but then the all .php files in that directory started to give 500 Internal error, I think it may be a problem of Nameservers but I don't have any clue,
Can anyone point me to right direction to setup a website in Centos Webpanel in AWS?
My Virtual Hosts Configuration, this is what I tried to put in httpd.conf but when 500 Error started to come I had to remove it.
# vhost_start devo.gq
<VirtualHost 52.56.234.217:80>
ServerName devo.gq
ServerAlias www.devo.gq
ServerAdmin xxxx#gmail.com
DocumentRoot "/home/devogq/public_html"
ScriptAlias /cgi-bin/ "/home/devogq/public_html/cgi-bin/
#
# Custom settings are loaded below this line (if any exist)
# Include "/usr/local/apache/conf/userdata/devogq/devo.gq/*.conf
<IfModule mod_suexec.c>
SuexecUserGroup devogq devogq
</IfModule>
<IfModule mod_suphp.c>
suPHP_UserGroup devogq devogq
suPHP_ConfigPath /home/devogq
</IfModule>
<Directory "/home/devogq/public_html">
Options all
Require all granted
AllowOverride All
</Directory>
</VirtualHost>
# vhost_end devo.gq
After adding this code in httpd.conf file.
still I am still being pointed to default htdocs directory of apache.
in error logs i am getting this error
[Sun Apr 23 17:43:04.554884 2017] [:error] [pid 16402:tid 140288731281152] [client 103.69.219.30:27233] File does not exist: /usr/local/apache/htdocs/devo.php
For me, I installed ssl and it worked.
left menu : WebServer Settings -> SSL certificates
I experienced the same problem with Centos Web Panel on an Oracle Virtual Box where all domains were only displaying the default test page. After trying several methods including the official ones like:
https://wiki.centos-webpanel.com/default-page-displayed-for-all-domains
It boiled down to the IP the domain (account) was being set on.
When creating the account, the shared public IP was chosen by default (in my case). When I changed it to use the local VM IP which the CWP was running on, they started working again. You may have to rebuild the vHosts again (Left Menu --> Apache Settings --> Rebuild Apache vHosts); for me, I realized this after deleting all account so I did not have to rebuild them.

Cloud Agent, Apache, and drupal's .htaccess

Installed Apache and Cloud Agent.
Agent collects information from mod_status. Everything is ok.
However, when I add drupal files (with .htaccess), Agent can't collect stat anymore.
I already tried many configuration and now I am super confused about VirtualHosts. I used standard agent's configuration for virtualhost:
ExtendedStatus on
<VirtualHost 127.0.0.1:80>
ServerName local-stackdriver-agent.stackdriver.com
<Location /mod_status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
</VirtualHost>
In http.conf I changed only DocumentRoot.
Can someone please explain me why the requests go to drupal's folder, and not to local-stackdriver-agent.stackdriver.com VirtualHost?

Configure httpd.conf to add new site on Apache Red Hat Linux

I have linux server (Red Hat Enterprise Linux Server release 5.3 (Tikanga)) with apache installed. It is already used for browsing some documents. Now I would like to add a new Directory (with a html page), so whenever the directory is browsed it can display the html page.
But I am not sure of where all to edit the httpd.conf file
Existing httpd.conf:
When I hit the url "http://servername/eng" it displays list of folders.
Now, I want to add a website to this existing, so when user hit the url "http://servername/builds" it should display a html page in the browser.I have added my "index.html" page in location "/var/www/html/builds/"
For this I added the below code to httpd.conf file
Please let me know what all modifications are required in the conf file
You can do it in a few different ways.
Putting index.html in /build
This requires you to have this setting:
DirectoryIndex index.html
(it should be there by default on most platform.)
Also for this to work, rather than putting new <Directory>, you should put the build/ directory in the directory that holds your http://example.com/ files. For instance:
/var/www/example.com/public_html/eng/
/var/www/example.com/public_html/builds/
/var/www/example.com/public_html/builds/index.html
Storing build/ in folder completely unrelated to example.com, but still be able to reach it via example.com/builds
For this, you need to rewrite the URLs so that example.com/builds redirects the user to the final URL. This is most easily achieved through mod_rewrite. You enable mod_rewrite module in your Apache's configuration, make sure that example.com can have .htaccess files through ensuring proper AllowOverride entry in example.com's <Directory> configuration, create /var/www//example.com/public_html/.htaccess (or similar) file, and fill it RewriteEngine On and RewriteRules you need. More on mod_rewrite in the Internet and in the documentation.
Completely separate virtual server, for example builds.example.com/
In this case, what you're looking for are virtual servers. These are not defined in httpd.conf or configuration itself, but usually have dedicated directory.
For example, to add builds.example.com that works for port 80, you'd need to create following entry:
<VirtualHost *:80>
ServerName builds.example.com
DocumentRoot /var/www/builds.example.com/public_html/
</VirtualHost>
Where to put this? Well, it depends on the platform. For Debian, you put this in a new file in /etc/apache2/sites-available/, e.g. /etc/apache2/sites-available/example.com, and symlink to it in /etc/apache2/sites-available (on Debian, you can do this easily with a2ensite <NAME_OF_FILE>. On your platform this procedure might be different, so look it up ("adding virtual servers on " would be a start). After adding virtual servers, you need to reload your Apache configuration.
Please let me know if this satisfies your question, if not, I'll edit the answer accordingly.

.htaccess deny from all

I have copied one of my old applications and renamed it to New_application. I want to access .htaccess file that is inside the New_application folder. When I opened it with my text editor, it just showed Deny from all. I tried to open .htaccess in my old application, it showed Deny from all too. I remember I was able to edit it before but not sure what I can't now. Any thoughts? Thanks a lot.
Deny from all
is an .htaccess command (the actual content of that file you are trying to view). Not a denial of being able to edit the file. Just reopen the .htaccess file in the text viewer of choice and make the alterations as you so desire, save it, then reupload it to your folder of choice.
Though I think inadvertently you are blocking even yourself from viewing said application once uploaded.
I would do something like:
order deny,allow
deny from all
allow from 127.0.0.1
which will deny everyone but the IP in the allow from line, which you would change the IP to match your IP which you can obtain from http://www.whatismyip.com/ or similar site.
This syntax has changed with the newer Apache HTTPd server, please see upgrade to apache 2.4 doc for full details.
2.2 configuration syntax was
Order deny,allow
Deny from all
2.4 configuration now is
Require all denied
Thus, this 2.2 syntax
order deny,allow
deny from all
allow from 127.0.0.1
Would ne now written
Require local
You can edit it. The content of the file is literally "Deny from all" which is an Apache directive: http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#deny
A little alternative to #gaspĀ“s answer is to simply put the actual domain name you are running it from. Docs: https://httpd.apache.org/docs/2.4/upgrading.html
In the following example, there is no authentication and all hosts in
the example.org domain are allowed access; all other hosts are denied
access.
Apache 2.2 configuration:
Order Deny,Allow
Deny from all
Allow from example.org
Apache 2.4 configuration:
Require host example.org

Resources