Difference between revisions of "NATS4 Apache Configuration"

From TMM Wiki
Jump to navigationJump to search
m
 
 
(17 intermediate revisions by 4 users not shown)
Line 3: Line 3:
 
}}
 
}}
  
== Executing PHP Pages ==
+
== Join Link Issues ==
Find the following line in your Apache httpd.conf:
+
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:
  
 
<pre>
 
<pre>
AddType application/x-httpd-php
+
AddType application/x-httpd-php .php
 
</pre>
 
</pre>
  
Line 16: Line 19:
 
</pre>
 
</pre>
  
== FollowSymLinks ==
+
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 [[ct#Site|site]], ensure you have the following two lines in your Apache configuration:
 
If your linkcodes go to your NATS install instead of your [[ct#Site|site]], ensure you have the following two lines in your Apache configuration:
  
Line 42: Line 47:
 
</pre>
 
</pre>
  
== Zend Optimizer ==
+
== Custom PHP Handlers ==
To use Apache 2.0 with Zend Optimizer and NATS, change all of the lines
+
<small>(As of NATS version 4.1.22.2)</small>
starting with SetHandler in your ''nats/www/.htaccess''. Replace the
 
SetHandler with ForceType. For example:
 
  
'''Old'''
+
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.
 +
 
 +
<b>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.</b>
 +
 
 +
Add this to your NATS virtual host:
 
<pre>
 
<pre>
<Files ttrack>
+
Define nats-php-handler [handler]
SetHandler application/x-httpd-php
 
</Files>
 
 
</pre>
 
</pre>
  
'''New'''
+
Where [handler] is the name of the handler you wish to use. For example:
 
<pre>
 
<pre>
<Files ttrack>
+
Define nats-php-handler application/x-httpd-php56
ForceType application/x-httpd-php
 
</Files>
 
 
</pre>
 
</pre>
  
Also add "AcceptPathInfo On" to the virtual host configuration in Apache's
+
=== If you're using PHP-FPM ===
httpd.conf.
+
* 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:
 
+
<pre>
== Apache 2 ==
+
Define nats-php-handler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
Most of our .htaccess files have the following lines:
+
</pre>
  
 +
* You may need to ensure that SetHandler is set. For example (depending on setup, needs, socket location, etc):
 
<pre>
 
<pre>
<Files track>
+
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler application/x-httpd-php
+
SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost";
</Files>
+
</FilesMatch>
 
</pre>
 
</pre>
  
Apache 2 requires you change the lines above to the lines below:
+
* 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:
 
 
 
<pre>
 
<pre>
<Files track>
+
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
SetOutputFilter PHP
 
SetInputFilter PHP
 
</Files>
 
 
</pre>
 
</pre>
 +
 +
=== 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.
 +
* <b>Apache defined variables are globally scoped, which means if you set a variable in your virtualhost, it can affect other virtualhosts as well</b>.
  
 
== See Also ==
 
== See Also ==
 
* [http://httpd.apache.org/docs/2.0/misc/perf-tuning.html Apache2 Performance Tuning] -- Official documentation about tuning your Apache for maximum performance.  (Apache 2)
 
* [http://httpd.apache.org/docs/2.0/misc/perf-tuning.html Apache2 Performance Tuning] -- Official documentation about tuning your Apache for maximum performance.  (Apache 2)
 
* [http://httpd.apache.org/docs/1.3/misc/perf-tuning.html Apache Performance Tuning] -- Official documentation about tuning your Apache for maximum performance.  (Apache 1.3)
 
* [http://httpd.apache.org/docs/1.3/misc/perf-tuning.html Apache Performance Tuning] -- Official documentation about tuning your Apache for maximum performance.  (Apache 1.3)
 +
 +
[[Category:NATS4 Setup]]

Latest revision as of 16:55, 21 September 2023

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