Training, Open Source computer languages

PerlPythonMySQLTclRubyC & C++LuaJavaTomcatPHPhttpdLinux

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Apache httpd, MySQL, PHP - installation procedure

If you're installing LAMP (Linux, Apache, MySQL, PHP), what do you do and in which order? Here's a summary of the procedure we followed on todays Apache httpd deployment course - in this case running (tailored) for a single company audience, and tailored for specfic needs.

(I've documented this and reporduced it here as it brings together in a short reminde form material from many different sources / help files, and shows you the decisions taken in real life as we followed the procudures. In the case of the examples, httpd, mysql and PHP were already installed and had to be stopped and deleted before fresh copies could be installed!)

a) Build of httpd (Must do this before we install PHP)

As root

1. Stop the old daemon
2. Take backups of data to be kept
3. cd /usr/local; rm -rf apache2

As admin user

(cd to user's build area)
3. rm -rf httpd-2.2.8
4. tar xzf httpd-2.2.8.tar.gz
5. cd httpd-2.2.8
6. ./configure --enable-proxy --enable-proxy-httpd --enable-proxy-balance --enable-jk --enable-so --enable-rewrite
Note:--enable-so is needed later on for PHP. The other modules were selected because of our requirements later in the day to proxy requests on to another system, to rewrite URLs, and to talk to Apache Tomcat via an AJP 1.3 connector
7. make

Back as root

(cd to user's build area)
8. cd httpd-2.2.8
9. make install
10. cd /usr/local/apache2
11. ./bin/apachectl start

From a browser

12. Test - visit http://yourhostname/

b) Add in MySQL (must do this before PHP as PHP uses its C library)

As root

101. Backup old data
102. Stop the old daemon (./support-files/mysql.server stop)
103. cd /usr/local - remove old version AND symlink!
Note:You should also delete the old /etc/my.cnf file, and the .my.cnf file in root's home directory, if you want to create a fresh build with fresh databases and tables. Otherwise it will inherit the old ones
104. tar xzf ~trainee/mysql-5.1.24-rc-linux-i686-icc-glibc23.tar.gz
105. ln -s mysql-5.1.24-rc-linux-i686-icc-glibc23/ mysql
106. cd mysql; chown -R mysql.mysql .
107 ./scripts/mysql_install_db --user=mysql
108. chown -R root .
109. chown -R mysql data
110. ./support-files/mysql.server start
111. ./bin/mysqladmin -u root password 'abc123'
112. Test - visit via ./bin/mysql -pabc123

c) And now PHP

(Nothing to delete or backup as you've done that already!)

As admin user

201. tar xzf php-5.2.5.tar.gz
202. cd php-5.2.5
203. /configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql
204. make

As root

205. cd /usr/local/apache2
206. ./bin/apachectl stop
207. cd ~trainee/php-5.2.5
208. make install
209. cp php.ini-dist /usr/local/lib/php.ini
210. Edit /usr/local/apache2/conf/httpd.conf to ensure the following are there:
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

211. cd /usr/local/apache2
212. ./bin/apachectl start
213. Add in file /usr/local/apache2/htdocs/phtest.php to contain just
<?php phpinfo(); ?>

214. Test - browse to http://yourservername/phtest.php

d) Make them restart at reboot

301. cd /etc/rc3.d or /etc/rc5.d
302. remove old symbolic links to previous installs
303. cd /etc/init.d
304. remove old apachectl and mysql.server files

305. cp /usr/local/apache2/bin/apachectl .
306. cp /usr/local/mysql/support-files/mysql.server .
307. cd /etc/rc3.d or /etc/rc5.d
308. ln -s ../init.d/apachectl S94webserver
309. ln -s ../init.d/mysql.server S93sqlserver

310. Test by rebooting!
311. Visit the MySQL client program(repeat step 112) and web server(repeat step 214)

Should you get an error message like:

httpd: Syntax error on line 53 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/mysql/lib/libmysqlclient.so.16: cannot restore segment prot after reloc: Permission denied

it's likely you're having issues with SELinux. As a quick fix, you may like to
add
setenforce 0
near the beginning of the scripts that you have copied into /etc/init.d

------ All basically running at this point --------

e) Further near-mandarory setup!

Move Web Site to appropriate place (e.g. /home or /var or /websites) (and switch web server to use it!)

Set up user and group for web server and switch server to use it! (or use the standard Apache one)

Set up user (same group) for web developer / provider

Set up MySQL account for web server. Set MySQL passwords.

Remove spurious accounts in MySQL!

Set up test page. Reboot (to ensure restarts AOK still!) Test.
(written 2008-08-01 18:17:54)

 
Associated topics are indexed under
A602 - Web Application Deployment - Apache httpd - Sourcing, Installation, Testing
S153 - Sourcing, Running and Configuring MySQL
H114 - Sourcing, installing and configuring PHP
A164 - Web Application Deployment - Services and Regular Jobs

Back to
Punting on the Cam
Previous and next
or
Horse's mouth home
Forward to
Old pictures and comparisons
Some other Articles
Finding words and work boundaries (MySQL, Perl, PHP)
All around the world?
memcached - overview, installation, example of use in PHP
Old pictures and comparisons
Apache httpd, MySQL, PHP - installation procedure
Punting on the Cam
Back from the future
A short Perl example
Equality and looks like tests - Perl
Hot Courses - Perl
1892 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

© WELL HOUSE CONSULTANTS LTD., 2008: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 0800 043 8225 or 01225 708225 • FAX: 0845 8382 405 or 01225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho