Friday, September 07, 2007

HTTPD (Apache) Server Configuration

All these customizations are made by editing the apache configuration file located at /etc/httpd/httpd.conf
You need to edit this file as root.
After you made the changes don't forget to save the file and restart the server:
/etc/rc.d/rc.httpd stop
/etc/rc.d/rc.httpd start

1. ServerAdmin
Find the line that says
ServerAdmin you@example.com
and change the address to your e-mail address

2. Server Port
If your ISP has blocked port 80 you can still make sure your server can be accessed from outside if you use a custom port number.
Find a line that says
Listen 80
or
Listen 12.34.56.78:80
and change it to
Listen:xxxx
where xxxx is the port number you wish to use for the server.
For example my server uses the 1980 port, so in my file the line says
Listen:1980

3. PHP is disabled in the default httpd intallation.
To test this, create e new php file and put in in your htdocs directory (usually /var/www/htdocs) and then try to access it through you web browser (eg. http://localhost/test.php). If it shows the code, PHP is disabled in your server configuration.
To enable PHP find a line that says:
Include /etc/httpd/mod_php.conf
Uncomment this line to enable PHP

4. PHP Configuration options for security and comercial server compatibility:
(modifications be made to /etc/httpd/php.ini )

short_open_tag = On
safe_mode = On
disable_functions = phpinfo, exec, system, shell_exec,proc_open, openlog, pfsockopen, popen, syslog, closelog, fsockopen, passthru, escapeshellarg, escapeshellcmd, proc_close, proc_get_status, proc_nice, proc_teminate
(no spaces between values; it is done this way here only to be readable in the blog)
disable_classes = exec
max_input_time = 30
max_execution_time = 30
memory_limit = 10M
error_reporting = E_ALL
display_errors = On
display_startup_errors = On
register_globals = Off
post_max_size = 2M
magic_quotes_gpg = Off
magic_quotes_runtime = Off
always_populate_raw_post_data = Off
upload_tmp_dir = /tmp/php
(you have to create this)
allow_url_fopen = Off
allow_url_include = Off
SMTP = localhost
(or better, your ISP's)
smtp_port = 25
sendmail_from = your email address
sendmail_path = /usr/sbin/sendmail -t -i

No comments: