How to setup an HTTP web server on a VPS running Debian
This tutorial explains how to install and configure Nginx1. Install Nginx
Now if you point your browser to your IP address, it should confirm that nginx was successfully installed on your VPS.
2. Configure Nginx
With virtual host, you can host many site on 1 VPS. Here is how to configure it.
Open the default virtual host to edit. You can use many free tool to edit text in linux such as vi/vim/emacs... With the limited resource VPS, I recommend "nano".
In this configuration file, you can config many virtual hosts as you want. A correct configured virtual host look like this:
Now you can save and exit nano by press Ctr + X, it will ask you to save the edited file, save it.
Restart Nginx by:
and now you can browse to your web server using your domain name!
3, Install PHP
After installing Nginx as the post above, if you want to create dynamic web with VPS, here is the tutorial to help you install PHP.
Initial installation is simple with the apt-get command.
And configure php to work with Nginx. Open
Find the line:
change it to:
Save and Exit.
Change configuration of Nginx. Add these following lines to each virtual host
Restart php-fpm:
You are done!. You can test your PHP by creating a simple file like this
in
Conclusion
Hi, this is my first tutorial on setting up a Web server on Debian. I think it will be useful for someone because With 128MB RAM, I think it would be better if you install Nginx for webserver, PHP for generating dynamic page and MySQL for database management. I choose Nginx because it is lighter and have better performance than Apache.
This tutorial explains how to install and configure Nginx1. Install Nginx
PHP Code:
sudo apt-get install nginx
sudo service nginx start
2. Configure Nginx
With virtual host, you can host many site on 1 VPS. Here is how to configure it.
Open the default virtual host to edit. You can use many free tool to edit text in linux such as vi/vim/emacs... With the limited resource VPS, I recommend "nano".
PHP Code:
sudo nano /etc/nginx/sites-available/default
PHP Code:
location / {
try_files $uri $uri/ /index.html;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
Restart Nginx by:
PHP Code:
sudo service nginx restart
3, Install PHP
After installing Nginx as the post above, if you want to create dynamic web with VPS, here is the tutorial to help you install PHP.
Initial installation is simple with the apt-get command.
PHP Code:
sudo apt-get install php5-fpm
PHP Code:
sudo nano /etc/php5/fpm/pool.d/www.conf
PHP Code:
Find the line, listen = 127.0.0.1:9000
PHP Code:
listen = /var/run/php5-fpm.sock
Change configuration of Nginx. Add these following lines to each virtual host
PHP Code:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
PHP Code:
sudo service php5-fpm restart
PHP Code:
<?php
phpinfo();?>
PHP Code:
/usr/share/nginx/www/info.php
i Dont know it's useful For You Or not
But It's useful For Someone