Saturday, October 25, 2014

Migrate From Apache to Nginx (Engin X) on Ubuntu VPS

I have low end of VPS, there are has minim of spesification hardware, googling and found recommended using Nginx for web server to reduce using of memory.

1. Stop service for Apache

sudo service apache2 stop

2. Installing Nginx PHP5-FPM

sudo apt-get install nginx php5-fpm

3. Configure PHP5-FPM

need to configuring PHP5 handler by Nginx
sudo nano /etc/php5/fpm/php.ini
find (CTRL + W) cgi.fix_pathinfo word and set like the below value:
cgi.fix_pathinfo=0
will modify another PHP configuration
sudo nano /etc/php5/fpm/pool.d/www.conf
find the "listen = ", We will modify this to use a socket for communication with the web server
listen = /var/run/php5-fpm.sock
Restart the PHP-FPM
sudo service php5-fpm restart

5. Set the Vhost of Nginx

sudo nano /etc/nginx/sites-available/myvhost.conf
add this lines to configure your site, for more example script you can find at /etc/nginx/sites-available/default
server {
    listen 80;

    root /var/www;
    index index.php index.html index.htm;
}
unlink the default configuration
sudo unlink /etc/nginx/sites-enabled/default 
Start the Nginx web server
sudo nano service nginx start

6. Remove Apache

to find all dependcies of Apache you filter like this:
dpkg --get-selections | grep apache
will display:
apache2      install
apache2-doc     install
apache2-mpm-prefork    install
apache2-threaded-dev    install
apache2-utils     install
apache2.2-bin     install
apache2.2-common    install
libapache2-mod-auth-mysql   install
libapache2-mod-passenger   install
remove
sudo apt-get remove apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common libapache2-mod-auth-mysql libapache2-mod-php5
for the clear remove dependencies run this command
sudo apt-get autoremove

No comments:

Post a Comment