sanus|art
May 27th, 2008, 08:38 PM
[1] - Installation:
This will install 'Apache 2', 'php5', 'MySQL' and 'phpMyAdmin' (if you need php4 rather than php5 - just change 5's to 4's in the code bellow):
sudo apt-get install apache2 php5 libapache2-mod-php5 mysql-server libapache2-mod-auth-mysql php5-mysql phpmyadmin
NOTE ! You'll be asked to provide SQL password durring the MySQL installation.
[2] - Configure:
Add 'phpMyAdmin' module to apache:
echo "Include /etc/phpmyadmin/apache.conf" | sudo tee -a /etc/apache2/apache2.conf
NOTE ! If you get 'blowfish password error' in http://localhost/phpmyadmin/ see the second post by antiigrav (http://ubuntuforums.org/showpost.php?p=5160992&postcount=2) in this tread.
NOTE ! the default username is 'root', the default password is whatever you specified at the stage [1] at the MySQL installation.
Edit the file /etc/apache2/httpd.conf (it might be empty - don't worry):
sudo gedit /etc/apache2/httpd.conf
and add this (my username and user group is called 'sasha' - change it to yours):
ServerName localhost
User sasha
Group sasha
This will grant you access as the specified user.
[3] - Testing the installation:
Restart the apache for new setting to be applied:
sudo /etc/init.d/apache2 restart
To test Apache2 installation - point your web browser to:
http://localhost/
You should see page which reads 'It works!'.
To test php installation - create file called test.php in /var/www or type in terminal:
echo '<?php phpinfo(); ?>' | sudo tee /var/www/test.php
and point your web browser to:
http://localhost/test.php
You should see page which tells different php settings like in the picture:
71843
To test phpMyAdmin installation point your web browser to:
http://localhost/phpmyadmin
[4] - Re-configurations (optional):
By default, apache2 is set to listen to port 80 at http://localhost/ while the server's root directory is /var/www.
(a) - to change the port - edit the file /etc/apache2/ports.conf and change the 'Listen 80' to some other number:
sudo gedit /etc/apache2/ports.conf
(for example: if you change 80 to 4747 - you can access the server root by http://localhost:4747/)
(b) - to change the 'server root' - edit the file /etc/apache2/sites-available/default:
back-up the original file:
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/default_backup
... and open the file for editing:
sudo gedit /etc/apache2/sites-available/default
change the content to something like the following:
(this is my settings - I wanted my server to be accessed from 'http://www' while all my web files are located at '/home/sasha/www')
NameVirtualHost *
<VirtualHost *>
ServerName www
DocumentRoot /home/sasha/www
</VirtualHost>
now go to SYSTEM => ADMINISTRATION => NETWORK at the HOST tab select localhost, and add 'www' as it shows in the picture:
71844
Or edit file /etc/hosts
sudo gedit /etc/hosts
Now restart the apache:
sudo /etc/init.d/apache2 restart
Now test it by pointing your web browser to:
http://www
(c) - To add more virtual hosts - just repeat the (b) part with the ServerName and DocumentRoot specification, add the ServerName to SYSTEM => ADMINISTRATION => NETWORK the HOST tab, restart apache.
Hope I didn't forgot/messed things up or worse, if I did - please feel free to correct me.
This will install 'Apache 2', 'php5', 'MySQL' and 'phpMyAdmin' (if you need php4 rather than php5 - just change 5's to 4's in the code bellow):
sudo apt-get install apache2 php5 libapache2-mod-php5 mysql-server libapache2-mod-auth-mysql php5-mysql phpmyadmin
NOTE ! You'll be asked to provide SQL password durring the MySQL installation.
[2] - Configure:
Add 'phpMyAdmin' module to apache:
echo "Include /etc/phpmyadmin/apache.conf" | sudo tee -a /etc/apache2/apache2.conf
NOTE ! If you get 'blowfish password error' in http://localhost/phpmyadmin/ see the second post by antiigrav (http://ubuntuforums.org/showpost.php?p=5160992&postcount=2) in this tread.
NOTE ! the default username is 'root', the default password is whatever you specified at the stage [1] at the MySQL installation.
Edit the file /etc/apache2/httpd.conf (it might be empty - don't worry):
sudo gedit /etc/apache2/httpd.conf
and add this (my username and user group is called 'sasha' - change it to yours):
ServerName localhost
User sasha
Group sasha
This will grant you access as the specified user.
[3] - Testing the installation:
Restart the apache for new setting to be applied:
sudo /etc/init.d/apache2 restart
To test Apache2 installation - point your web browser to:
http://localhost/
You should see page which reads 'It works!'.
To test php installation - create file called test.php in /var/www or type in terminal:
echo '<?php phpinfo(); ?>' | sudo tee /var/www/test.php
and point your web browser to:
http://localhost/test.php
You should see page which tells different php settings like in the picture:
71843
To test phpMyAdmin installation point your web browser to:
http://localhost/phpmyadmin
[4] - Re-configurations (optional):
By default, apache2 is set to listen to port 80 at http://localhost/ while the server's root directory is /var/www.
(a) - to change the port - edit the file /etc/apache2/ports.conf and change the 'Listen 80' to some other number:
sudo gedit /etc/apache2/ports.conf
(for example: if you change 80 to 4747 - you can access the server root by http://localhost:4747/)
(b) - to change the 'server root' - edit the file /etc/apache2/sites-available/default:
back-up the original file:
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/default_backup
... and open the file for editing:
sudo gedit /etc/apache2/sites-available/default
change the content to something like the following:
(this is my settings - I wanted my server to be accessed from 'http://www' while all my web files are located at '/home/sasha/www')
NameVirtualHost *
<VirtualHost *>
ServerName www
DocumentRoot /home/sasha/www
</VirtualHost>
now go to SYSTEM => ADMINISTRATION => NETWORK at the HOST tab select localhost, and add 'www' as it shows in the picture:
71844
Or edit file /etc/hosts
sudo gedit /etc/hosts
Now restart the apache:
sudo /etc/init.d/apache2 restart
Now test it by pointing your web browser to:
http://www
(c) - To add more virtual hosts - just repeat the (b) part with the ServerName and DocumentRoot specification, add the ServerName to SYSTEM => ADMINISTRATION => NETWORK the HOST tab, restart apache.
Hope I didn't forgot/messed things up or worse, if I did - please feel free to correct me.