Ana içeriğe geç

Lemp Wordpress Kurulumu

Uygulama Ubuntu 18.04 üzerinde yapılmıştır

  • Güncelleştirme sağlanıyor
apt-get update
  • MySQL kurulumu yapılıyor
apt-get install mysql-server mysql-client 
  • Gerekli PHP dosyaları indiriliyor
apt-get install php-mysql php-fpm monit
  • Repo eklemesi sağlanıyor
add-apt-repository ppa:nginx/stable
  • Güncelleştirme yapılıyor
apt-get update
  • nginx indiriyoruz
apt-get install nginx 
  • Nginx başlatılıyor
systemctl start nginx php7.2-fpm monit
  • Nginx kalıcı hale getiriliyor
systemctl enable nginx php7.2-fpm monit  
  • Nginx dizinine gidilir
cd /etc/nginx/
  • Gerekli düzenlemeler
mv nginx.conf nginx.conf.ORIG
  • Dosyayı düzenliyoruz
nano nginx.conf
  • Alttaki satırlar metin dosyasının içine yapıştırılır.
user www-data;
worker_processes auto;

pid /run/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
error_log /var/log/nginx_error.log error;
#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

# SSL
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # no sslv3 (poodle etc.)
ssl_prefer_server_ciphers on;

# Gzip Settings
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_min_length 512;
gzip_types text/plain text/html application/x-javascript text/javascript application/javascript text/xml text/css application/font-sfnt;

fastcgi_cache_path /usr/share/nginx/cache/fcgi levels=1:2 keys_zone=microcache:10m max_size=1024m inactive=1h;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

mkdir -p /usr/share/nginx/cache/fcgi (önbellek dizini oluşturulur)
apt-get install php-json php-xmlrpc php-curl php-gd php-xml php-mbstring (php dosyaları iner)
mkdir /var/run/php-fpm (dosya oluşturuluyor)

mv /etc/php/7.2/fpm/php-fpm.conf /etc/php/7.2/fpm/php-fpm.conf.ORIG
nano /etc/php/7.2/fpm/php-fpm.conf (alttaki satırlar içine yapıştırılır)

