The following assumes that you have a working SSH connection (alternatively use the terminal app)
You will need the following software:
HostEditor7 or HostMan (
https://www.donation...ex.php?topic=27355.0)
TIPS
First, a nice tip: create a place for future shell scripts and add it to your local path
mkdir ~/bin
sudo echo "export PATH=$PATH:~/bin" >> ~/.bashrc
I find it handy to install the following:
* support for unzipping archives
* lynx text browser for troubleshooting browsing via shell
sudo apt-get install lynx unzip
INSTALL APACHE & PHP
Install the Apache Webserver with documentation, and PHP including secure suhosin 'advanced protection system'
sudo apt-get install apache2 apache2-doc apache2-utils
sudo apt-get install libapache2-mod-php5 php5 php-pear php5-xcache php5-suhosin
MYSQL
Next up is mysql server and hooks for php
sudo apt-get install mysql-server php5-mysql
You will be prompted for a root password, make sure to note it.
Test the configuration, then exit, and ensure you can login:
mysql -u root -p
After installing MySQL, it's recommended that you run mysql_secure_installation in order to help secure MySQL. It is recommended that you accept the program's default answers. If you are prompted to reload privileges, select "yes." Run the following command to execute the program. After running mysql_secure_installation, MySQL is secure and can be restarted:
sudo mysql_secure_installation && sudo restart mysql
APACHE - SETUP VIRTUAL SITES FOR YOUR WEB PROJECTS
I've created the following script that will make it really easy to setup a new website:
#!/bin/bash
# version 1.0.0 - 21 march 2012
echo "Specify hostname:"
read AVS_HOSTNAME
echo
echo "Specify webmaster email for '${AVS_HOSTNAME}':"
read AVS_WEBMASTER
echo
echo "Generating directories in ${HOME}/projects/${AVS_HOSTNAME}..."
mkdir $HOME/projects/$AVS_HOSTNAME/public_html -p
mkdir $HOME/projects/$AVS_HOSTNAME/logs
echo "Hello World! Another site saved." | tee $HOME/projects/$AVS_HOSTNAME/public_html/index.html
echo
echo "Generating virtual host file:"
echo "
<VirtualHost *:80>
ServerAdmin ${AVS_WEBMASTER}
ServerName ${AVS_HOSTNAME}
DocumentRoot ${HOME}/projects/${AVS_HOSTNAME}/public_html/
ErrorLog ${HOME}/projects/${AVS_HOSTNAME}/logs/error.log
CustomLog ${HOME}/projects/${AVS_HOSTNAME}/logs/access.log combined
</VirtualHost>
" | sudo tee /etc/apache2/sites-available/$AVS_HOSTNAME
echo "Virtual Host file saved to /etc/apache2/sites-available/${AVS_HOSTNAME}"
echo "Enabling site and reloading apache..."
sudo a2ensite $AVS_HOSTNAME
sudo service apache2 reload
It performs the following tasks:
* asks you for the hostname and webmaster email
* creates the required directories in your home www folder
* generates a working basic virtual hosts file and saves it in the correct location
* enables the new site
* reloads apache with the configuration changes
open nano again and copy and paste the script into the file, then ctrl-x, y to save changes :
nano ~/bin/addvirtualsite.sh
You can now run the following command to setup a new site (mind the spacing and dot):
. ~/bin/addvirtualsite.sh
To make Windows aware of the new hostname add a line to your hosts file using HostEditor7. At the end of the file add the ip address of your VM followed by a space and the hostname/virtual site you created.
Open a browser and navigate to the hostname (
http://test.devvy in my case).
Congratulations!