Ubuntu MYSQL NGINX phpMyAdmin WordPress Sunucu Kurulumu Ayarlanması ve Yüklenmesi


Merhabalar;
Bu günkü videomuzu daha önce Ubuntu sunucu kurma deneyimini yaşamamış fakat merakı olan takipçilerimiz için hazırladık. Ayrıca bu rehberimizi, herkes yararlanabilsin diye İngilizce olarakta sunmak istedik. Değineceğimiz konulara maddeler halinde bir bakalım:

  • Ubuntu sunucun nasıl kurulduğu – How to install ubuntu server?
  • Kurulum sırasında dikkat edilmesi gereken noktalar – Points must be considered during installation
  • MYSQL veritabanı güvenliği arttırma – Increase security level for MYSQL database
  • Ubuntu nginx web sunucusu kurulumu – Ubuntu nginx web server setup process
  • WordPress nginx ayarı – Nginx settings for WordPress
  • web (/var/www) dosya izinlerinin ayarlanması – Permission settings for web (/var/www) folder
  • phpMyAdmin kurulumu ve nginx ayarı – phpMyAdmin setup and nginx settings
  • MYSQL yeni kullanıcı adı oluşturma ve veri tabanı oluşturma – How can you create new MYSQL user and database?
  • PHP maksimum yükleme boyutu nasıl arttırıldığı – How can you increase the maximum upload size for PHP?

 


KODLAR – CODES

Kullanılan kodlar. Koyu ve altı çizili kodların sıralaması aşağıdaki gibi olmalıdır. Altı çizili kodlar farklı sıralama ile yazılırsa kurulum sıkıntı çıkarabilir.
(Here we go, You have to obey order of the list. This is important to make no mistake.)


apt-get update
apt-get upgrade
apt-get install nginx mysql-server php5-fpm php5-mysql
apt-get install phpmyadmin
apt-get install wordpress

mysql_secure_installation
apt-get install unzip

phpMyAdmin NGINX ayarı. Ayar konumu /etc/nginx/sites-enabled/phpmyadmin.web
(This code block includes NGINX settings. Path of settings: /etc/nginx/sites-enabled/phpmyadmin.web )


server {
    listen 925;
	client_max_body_size 100M;
    root /usr/share/phpmyadmin;
    index index.html index.htm index.php;
    server_name phpden.sitem.com;
    charset utf-8;
  index index.php;
  location / {
    try_files $uri $uri/ /index.php?$args;
  }
  location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
    access_log off;
    expires max;
  }
  location ~ /\.ht {
    deny  all;
  }
  location ~ \.php$ {
    fastcgi_index index.php;
    fastcgi_keep_conn on;
    include /etc/nginx/fastcgi_params;
    #fastcgi_pass 127.0.0.1:9000;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

/web klasörü izin ayarlama kodu.
(This is permission settings for /web folder.)


nano /usr/bin/wwwpermission
#!/bin/bash
sudo chown -R www-data:www-data /web
sudo chmod -R g+rwX /web
chmod 755 /usr/bin/wwwpermission

WordPress kullanan site NGINX ayarı.  Ayar konumu /etc/nginx/sites-enabled/sitem-com.web
(This is NGINX settings for website which uses WordPress. Path of settings: /etc/nginx/sites-enabled/sitem-com.web)


server {
    listen 80;
	client_max_body_size 100M;
    root /web/sitem;
    index index.html index.htm index.php;
    server_name sitem.com www.sitem.com;
    charset utf-8;
	#########saniye basina limit ##########
######resimkoruma######
#location ~* \.(gif|png|jpe?g)$ {
#  expires 7d;
#  add_header Pragma public;
#  add_header Cache-Control "public, must-revalidate, proxy-revalidate";
#
#  # prevent hotlink
#  valid_referers none blocked ~.google. ~.bing. ~.yahoo. server_names ~($host);
#  if ($invalid_referer) {
#    rewrite (.*) /wp-content/uploads/hotlink-denied.jpg redirect;
#    # drop the 'redirect' flag for redirect without URL change (internal rewrite)
#  }
#}
# stop hotlink loop
#location = /images/hotlink-denied.jpg { }
#############################
    location / {
            try_files $uri $uri/ /index.php?$args;
    }
    error_page 404 /index.php;
    # Deny .htaccess file access
    location ~ /\.ht {
        deny all;
    }
	if ($request_method = POST) {
		set $skip_cache 1;
	}
	if ($query_string != "") {
		set $skip_cache 1;
	}
	# Don't cache uris containing the following segments
	if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
		set $skip_cache 1;
	}
	# Don't use the cache for logged in users or recent commenters
	if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
		set $skip_cache 1;
	}
    #hhvm kullanıcıları için ## include hhvm.conf;
	location ~ \.php$ {
                try_files $uri =404;
                #HHVM kullanıcıları için ## fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
				###   PHP cache   ###
				add_header X-Cache $upstream_cache_status;
				#fastcgi_cache dijitaller;
				#fastcgi_cache_valid 60m;
				#fastcgi_cache_bypass $skip_cache;
				#fastcgi_no_cache $skip_cache;
				#limit_req zone=one burst=5;
                 }
	location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
		access_log off;	log_not_found off; expires max;
	}
location = /favicon.ico {
	log_not_found off;
	access_log off;
}
location = /robots.txt {
	allow all;
	log_not_found off;
	access_log off;
}
location ~ /\. {
	deny all;
}
location ~* /(?:uploads|files)/.*\.php$ {
	deny all;
}
########################################
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
	expires 24h;
	log_not_found off;
}
location ^~ /blogs.dir {
        internal;
        alias /var/www/example.com/htdocs/wp-content/blogs.dir ;
        access_log off; log_not_found off;      expires max;
}
# Rewrite multisite '.../wp-.*' and '.../*.php'.
if (!-e $request_filename) {
	rewrite /wp-admin$ $scheme://$host$uri/ permanent;
	rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
	rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
location ~ \.php$ {
	# Zero-day exploit defense.
	# http://forum.nginx.org/read.php?2,88845,page=3
	# Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
	# Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine.  And then cross your fingers that you won't get hacked.
	try_files $uri =404;
	fastcgi_split_path_info ^(.+\.php)(/.+)$;
	#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
	include fastcgi_params;
	fastcgi_index index.php;
	fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#	fastcgi_intercept_errors on;
}
###############################################  Cache #####################
set $cache_uri $request_uri;
if ($request_method = POST) {
        set $cache_uri 'null cache';
}
if ($query_string != "") {
        set $cache_uri 'null cache';
}
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
        set $cache_uri 'null cache';
}
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
        set $cache_uri 'null cache';
}
#########################################################################################
}

PHP (php-fpm)  maksimum yükleme boyutunu arttırma.
(Increase the maximum upload size for PHP (php-fpm) )


nano /etc/php5/cli/php.ini
nano /etc/php5/cgi/php.ini
nano /etc/php5/fpm/php.ini
upload_max_filesize = 500M
post_max_size = 500M

Bir sonraki rehberimizde görüşmek üzere, hoşçakalın.
(We will see you in next the guide, Goodbye.)


0 Yorum

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir