Home Tutorial How to install Kren-Abiz script on Nginx and PHP 7.0 without Mysql using Ubuntu 16.04?

How to install Kren-Abiz script on Nginx and PHP 7.0 without Mysql using Ubuntu 16.04?

0
How to install Kren-Abiz script on Nginx and PHP 7.0 without Mysql using Ubuntu 16.04?

Create New Session of your server on Xshell 5 or simply using Putty to login.

Installing Python
============
First Install python apt-get install python

Creating SFTP user

=============
Copy useradd -m krenabiz && passwd krenabiz to create SFTP login and paste then press ENTER.
You can use another username besides krenabiz

Type your SFTP password for krenabiz or your self username


Installing Nginx Mainline version

=======================
Before installing the Nginx, we need to add the key used to sign the nginx packages and repository to the apt program keyring. For Ubuntu, in order to authenticate the nginx repository signature and to eliminate warnings about missing PGP key during installation of the nginx package.
Source: http://nginx.org/en/linux_packages.html

Simply copy cd /tmp && wget http://nginx.org/keys/nginx_signing.key && apt-key add nginx_signing.key and paste then press ENTER to Xshell 5 or Putty, see the picture.

Edit /etc/apt/sources.list file by copying nano /etc/apt/sources.list then paste and ENTER

Append the following to the end of the file

deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ xenial nginx

Press Ctrl O and ENTER to save it then press Ctrl X to exit from the Nano editor

Now we ready to install the NGINX server.
Copy apt-get update && apt-get install nginx -y then paste and ENTER

Wait for the processing until done.

Installation of Nginx successfully

Start Nginx Service with the command line /etc/init.d/nginx start

You must see message like this [ ok ] Starting nginx (via systemctl): nginx.service.

Visit your server IP http://IP_address/ and you will see like this if you do this stuff correctly.


Installing PHP 7

===========
Do with this command line apt-get -y install php7.0-fpm

Start PHP7-FPM service with /etc/init.d/php7.0-fpm start

Making PHP-FPM Use A TCP Connection
===========================
Edit /etc/php/7.0/fpm/pool.d/www.conf file with nano /etc/php/7.0/fpm/pool.d/www.conf

Change www-data with krenabiz or your self username.
Give semicolon (;) sign in the front of listen = /run/php/php7.0-fpm.sock, should be looks like ;listen = /run/php/php7.0-fpm.sock then append the following just below it listen = 127.0.0.1:9000 and save the file.
See the picture to avoid mistakes.

Restart the service everytime you make changing.
/etc/init.d/php7.0-fpm restart


Configuring nginx

=============
Edit /etc/nginx/nginx.conf file with nano /etc/nginx/nginx.conf

Adjust to the core amount of your server.

To disable log error and access, simply follow the picture or ignored this step if want keep it

Remove the default nginx config and create new config with this line
rm -rf /etc/nginx/conf.d/default.conf && nano /etc/nginx/conf.d/default.conf

Copy and paste the following configuration then save the file and restart the NGINX with this command /etc/init.d/nginx restart

server {
	listen		80;
	server_name	localhost;
	#charset	koi8-r;
	#access_log	/var/log/nginx/log/host.access.log  main;
	root		/usr/share/nginx/html;
	#autoindex	on;
	index		index.php index.html index.htm;

	location / {
		try_files $uri $uri/ /index.php;
	}

	error_page	404 /404.html;
	location = /404.html {
		root	/usr/share/nginx/html;
	}

	error_page   500 502 503 504  /50x.html;
	location = /50x.html {
		root	/usr/share/nginx/html;
	}

	location ~ \.php$ {
		root		/usr/share/nginx/html;
		try_files	$uri =404;
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index  index.php;
		fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
		include		fastcgi_params;
	}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	location ~ /\.ht {
		deny  all;
	}
}

Next open and edit  /etc/php/7.0/fpm/php.ini file with nano /etc/php/7.0/fpm/php.ini
Change ;cgi.fix_pathinfo=1 to cgi.fix_pathinfo=0
Press Ctrl W to search cgi.fix_pathinfo=

Save the file and restart PHP7-FPM service with /etc/init.d/php7.0-fpm restart

Next create info.php file with nano /usr/share/nginx/html/info.php
and paste the following code

<?php phpinfo(); ?>

Visit http://IP_address/info.php so you will see like this if you do this stuff correctly.

Install other PHP Modules
==================
We will install some PHP modules, which might needed for kren-abiz script with the following command line

apt-get -y install php7.0-curl php7.0-bcmath php7.0-gd php7.0-intl php-pear php-imagick php7.0-imap php7.0-mcrypt php-memcache php7.0-pspell php7.0-recode php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-mbstring php-gettext

Restart PHP7-FPM service again with /etc/init.d/php7.0-fpm restart

Uploading Kren-Abiz Script
===================
Open winSCP and create New Session

create new folder, give name master_krenabiz

Upload Search_Engine_Kren-A.biz.2.1.8.zip files or the latest version.

Open Xshell 5 or putty, login to your server and go to /home/krenabiz/master_krenabiz with this command cd /home/krenabiz/master_krenabiz

check the file with ls -la
extract with unzip Search_Engine_Kren-A.biz.2.1.8.zip

If you get error like this below, it seems your server had not been installed unzip.
Install unzip first with apt-get install unzip see the picture below.

once again do unzip Search_Engine_Kren-A.biz.2.1.8.zip to extract the script.

check the result with ls -la
Now change the files permission from root to krenabiz user with chown -R krenabiz:krenabiz .

check again with ls -la and the result should be like this below.

