Difference between revisions of "LAMP Server"
Line 99: | Line 99: | ||
== Configuration of HTTPD == | == Configuration of HTTPD == | ||
The new configuration file for the Apache HTTPD server is in /usr/local/apache2/conf. This is a single file (unlike OpenSUSE's multiple-file system in /etc/apache2. Simply edit httpd.conf to meet your needs. For a simple local server you might have the following entries in addition to the defaults: | The new configuration file for the Apache HTTPD server is in /usr/local/apache2/conf. This is a single file (unlike OpenSUSE's multiple-file system in /etc/apache2. Simply edit httpd.conf to meet your needs. For a simple local server enabling cgi and uploads you might have the following entries in addition to the defaults: | ||
Line 113: | Line 113: | ||
AllowOverride None | AllowOverride None | ||
Require all granted | Require all granted | ||
</Directory> | |||
<IfModule alias_module> | |||
ScriptAlias /cgi-bin/ "/data/www/cgi-bin/" | |||
</IfModule> | |||
<Directory /data/www/cgi-bin> | |||
Options +ExecCGI | |||
AddHandler cgi-script .cgi .pl .py | |||
</Directory> | </Directory> | ||
Revision as of 03:00, 27 December 2012
The telescope control computers, servers, and workstations at Moore and Mt. Kent Observatories run under Linux, typically the OpenSUSE distribution with an Xfce desktop environment. The public servers, and increasingly our internal operations, also depend on server-side technology to provide interactive computing and remote access while minimizing the need for software that depends on the end-user's computer system. To this end, we use the Linux-Apache-MySQL-PHP (LAMP) model, and add Python and SQLite for many applications.
This page provides a brief guide to installing these components.
Installation of Apache HTTPD and PHP from Source
From openSUSE using YAST:
Install the standard LAMP server package including --
Apache
MySQL
PHP
Install libsqlite-3-0 to provide SQLite libraries (usually by default)
Install most of Python 2.7 (not yet 3.0, using modules in the list for OpenSUSE installation at the observatories)
Although we do not use the distribution's Apache and PHP software, we do use MySQL and the default installation provides internal consistency. However, after installation do not start the default Apache server. We install our own Apache and PHP in /usr/local/ so that this does not interfere with the system defaults, but can be configured for our own uses. (The OpenSUSE configuration of HTTPD is particularly arcane for small systems and individual users.)
Install the Apache server in /usr/local:
From Apache download httpd-2.4.3.tar.gz or the latest stable release and save in /usr/local/src
tar xvzf httpd-2.4.3.tar.gz
cd httpd-2.4.3
Copy or edit the following into ./config.nice:
#! /bin/sh
#
"./configure" \
"--prefix=/usr/local/apache2" \
"--enable-so" \
"$@"
Then run ./config.nice (or run the above commands directly from the command line) and
make
make install
The last command will create /usr/local/apache2 if it does not already exist, and install the software and configuration files there. You will need to edit the configuration file, and start the software using apachectl in /usr/local/apache2/bin (see below).
Install PHP in /usr/local:
From PHP download php-5.4.10.tar.gz and save in /usr/local/src/
cd php-5.4.10
Copy or edit the following into ./config.nice:
#! /bin/sh # # Created by configure
'./configure' \
'--prefix=/usr/local/php' \
'--with-gd' \
'--with-zlib' \
'--with-apxs2=/usr/local/apache2/bin/apxs' \
'--with-libdir=/lib64' \
"$@"
Then run ./config.nice (or run the above commands directly from the command line)
make
make install
The last command will add php support to /usr/local/apache2/conf/httpd.conf if it does not already exist, and install the library and configuration files in
/usr/local/php. You should copy php.ini-development to /usr/local/phplib64/php.ini .
Configuration of HTTPD
The new configuration file for the Apache HTTPD server is in /usr/local/apache2/conf. This is a single file (unlike OpenSUSE's multiple-file system in /etc/apache2. Simply edit httpd.conf to meet your needs. For a simple local server enabling cgi and uploads you might have the following entries in addition to the defaults:
LoadModule cgi_module modules/mod_cgi.so LoadModule php5_module modules/libphp5.so
DocumentRoot "/data/www/htdocs" User wwwrun Group www
<Directory "/data/www/htdocs"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
<IfModule alias_module> ScriptAlias /cgi-bin/ "/data/www/cgi-bin/" </IfModule>
<Directory /data/www/cgi-bin> Options +ExecCGI AddHandler cgi-script .cgi .pl .py </Directory>
<Directory /data/www/htdocs/remote> Options +ExecCGI AddHandler cgi-script .cgi .pl .py </Directory>
<Directory /data/www/htdocs/archive> AllowOverride AuthConfig AuthType Basic AuthName "Restricted Files" AuthUserFile /usr/local/apache2/passwd/passwords1 Require valid-user </Directory>
<Directory /data/www/htdocs/upload> AllowOverride AuthConfig AuthType Basic AuthName "Restricted Files" AuthUserFile /usr/local/apache2/passwd/passwords1 Require valid-user LimitRequestBody 524288000 </Directory>
<IfModule dir_module> DirectoryIndex index.html index.php </IfModule>
<IfModule mime_module> AddHandler cgi-script .cgi .py .pl AddType application/x-httpd-php .php </IfModule>
Configuration of PHP
The PHP configuration file is php.ini in /usr/localphp/lib64 . The default file will work as is, but modify it larger upload and download file sizes. Edit the entries for these two lines and change them to values appropriate for your use, such as
post_max_size = 500M upload_max_filesize = 500M
Starting and Stopping HTTPD
Control of the local installation of httpd is through /usr/local/apache2/bin/apachectl. You may run this from the command line, and as root to start the server
cd /usr/local/apache2/bin
./apachectl start
or to stop the stop the server
cd /usr/local/apache2/bin
./apachectl stop
For automatic starting at boot, rather than change the system configuration that is already set up for its own server, add this to /etc/rc.d/boot.local -
/usr/local/apache2/bin/apachectl start