Difference between revisions of "LAMP Server"

From SharedSkies
Jump to navigation Jump to search
Line 131: Line 131:
  
 
cd /usr/local/apache2/bin
 
cd /usr/local/apache2/bin
 +
 
./apachectl start
 
./apachectl start
  
Line 137: Line 138:
  
 
cd /usr/local/apache2/bin
 
cd /usr/local/apache2/bin
 +
 
./apachectl stop
 
./apachectl stop
  
Line 142: Line 144:
 
For automatic loading 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 -
 
For automatic loading 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
+
/usr/local/apache2/bin/apachectl start

Revision as of 19:41, 24 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/lib/php.ini and edit this file as needed.

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:

DocumentRoot "/data/www/htdocs"
User wwwrun
Group www
<Directory "/data/www/htdocs">
   Options Indexes FollowSymLinks
   AllowOverride None
   Require all granted
</Directory>
<Directory /data/www/htdocs/remote>
  Options +ExecCGI
  AddHandler cgi-script .cgi .pl .py
</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>

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 loading 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