How to check mod_headers and mod_expires modules enabled in apache - apache

I want to check whether mod_headers and mod_expires modules enabled or not in my server
Is there a way available to list apache enabled/disabled modules using some php function just like we list php information with phpinfo(); function?

All the above answers are wrong. Use instead:
apachectl -t -D DUMP_MODULES
or
apachectl -M

On Debian:
user#machine:~$ /usr/sbin/apache2 -l
Most GNU/Linux distros:
user#machine:~$ /usr/sbin/httpd -l
Ubuntu:
user#machine:~$ ls /etc/apache2/mods-enabled
On Mac OSX:
user#mymac:~$ httpd -l
On Win 7 (64-bit):
C:\Users\myuser>"\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe" -l
Try these commands from a terminal window in all but Windows, which will use CMD instead.

On Ubuntu you can see the list of enabled modules here,
/etc/apache2/mods-enabled

Some versions of PHP/Apache show all loaded modules in phpinfo() under "Loaded Modules".
Speeve's answer shows compiled in modules (x6 on my system):
echo system('/usr/sbin/apache2 -l');
You'll also need to see your enabled modules (x36 for me):
echo system('ls /etc/apache2/mods-enabled/');
To get the list of disabled modules, run this command then cross off all the enabled modules:
echo system('ls /etc/apache2/mods-available/');

Related

How can I check server configuration ("$ httpd -S") in MAMP?

I have previously installed Apache on my Mac Mini using Homebrew, but I'm currently using MAMP. When I issue the terminal command httpd -S to check Apache configurations, it checks the Homebrew configurations. Is there a way I can test the configurations for MAMP? I would like to use the same httpd -S command, but if there's another preferred way to do it for MAMP, that's fine too.
You do it with the -f flag, like this:
httpd -f /Applications/MAMP/conf/httpd.conf -S
This is in httpd options:
Options:
...
-f file: specify an alternate ServerConfigFile

How to enable Brotli on Debian 10 with DirectAdmin?

I'm running the latest version of DA (1.61.3), PHP 7.4.7 en Apache 2.4.43 on a Debian 10 server. I want to add Brotli support en did this:
Installed Brotli package on Debian (apt-get install brotli)
Added brotli module to apache for custombuild, following: https://help.directadmin.com/item.php?id=191 (--with-brotli)
After this I checked at https://www.brotli.pro and https://tools.keycdn.com/brotli-test, but it fails, says: no Brotli support.
In PHP info I see under the section curl this:
Before BROTLI was not mentoined here, so something is installed, but as you can see the value is "No".
What do I have to do more to enable Brotli?
Thanks for help!
Try this ...
Check if the brotli module is really active in Apache:
httpd -t -D DUMP_MODULES
then recompile the php
cd /usr/local/directadmin/custombuild
./build php
./build rewrite_confs

httpd (apache) centos fail to open stream: Permission denied

i'm facing the next error in a centos 7 server
I take a look to similar questions saying that is because SELinux doesn't allow to httpd to write in my /home folder, i've tried changing the owner of the folder without success; try changing the context (chcon) to httpd_sys_rw_content_t of my /home with the same error; try disabling SELinux and the error persists; and in the file httpd.conf change the User and Group from apache to test this didn't work either. My server is:
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core
and
Linux localhost 3.10.0-693.17.1.el7.x86_64 #1 SMP Thu Jan 25 20:13:58 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
When I execute move_uploaded_file() from php -a as user test it works normally, i see that the issue is with the user apache
TLDR:
Do not run setenforce 0 command, this will disable SELinux! You should not disable SELinux for security reasons.
The solution:
You should update policy to make SELinux allow read and write on specific directories:
To allow apcahe to read and write.
chcon -R -t httpd_sys_rw_content_t /path/your_writabl_dir
For read only directories:
chcon -R -t httpd_sys_content_t /path/yourdir
For example you can make your public (document root) directory read only and only allow write on directories that you allow you app to write on:
# Make all read only
chcon -R -t httpd_sys_content_t /var/www/myapp
# Only allow write on uploads dir for example
chcon -R -t httpd_sys_rw_content_t /var/www/myapp/public/uploads

How to configure HHVM with Apache compiled from source?

Today, when HHVM has been updated (Ubuntu 12.04 x64), I try run the fast_cgi install command. Like below:
➜ ~ sudo /usr/share/hhvm/install_fastcgi.sh
Checking if Apache is installed
WARNING: Couldn't find Apache2 configuration paths, not configuring
Checking if Nginx is installed
Nginx not found
My apache was not found because it's in different location/folder: /etc/apache247/
How can I configure this install for a custom apache?
The script for check apache installation is that:
#!/bin/bash
if [ -f /etc/init.d/hhvm ]
then
/etc/init.d/hhvm start
fi
#!/bin/bash
apache_check_installed() {
echo "Checking if Apache is installed"
if [ \( ! -d /etc/apache2/mods-enabled \) -o \( ! -d /etc/apache2/mods-available \) ]
then
echo "WARNING: Couldn't find Apache2 configuration paths, not configuring"
return 1
fi
echo "Detected Apache installation"
return 0
}
Sorry for my english.
You can follow the instructions on the HHVM Wiki to manually configure Apache to talk FastCGI to HHVM.
The installation process comes down to enabling the mod_proxy and mod_proxy_fcgi modules in Apache, then adding ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/path/to/your/www/root/goes/here/$1 to the VirtualHost you want to run HHVM on.

relocate apache's configuration files

is there a chance to use different location for apache's config files (on Windows)? Other than having to compile it myself and setting the proper #define HTTPD_ROOT value.
Thx rezna
This can be done by specifying the -f option when installing apache as a service on Windows.
The -f option accepts the location of the configuration file. For example, if your command to install the service was
httpd.exe -k install -n "MyServiceName"
Add -f "c:\files\my.conf", with your configuration file instead, like so:
httpd.exe -k install -n "MyServiceName" -f "c:\files\my.conf"
See the Apache manual for more information.