You can install nginx webserver as mentioned in this link
Now to add domains to it, we create two folders for the virtualhosts.
1) sites-available for all virtualhosts
2) sites-enabled for those virtualhosts that are active
We are going to create the domain greproot.com with username as greproot
The document root will be under /var/www/greproot/public_html. So create a user with home directory set to /var/www/greproot
[root@abc ~]# useradd -d /var/www/greproot greproot
[root@abc ~]# passwd greproot # give a strong password for the user
[root@abc ~]# mkdir /var/www/greproot/public_html
[root@abc ~]# mkdir /var/www/greproot/logs
[root@abc ~]# touch /var/www/greproot/logs/access.log
[root@abc ~]# touch /var/www/greproot/logs/error.log
[root@abc ~]# chown -R greproot:greproot /var/www/greproot/
[root@abc ~]# chmod 755 /var/www/greproot
Now we need to add the virtual hosts files. As mentioned earlier, /etc/nginx/sites-enabled/ is where the virtual host file for active sites reside. So we need to include this in the main nginx conf.
[root@abc ~]# vi /etc/nginx/nginx.conf and add the following lines to the end of that file before the closing bracket.
## Load virtual host conf files. ##
include /etc/nginx/sites-enabled/*;
Save and exit, restart nginx.
[root@abc ~]# /etc/rc.d/init.d/nginx restart
Stopping nginx: [ OK ]
Starting nginx: [ OK ]
Now add the virtual host for greproot.com. We add it to sites-available and then symlink it to sites-enabled to activate it.
[root@abc ~]# cd /etc/nginx/sites-available/
[root@abc ~]# vi greproot.com and add the following to it
server {
server_name www.greproot.com greproot.com;
access_log /var/www/greproot/logs/access.log;
error_log /var/www/greproot/logs/error.log;
root /var/www/greproot/public_html/;
location / {
index index.html index.htm index.php;
}
location ~ \.php$ {
if (!-e $request_filename) { rewrite / /index.php last; }
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/greproot/public_html$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE base;
fastcgi_param MAGE_RUN_TYPE website;
}
}
If php is not installed in the server, comment out the location section for php. After that save the file and exit. Now, if we need to access this site over browser, the virtual host conf should come in sites-enabled.
[root@abc ~]# cd /etc/nginx/sites-enabled/
[root@abc ~]# ln -s /etc/nginx/sites-available/greproot.com
[root@abc ~]# /etc/rc.d/init.d/nginx restart
Stopping nginx: [ OK ]
Starting nginx: [ OK ]
If nginx started fine, and if the website greproot.com is resolving correctly to your server IP address, then try accessing the site over browser after placing a test page at /var/www/greproot/public_html/
Recent Comments