See the files on winSCP.

Configuring Your domains
==================
For example, we use example.com.
Create example.conf within the /etc/nginx/conf.d directory with this command nano /etc/nginx/conf.d/example.conf

Paste this config and save it, please replace RED BOLD text with yours

server {
	listen		80;
	listen		443 ssl;
	server_name	www.example.com;
	return		301 $scheme://example.com$request_uri;
	#return		301 https://example.com$request_uri;
}
server {
	server_name	example.com;
	#charset	koi8-r;
	#access_log	/var/log/nginx/log/example.com.access.log  main;
	#error_log	/var/log/nginx/log/example.com.error.log  error;
	root		/home/krenabiz/master_krenabiz;
	#autoindex	on;
	index		index.php index.html index.htm;

	location / {
		try_files $uri $uri/ /index.php;
		rewrite ^/download/mp3/(.*)/(.*).mp3?$ https://api.soundcloud.com/tracks/$1/stream?client_id=2t9loNQH90kzJcsFCODdigxfp325aq4z last;
		rewrite ^/dlmp3-sc/([0-9]*)/(.*).html?$ /soundcloud.php?id=$1&slug=$2 last;
		rewrite ^/viewlyrics/(.*)/(.*).html?$ /songlyrics.php?id=$1&slug=$2 last;
		rewrite ^/watch-yt/(.*)/(.*).html?$ /youtube.php?id=$1&slug=$2 last;
		rewrite ^/watch-dm/(.*)/(.*).html?$ /dailymotion.php?id=$1&slug=$2 last;
		rewrite ^/watch-vm/(.*)/(.*).html?$ /vimeo.php?id=$1&slug=$2 last;
		rewrite ^/watch-rt/(.*)/(.*).html?$ /redtube.php?id=$1&slug=$2 last;
		rewrite ^/watch-ph/(.*)/(.*).html?$ /pornhub.php?id=$1&slug=$2 last;
		rewrite ^/watch-yp/(.*)/(.*).html?$ /youporn.php?id=$1&slug=$2 last;
		rewrite ^/watch-movie/(.*)/(.*).html?$ /movie.php?id=$1&slug=$2 last;
		rewrite ^/watch-tv/(.*)/(.*).html?$ /tv.php?id=$1&slug=$2 last;
		rewrite ^/(.*)-youtube-(.*)?$ /index.php?search=$1&source=youtube&page=$2 last;
		rewrite ^/(.*)-([a-z]*)-([0-9]+)?$ /index.php?search=$1&source=$2&page=$3 last;
		rewrite ^/(.*)-([a-z]*)?$ /index.php?search=$1&source=$2 last;
		rewrite ^/sitemap.xml?$ /sitemap.php last;
		rewrite ^/sitemap-main.xml?$ /sitemap.php?home=main last;
		rewrite ^/sitemap-latest-download-(.*).xml?$ /sitemap.php?download=$1 last;
		rewrite ^/sitemap-recent-search-(.*).xml?$ /sitemap.php?recentsearch=$1 last;
		rewrite ^/sitemap-index-(.*).xml?$ /sitemap.php?keyword=$1 last;
		rewrite ^/sitemap-top-(.*)-songs.xml?$ /sitemap_pro.php?tsgenre=$1 last;
		rewrite ^/sitemap-new-release-(.*)-songs.xml?$ /sitemap_pro.php?nrgenre=$1 last;
		rewrite ^/sitemap-hot-trends.xml?$ /sitemap_pro.php?gtrend=hottrends last;
		location ~ /\.(php|js|css|mp3|wmv|flv|html|htm)$ {
		}
	}

        location /api {
                deny all;
        }

	error_page 404 /404.php;
	location   /404.php {
		root   /home/krenabiz/master_krenabiz;
	}
	
	error_page  500 502 503 504  /50x.html;
	location	/50x.html {
		root	/home/krenabiz/master_krenabiz;
	}

	location ~ \.php$ {
		root		/home/krenabiz/master_krenabiz;
		try_files	$uri =404;
		fastcgi_pass	127.0.0.1:9000;
		fastcgi_index	index.php;
		fastcgi_param	SCRIPT_FILENAME  $document_root$fastcgi_script_name;
		include		fastcgi_params;
		#fastcgi_param	HTTPS 'on';
	}

	location ~ /\.ht {
		deny  all;
	}

}

Save the file and restart the NGINX with this command /etc/init.d/nginx restart

 

Visit your http://example.com and do configuration as you want it.

IMPORTANT NOTE!
If you want to use SSL,
remove # sign in the front this line #fastcgi_param HTTPS ‘on’;
should be looks like this fastcgi_param HTTPS ‘on’;

and change

return 301 $scheme://example.com$request_uri;
#return 301 https://example.com$request_uri;

to

#return 301 $scheme://example.com$request_uri;
return 301 https://example.com$request_uri;

Adding second domain
===============
Add the second domain, simply copy the already existing conf file to the second domain name.
Go to the /etc/nginx/conf.d directory with this command cd /etc/nginx/conf.d

Check the existing conf file with ls -la
copy one of the existing conf files to the second domain name this the following command
cp example.conf seconddomain.conf

Edit the seconddomain.conf file with nano seconddomain.conf and change example.com with second-domain.com


Save the file and restart the NGINX /etc/init.d/nginx restart

Adding new domain again, simply copy the already existing conf file to the new domain name.

REMEMBER!
Restart NGINX or PHP7-FPM everytime you make changing or appending

/etc/init.d/php7.0-fpm restart
/etc/init.d/nginx restart

That’s all.

Good luck 🙂