First of all, This is possible to do:
1. Download Nginx or Apache (I use Nginx so the configuration below is for Nginx):
sudo apt-get install nginx
you might need to install php5, mysql etc when you configuring nginx, here is the dependence you need
sudo apt-get install php5 php5-cli php5-cgi spawn-fcgi php5-mysql php5-mcrypt php5-curl php5-gd php5-fpm openssl mysql-server
2.Configure Nginx
- Go to Nginx directory and delete unnecessary files
cd /etc/nginx/
rm sites-available/default
rm sites-enabled/default
- Configure for Website
cd /etc/nginx/conf.d
touch website-name.conf
- open .conf file you just created and paste the configures below
nano /etc/nginx/conf.d/website-name.conf
server {
listen [::]:80; #ipv6only=on; ######STEP1#####
server_name www.whateveryoulike.com; #####STEP2####
root /path/to/file; ######STEP3#####
index index.html index.php;
location / {
try_files $uri $uri/ @handler;
}
location @handler {
rewrite / /index.php;
}
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
location ~ \.php$ {
#try_files $uri $uri/;
fastcgi_index index.php;
expires off;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php5-fpm.sock; ######STEP4#####
include fastcgi_params;
}
#include /etc/nginx/fastcgi.conf;
}
Step 1: this is port that your website is bind on
Step 2: this is where your server name is written (you can have a server name whatever you like)
Step 3: this is where your root directory is written (it must be same as your git clone location)
Step 4: this is where the php5-fpm directory is written (nothing has to change but leave it for future use such as zend server )
For Version Control
Use Github or Bitbucket if you enjoy privacy.
I personally use Bitbucket, the process is simple as 1 2 3 4
1. Push your Live site files as master
pull the code to your pc (this is the file location for nginx)
edit , delete , add files to the local version( staging, etc )
when you done push it to bitbucket, and pull it back in live site's shell.
Finally , Relax and You're Welcome