NATS4 Apache Configuration

From TMM Wiki
Jump to navigationJump to search
NATS 4
NATS Setup
Post-Installation Steps
Apache Configuration
MySQL Settings
Creating Admin Accounts
Multiple Server Setup
Using Memcached for Caching
File Upload Setup
Link Domain
HTTPS Setup
NATS4 Files and Directories
NATS4 Go Live Checklist
NATS3 to NATS4 Going Live Checklist
Moving NATS4
Members Admin
The Members Admin
View Member Details
Add Member
MySQL Auth
Mod Authn DB
Multisite Access
Member Logging
Member Password Retrieval
OpenID Connect
Mod Auth OpenIDC
ID Numbers

Join Link Issues

The following information can be used for your Apache Configuration files if you are having problems with your NATS join links.

Executing PHP Pages

Your server needs to parse both your tour and members area pages for PHP, so that you can use our NATS tracking and join links correctly. If you're currently using html pages, you can tell Apache to parse them for PHP as well. Find the following line in your Apache httpd.conf:

AddType application/x-httpd-php .php

Add the following extensions to the end of the line above:

.php .php3 .html .htm

You might be using a different named PHP handler than "application/x-httpd-php". If so, look for the line that begins with AddType, and includes .php, and modify that.

FollowSymLinks

If your linkcodes go to your NATS install instead of your site, ensure you have the following two lines in your Apache configuration:

<Directory /home/www>
	Options FollowSymLinks
	AllowOverride All
</Directory>

The lines should be in a global virtual host configuration. For example:

<VirtualHost *:80>
        ServerAdmin webmaster@site.com
        DocumentRoot /home/www
        ServerName site.com
        ServerAlias *.site.com
        CustomLog /dev/null common
        <Directory /home/www>
                Options FollowSymLinks
                AllowOverride All
        </Directory>
</VirtualHost>

Custom PHP Handlers

(As of NATS version 4.1.22.2)

NATS assumes that your Apache PHP handler is named "application/x-httpd-php", and makes that assumption when setting up your track links. If your PHP handler is named differently, you can let NATS know your PHP handler by setting the $nats-php-handler Apache variable in your virtual host.

Note: The Define Directive was first made available as a core directive in apache 2.4. So if you are using apache 2.2 than you will need to install the Define module before being able to use this directive.

Add this to your NATS virtual host:

Define nats-php-handler [handler]

Where [handler] is the name of the handler you wish to use. For example:

Define nats-php-handler application/x-httpd-php56

If you're using PHP-FPM

  • You can also use this variable to set the handler variable by giving the full proxy handler path, as you would when setting the php AddType. For example:
Define nats-php-handler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
  • You may need to ensure that SetHandler is set. For example (depending on setup, needs, socket location, etc):
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost";
</FilesMatch>
  • If directives in .htaccess file are not parsing properly, php-fpm could be encountering issue related to 'security.limit_extensions' for items in our .htaccess file. To resolve, you will need to set the directive to match our .htaccess directives. For example:
security.limit_extensions = .php api signup track ttrack qtrack banner strack gallery feed tflash include ptrack rss_stats rss_adtools rss_payments xml_stats xml_adtools xml_payments dump_adtools nats_builder.css charts view_flash zip_tool submit random_banner member-openid-configuration member-openid-keys

Keep in mind

  • You'll still need to set the handler for normal .php files using AddType, as normal. This variable simply allows NATS to know which handler to use for custom shortened links.
  • This change will allow the NATS .htaccess file to be able to use your handler if you're using php-fpm, but there are other concerns to consider when using php-fpm as well -- this variable will not resolve all of them. If looking to setup using php-fpm instead of Apache'd mod_php module, please submit a support ticket.
  • Apache defined variables are globally scoped, which means if you set a variable in your virtualhost, it can affect other virtualhosts as well.

See Also