[global]
pid = /run/php/php7.2-fpm.pid
error_log = /var/log/php-fpm.log
include=/etc/php/7.2/fpm/pool.d/*.conf


rm /etc/php/7.2/fpm/pool.d/www.conf

nano /etc/php/7.2/fpm/pool.d/www.conf (alttaki satırları içine yapıştırın)
[default]
security.limit_extensions = .php
listen = /var/run/php/yourserverhostname.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
user = www-data
group = www-data
pm = dynamic
pm.max_children = 75
pm.start_servers = 8
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_requests = 500
mv /etc/php/7.2/fpm/php.ini /etc/php/7.2/fpm/php.ini.ORIG
nano /etc/php/7.2/fpm/php.ini (alttaki satırlar dosyaya yapıştırılır)

[PHP]
engine = On
short_open_tag = Off
asp_tags = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = 17
disable_functions =
disable_classes =
zend.enable_gc = On
expose_php = Off
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
html_errors = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
default_charset = "UTF-8"
doc_root =
user_dir =
enable_dl = Off
cgi.fix_pathinfo=0
file_uploads = On
upload_max_filesize = 25M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
[CLI Server]
cli_server.color = On
[Date]
[filter]
[iconv]
[intl]
[sqlite]
[sqlite3]
[Pcre]
[Pdo]
[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=
[Phar]
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = On
[SQL]
sql.safe_mode = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[OCI8]
[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[Sybase-CT]
sybct.allow_persistent = On
sybct.max_persistent = -1
sybct.max_links = -1
sybct.min_server_severity = 10
sybct.min_client_severity = 10
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatibility_mode = Off
mssql.secure_connection = Off
[Assertion]
[COM]
[mbstring]
[gd]
[exif]
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
[ldap]
ldap.max_links = -1
[dba]
[opcache]
[curl]
[openssl]
  • PHP yeniden başlatılıyor
systemctl restart php7.2-fpm (yeniden başlatma)
  • Gerekli işlemler
echo -n @ && cat /dev/urandom | env LC_CTYPE=C tr -dc [:alnum:] | head -c 15 && echo
  • MySQL için gerekli güvenlik ayarlarının yapılandırılması
/usr/bin/mysql_secure_installation
  • MySQL yeniden başlatılıyor
systemctl restart mysql
  • Deneme adında user oluşturalım
adduser deneme
  • Gerekli ayarlar
mkdir -p /home/deneme/logs
  • Nginx dizininde deneme.conf adında dosya oluşturup düzenliyoruz
nano /etc/nginx/conf.d/deneme.conf
server {
listen 80;
server_name www.deneme.com;

client_max_body_size 20m;

index index.php index.html index.htm;
root /home/deneme/public_html;

location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}


# pass the PHP scripts to FastCGI server
location ~ \.php$ {
# Basic
try_files $uri =404;
fastcgi_index index.php;

# Create a no cache flag
set $no_cache "";

# Don't ever cache POSTs
if ($request_method = POST) {
set $no_cache 1;
}

# Admin stuff should not be cached
if ($request_uri ~* "/(wp-admin/|wp-login.php)") {
set $no_cache 1;
}

# WooCommerce stuff should not be cached
if ($request_uri ~* "/store.*|/cart.*|/my-account.*|/checkout.*|/addons.*") {
set $no_cache 1;
}

# If we are the admin, make sure nothing
# gets cached, so no weird stuff will happen
if ($http_cookie ~* "wordpress_logged_in_") {
set $no_cache 1;
}

# Cache and cache bypass handling
fastcgi_no_cache $no_cache;
fastcgi_cache_bypass $no_cache;
fastcgi_cache microcache;
fastcgi_cache_key $scheme$request_method$server_name$request_uri$args;
fastcgi_cache_valid 200 60m;
fastcgi_cache_valid 404 10m;
fastcgi_cache_use_stale updating;


# General FastCGI handling
fastcgi_pass unix:/var/run/php/tutorialinux.sock;
fastcgi_pass_header Set-Cookie;
fastcgi_pass_header Cookie;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_intercept_errors on;
include fastcgi_params;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico|woff|ttf|svg|otf)$ {
expires 30d;
add_header Pragma public;
add_header Cache-Control "public";
access_log off;
}

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

server {
listen 80;
server_name deneme.com;
rewrite ^/(.*)$ http://www.deneme.com/$1 permanent;
}
  • Default sayfayı silin
rm /etc/nginx/sites-enabled/default
  • deneme.conf dosyasını düzenleyelim
nano /etc/php/7.2/fpm/pool.d/deneme.conf
  • Alttakini ekleyin:
[deneme]
listen = /var/run/php/deneme.sock
listen.owner = deneme
listen.group = www-data
listen.mode = 0660
user = deneme
group = www-data
pm = dynamic
pm.max_children = 75
pm.start_servers = 8
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_requests = 500

php_admin_value[upload_max_filesize] = 25M
php_admin_value[error_log] = /home/deneme/logs/phpfpm_error.log
php_admin_value[open_basedir] = /home/deneme:/tmp
  • Log için dosya oluşturalım
touch /home/deneme/logs/phpfpm_error.log
  • MySQL üzerinden bir veritabanı oluşturalım
mysql -u root -p

CREATE DATABASE wordpress;
CREATE USER 'wordpressu'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO [email protected];
FLUSH PRIVILEGES;

  • deneme user'ine girelim
su - tutorialinux
cd
  • Wordpress indiriliyor
wget https://wordpress.org/latest.tar.gz
  • Wordpress tar.gz den çıkarılıyor
tar zxf latest.tar.gz
  • İndirdiğimiz dosyayı silelim
rm latest.tar.gz

mv wordpress public_html
ctrl-d (+ENTER)
cd /home/deneme/public_html
chown -R deneme:www-data .
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \
systemctl restart php7.2-fpm
systemctl restart nginx

  • Siteyi görebilmek için hosts dosyamızı düzenliyoruz
nano /etc/hosts 
  • Aşağıdakileri ekleyin:
81.7.14.132 tutorialinux.com
81.7.14.132 www.tutorialinux.com

Kaynak