Need to set up a web server with MySQL and PHP support? That's exactly what I needed to do when I
decided to create a photo gallery using the gallery2 open source software package. Prior to using VL, I actually did the equivalent in Windows using gallery2 and the wamp open source package. However, using VL lets me dedicate an old PIII-800 to web server duties with VL running nicely on the Pentium III.
Below is how I got AMP (Apache, MySQL, and PHP) up and running under VectorLinux 5.9 Gold Standard.
This information is based on the Slackware guide for AMP at
http://www.linuxquestions.org/questions/slackware-14/slackware-guide-for-amp-apache-mysql-and-php-311344/First I Installed httpd, MySQL, and PHP using GSLAPT
httpd was 2.2.8-i486-1_slack12.0.tgz
mysql was 5.051-i486-1_slack12.0.tgz
php was 5.2.6-i486-1_slack12.0.tgz
all 3 came from from
http://slackware.mirrors.tds.net/pub/slackware/slackware-12.0/create a group called mysql
============
Code:
groupadd mysql
create user mysql (if doesn't exist.. to see if it does,
type su - mysql).
If it says "Unknown id: mysql" then that user does not exist.
(note: this user was alrady present in my system)
============
Code:
useradd -g mysql mysql
give user mysql access
============
Code:
chown -R mysql.mysql /var/lib/mysql
install a database from user mysql
============
Code:
su - mysql
mysql_install_db
exit
create a my.cnf file
============
Code:
cp /etc/my-medium.cnf /etc/my.cnf
keep the socket in /var/run/mysql/, its more secure than /tmp
don't modify anything else
start mysql
============
Code:
chmod +x /etc/rc.d/rc.mysqld
su - mysql
/etc/rc.d/rc.mysqld start
exit
set a password for mysql root user
============
Code:
/usr/bin/mysqladmin -u root password 'new-password'
Download mysqlcc 0.9.8 from sourceforge and compile it per
the instructions that come with it.
run mysqlcc
============
Code:
cd mysqlcc-0.9.8-src/ (had this directory inside my home - the location mysqlcc was compiled in)
./mysqlcc
file > new
name: mylocalmysql
hostname: localhost
user: root
password: **********
socket file: /var/run/mysql/mysql.sock
click on test, it should be successful
If you need to create a database for a specific application,
such as gallery2, then do the following:
============
su - mysql (using mysql user at this point)
mysql -h localhost -u root -p (connect to mysql server)
Then enter your mysql root password when promted
Then you will see somethinglike the following:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.0.51-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
At the mysql prompt above, type SHOW DATABASES; including
the semicolon to see what databases are already present
and to make sure the one you want to create is not already
there.
next at the mysql prompt, type CREATE DATABASE gallery2;
(or whatever your new database is)
SHOW DATABASES; will show the newly created database
in the list.
quit at the mysql> prompt will drop the connection
exit will then exit out of the mysql user
configure php
==============
edit httpd.conf and make sure this line is at the
bottom of the file
Include /etc/httpd/mod_php.conf
edit mod_php.conf
==================
make sure the line looks similar to this
Code:
==================
LoadModule php5_module usr/lib/httpd/modules/libphp5.so
start apache & php
==============
Code:
cd /etc/rc.d
./rc.httpd start
(had to right click rc.httpd in Thunar running
as root and make the file executable first)
When started, go to your web browser, and go to
http://localhostyou should see a website. Good.
next test php
===============
Code:
cd /var/www/htdocs
create a file called test.php and add the following to it
===============
Code:
<? phpinfo(); ?>
You should now be able to see all the php configurations.
If you search for mysql, you won't find it.
Let us link mysql to apache and php now.
stop apache
===============
Code:
apachectl stop
or
===============
Code:
/etc/rc.d/rc.httpd stop
go back to /etc/apache2, and edit php.ini
==================
Code:
cd /etc/apache2/
pico php.ini
search for mysql
============
Code:
ctrl + w mysql
uncomment the line ;extension=mysql.so by removing the ';'
============
Code:
extension=mysql.so
restart apache
============
Code:
apachectl start
refresh the
http://localhost/test.phpand search for mysql
now you will find it halfway through the webpage.
Congratulations... =)