Friday, February 17, 2006

Setting up L.A.M.P.

This is how I setup Linux+Apache+MySQL+PHP on my Linux box. My goal is to setup a web-server that has support for php and talks to mysql. I want the servers to auto-run on my machine. I also want to provide a server space for multiple users. The users will have FTP access to their home sites for management. I'm building from source to stay clear from problems with pre-built binaries.

My system = Debian 3.0 on Mac iBook M5423, 2.4.30 kernel, 2.95.4 gcc, 2.12.90 binutils, 2.2.5 libc.... it's a pretty slow machine but it's good so I'd always keep performance in mind.

Be very careful choosing which versions to mix. I'm using:
PHP-4.3.0 + Apache 1.3.34 + MySQL Ver 11.18 Distrib 3.23.58

0. You can also get some instructions from:

1. Download apache source tarball.
2. Download mysql source tarball.
3. Download php source tarball.
4. Untar Apache source then do the following:
make && make install

5. Untar MySQL source then do the following:
./configure --prefix=/usr/local/mysql
make && make install

6. Untar PHP source then do the following:
./configure --with-mysql=/usr/local/mysql --with-apache=../apache_1.3.34/
make && make install

7. Go back to Apache source then do the following: (if libphp4.a does no exist, it will be created)
./configure --prefix=/usr/local/apache --activate-module=src/modules/php4/libphp4.a
make && make install

8. Go to PHP source then do the following:
cp php.ini-dist /usr/loca/lib/php.ini

9. Edit Apache configuration (httpd.conf) and add the following:
AddType application/x-httpd-php .php

10. MySQL does not allow root to launch the SQL server so you must use a regular user. I use, of course, dennis. Then do the following:
chown dennis /usr/local/mysql/var -R

11. Auto-start mysql server (on other distro, this should go to /etc/rc.d/rc.local).
echo "/usr/local/mysql/bin/safe_mysqld --log=/home/dennis/mysql.log --log-long-format > /dev/null &" >> /etc/init.d/rcS

12. Initialize the database.

13. Start the server.
/usr/local/mysql/bin/safe_mysqld --log=/home/dennis/mysql.log --log-long-format > /dev/null &

14. Create new database
/usr/local/mysql/bin/mysql -u root -p
mysql> create database my_database;

15. Grant user access
mysql> select my_database;
mysql> grant all privileges on my_database.* to someuser@"192.168.XXX.XXX" identified by 'somepassword';
mysql> flush privileges;

No comments: