Preparation
As I have already mentioned, for more complicated systems and to emulate the live environment it is suggested to use a separate virtual machine(s) with installed LAMP environment in it.
You will need a virtual machine software, my favorite is the OracleVM VirtualBox: it is lightweight, it has a big comminity and it is free.
We need to get a Linux distribution, since usually there is no need to have a GUI included, I suggest to download an ISO file of a Debian or Ubuntu Server. Further on I will make examples with Ubuntu 12.10.
Installation of Ubuntu
There are tons of descriptions for the topic available, so I would rather skip this.
Access Ubuntu via ssh
If you have not chosen the openssh package installation during the Ubuntu installation, you should do it now:
To install the OpenSSH client applications on your Ubuntu system, use this command at a terminal prompt:
sudo apt-get install openssh-client
To install the OpenSSH server application, and related support files, use this command at a terminal prompt:
sudo apt-get install openssh-server
You have to add a new network adapter to your virtual machine instance at the host application, choose a "Bridge" option from the "Attached to" dropbox, then in the installed Ubuntu set up the IP address of the adapter:
nano /etc/network/interfaces
auto eth1
iface eth1 inet static
address 192.168.56.10 # this is the IP address of your guest os
netmask 255.255.255.0
And you should enable it:
sudo ifup eth1
Installing Nginx
sudo apt-get install nginx
Afterwards you need to start it:
sudo /etc/init.d/nginx start
If you have no issues during the installation you should see the following screen on load of the http://ubuntu-vm
Installing PHP5
In Ubuntu you can make PHP5 work in Nginx through PHP-FPM, which is a daemon process (with the init script /etc/init.d/php5-fpm) that runs a FastCGI server set by default on port 9000.
apt-get install php5-fpm
Set up the Nginx virtualhost
Create a folder for your new virtualhosted application here:
mkdir /var/www/localhost
Create a config for the new host:
sudo nano /etc/nginx/sites-available/localhost
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www/localhost;
index index.php index.html index.htm;
# Make site accessible from http://ubuntu_localhost/
server_name ubuntu_localhost;
location / {
try_files $uri $uri/ /index.php;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
#try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
Set up your Windows hosts file accordingly :
192.168.1.10 ubuntu_localhost
Create a symlink to it in the sites-enabled directory:
sudo ln -s /etc/nginx/sites-available/localhost /etc/nginx/sites-enabled/localhost
Restart nginx:
sudo /etc/init.d/nginx restart
Create an index.php file in the newly created /var/www/localhost folder with the following content:
<?php
phpinfo();
If you have set up everything properly, you should see the phpinfo() page upon loading the http://ubuntu_localhost/
Set up Samba
Here you can find a pretty nice guide how to set up a samba share between the host Windows 7 and guest Ubuntu 12.
No comments:
Post a Comment