Lisanssız Cpanel domain ekleme 2019 – Yeni yöntem, detaylı
Lisanssız Cpanel domain ekleme 2019 – Yeni yöntem, detaylı

Lisanssız Cpanel kullanan hostlar yada sunucularda lisansınızın günü bitmiş ise yeni site yada domain eklemenin mümkün olmuyor artık. Yapılan yeni güncelleme ve alınan yeni kararlar ile artık lisanssız bir cpanel kullanıcısı iseniz yeni domain eklemek için ssh den eskisi gibi kod kullanamıyorsunuz. Bu yazımda size lisanssız cpanel bulunan host yada sunucularda nasıl yeni domain ekleyeceğinizi anlatacağım, biraz uzun yada karışık görünebilir ama denedim sorunsuz şekilde domain ekleyebiliyoruz.

Öncelikle aşağıdaki adımları kullanarak cpanel’e domaini ve kullanıcı adını tanımlayalım, aksi halde cpanel kendini belli aralıklarla güncelleyerek burda olmayan domainleri httpd.conf dosyasından çıkarıyor ve domaine bir süre sonra erişilememeye başlıyor.

Öncelikle yazı boyunca kodlardaki bu domain ismini ekleyeceğiniz domain ismi ile değiştirin ve kodları o şekilde çalıştırın: testcpanel.makaleci.com

Ssh ile cpanel de domain eklemek istediğiniz sunucuya giriyoruz ve aşağıdaki komutları sırası ile çalıştırıyoruz.

Domain için kullanıcı oluşturma ve şifre belirleme

Öncelikle kullanıcı oluşturmak için aşağıdaki komutu çalıştırın:

useradd testcpanel

Kullanıcı için şifre belirleyelim:

passwd testcpanel

Son komutu çalıştırdığınızda sizden şifre isteyecek, iki kere girip enter yaptıktan sonra şifremiz kullanıcı adına eklenmiş olacak.

Kullanıcı için atanan otomatik ssh giriş yetkisini aşağıdaki komutu uygulayarak kapatalım

usermod -s /sbin/nologin testcpanel

Cpanel dosyalarını oluşturalım ve ayarları ekleyelim

nano /etc/valiases/testcpanel.makaleci.com

Açılan sayfaya aşağıdaki kodu yazıp nanoyu kaydedip kapatalım. Burdaki testçpanel kısmı domain için kullanıcı adı olacak arkadaşlar.

*: testcpanel

Kaydedip kapatmak için ctrl+x, y yazıp enter yapın.

Aşağıdaki komutu çalıştırıyoruz, domain ile ilgili bir dosya daha oluşturacağız:

touch /etc/vdomainaliases/testcpanel.makaleci.com

Şimdi sıra Apache httpd.conf dosyasına domaini tanıtmaya geldi, böylece gelen http ve https isteklerinde domainin varlığını belirtmiş olacağız ve sunucuda çalışması için gerekli komutları yazacağız. Bu kısmı kendi httpd.conf dosyasında bulunan, çalışan bir domainin kod satırlarını kopyalayarak yapabilirsiniz, bazı durumlarda farklılık gösterebilir. İki ayrı kod kısmı var, bunlardan birisi :80 http portuna gelen istekler yani http, diğeri :443 https ile açılmak istediğinde işlenecek kısım. ikisini ayrı ayrı yapalım. Aşağıdaki kodlar yazının yayınlandığı tarihte kullandığım güncel cpanel lisansı ile oluşturulmuş httpd.conf dosyasından alınmıştır.

SSL için klasör ve dosya oluşturma

Öncesinde ssl için klasör oluşturalım, aşağıdaki kodu çalıştırın:

mkdir /var/cpanel/ssl/apache_tls/testcpanel.makaleci.com

Ardından aşağıdaki komutu çalıştırarak açılan nanoda sırasıyla ssl key, ssl sertifikası ve varsa CA sertifikasını sırayla alt alta girip kaydedip çıksınlar, sonrasında aşağıdaki işlemlere devam edebilirsiniz.

nano /var/cpanel/ssl/apache_tls/testcpanel.makaleci.com/combined

Apache httpd.conf ayarlarını yapalım

Bu dosyayı açarak “/etc/apache2/conf/httpd.conf” en alta yada # END: HTTPS vhoşts list kodundan sonrasına aşağıdaki kodu kendinize göre düzenleyerek ekleyin;

<VirtualHost 1XX.X8.21X.142:80>
  ServerName testcpanel.makaleci.com
    ServerAlias mail.testcpanel.makaleci.com www.testcpanel.makaleci.com
  DocumentRoot /home/testcpanel/public_html
  ServerAdmin [email protected]
  UseCanonicalName Off

  ## User testcpanel # Needed for Cpanel::ApacheConf
  <IfModule userdir_module>
    <IfModule !mpm_itk.c>
      <IfModule !ruid2_module>
        <IfModule !mod_passenger.c>
          UserDir disabled
          UserDir enabled testcpanel 
        </IfModule>
      </IfModule>
    </IfModule>
  </IfModule>

  # Enable backwards compatible Server Side Include expression parser for Apache versions >= 2.4.
  # To selectively use the newer Apache 2.4 expression parser, disable SSILegacyExprParser in
  # the user's .htaccess file.  For more information, please read:
  #    http://httpd.apache.org/docs/2.4/mod/mod_include.html#ssilegacyexprparser
  <IfModule include_module>
    <Directory "/home/testcpanel/public_html">
      SSILegacyExprParser On
    </Directory>
  </IfModule>

  

  <IfModule suphp_module>
    suPHP_UserGroup testcpanel testcpanel
  </IfModule>
  <IfModule suexec_module>
    <IfModule !mod_ruid2.c>
      SuexecUserGroup testcpanel testcpanel
    </IfModule>
  </IfModule>
  <IfModule ruid2_module>
    RMode config
    RUidGid testcpanel testcpanel
  </IfModule>
  <IfModule mpm_itk.c>
    # For more information on MPM ITK, please read:
    #   http://mpm-itk.sesse.net/
    AssignUserID testcpanel testcpanel
  </IfModule>
  <IfModule mod_passenger.c>
    PassengerUser testcpanel
    PassengerGroup testcpanel
  </IfModule>

  <IfModule alias_module>
    ScriptAlias /cgi-bin/ /home/testcpanel/public_html/cgi-bin/
  </IfModule>


    # Global DCV Rewrite Exclude
    <IfModule rewrite_module>
        RewriteOptions Inherit
    </IfModule>

    <IfModule proxy_fcgi_module>
        <FilesMatch \.(phtml|php[0-9]*)$>
            SetHandler proxy:unix:/opt/cpanel/ea-php73/root/usr/var/run/php-fpm/testcpanel.sock|fcgi://testcpanel.makaleci.com
        </FilesMatch>
    </IfModule>


  # To customize this VirtualHost use an include file at the following location
  # Include "/etc/apache2/conf.d/userdata/std/2_4/testcpanel/testcpanel.makaleci.com/*.conf"
</VirtualHost>

<VirtualHost 1XX.X8.21X.142:443>
  ServerName testcpanel.makaleci.com
  ServerAlias mail.testcpanel.makaleci.com www.testcpanel.makaleci.com cpanel.testcpanel.makaleci.com webdisk.testcpanel.makaleci.com webmail.testcpanel.makaleci.com
  DocumentRoot /home/testcpanel/public_html
  ServerAdmin [email protected]
  UseCanonicalName Off

  ## User testcpanel # Needed for Cpanel::ApacheConf
  <IfModule userdir_module>
    <IfModule !mpm_itk.c>
      <IfModule !ruid2_module>
        <IfModule !mod_passenger.c>
          UserDir disabled
          UserDir enabled testcpanel 
        </IfModule>
      </IfModule>
    </IfModule>
  </IfModule>

  # Enable backwards compatible Server Side Include expression parser for Apache versions >= 2.4.
  # To selectively use the newer Apache 2.4 expression parser, disable SSILegacyExprParser in
  # the user's .htaccess file.  For more information, please read:
  #    http://httpd.apache.org/docs/2.4/mod/mod_include.html#ssilegacyexprparser
  <IfModule mod_include.c>
    <Directory "/home/testcpanel/public_html">
      SSILegacyExprParser On
    </Directory>
  </IfModule>

  
  <Proxymatch ^https?://127\.0\.0\.1:(2082|2083|2077|2078|2079|2080|2086|2087|2095|2096)/>
       <IfModule security2_module>
          SecRuleEngine Off
       </IfModule>
  </Proxymatch> 

  <IfModule mod_suphp.c>
    suPHP_UserGroup testcpanel testcpanel
  </IfModule>
  <IfModule suexec_module>
    <IfModule !mod_ruid2.c>
      SuexecUserGroup testcpanel testcpanel
    </IfModule>
  </IfModule>
  <IfModule ruid2_module>
    RMode config
    RUidGid testcpanel testcpanel
  </IfModule>
  <IfModule mpm_itk.c>
    # For more information on MPM ITK, please read:
    #   http://mpm-itk.sesse.net/
    AssignUserID testcpanel testcpanel
  </IfModule>
  <IfModule mod_passenger.c>
    PassengerUser testcpanel
    PassengerGroup testcpanel
  </IfModule>

  <IfModule alias_module>
    ScriptAlias /cgi-bin/ /home/testcpanel/public_html/cgi-bin/
  </IfModule>
  <IfModule ssl_module>
    SSLEngine on
    
    SSLCertificateFile /var/cpanel/ssl/apache_tls/testcpanel.makaleci.com/combined

    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    <Directory "/home/testcpanel/public_html/cgi-bin">
      SSLOptions +StdEnvVars
    </Directory>
  </IfModule>
    <IfModule proxy_fcgi_module>
        <FilesMatch \.(phtml|php[0-9]*)$>
            SetHandler proxy:unix:/opt/cpanel/ea-php73/root/usr/var/run/php-fpm/testcpanel.sock|fcgi://testcpanel.makaleci.com
        </FilesMatch>
    </IfModule>




  # To customize this VirtualHost use an include file at the following location
  # Include "/etc/apache2/conf.d/userdata/ssl/2_4/testcpanel/testcpanel.makaleci.com/*.conf"

    <IfModule headers_module>
    RequestHeader set X-HTTPS 1
    </IfModule>
    RewriteEngine On
            RewriteCond %{HTTP_HOST} =cpanel.testcpanel.makaleci.com [OR]
            RewriteCond %{HTTP_HOST} =cpanel.testcpanel.makaleci.com:443
        RewriteCond %{HTTP:Upgrade} !websocket   [nocase]

        RewriteRule ^/(.*) /___proxy_subdomain_cpanel/$1 [PT]
		ProxyPass "/___proxy_subdomain_cpanel" "http://127.0.0.1:2082" max=1 retry=0
            RewriteCond %{HTTP_HOST} =webdisk.testcpanel.makaleci.com [OR]
            RewriteCond %{HTTP_HOST} =webdisk.testcpanel.makaleci.com:443
        RewriteCond %{HTTP:Upgrade} !websocket   [nocase]

        RewriteRule ^/(.*) /___proxy_subdomain_webdisk/$1 [PT]
		ProxyPass "/___proxy_subdomain_webdisk" "http://127.0.0.1:2077" max=1 retry=0
            RewriteCond %{HTTP_HOST} =webmail.testcpanel.makaleci.com [OR]
            RewriteCond %{HTTP_HOST} =webmail.testcpanel.makaleci.com:443
        RewriteCond %{HTTP:Upgrade} !websocket   [nocase]

        RewriteRule ^/(.*) /___proxy_subdomain_webmail/$1 [PT]
		ProxyPass "/___proxy_subdomain_webmail" "http://127.0.0.1:2095" max=1 retry=0

            RewriteCond %{HTTP:Upgrade} websocket   [nocase]
                RewriteCond %{HTTP_HOST} =cpanel.testcpanel.makaleci.com [OR]
                RewriteCond %{HTTP_HOST} =cpanel.testcpanel.makaleci.com:443

            RewriteRule ^/(.*) /___proxy_subdomain_ws_cpanel/$1 [PT]
            RewriteCond %{HTTP:Upgrade} websocket   [nocase]
                RewriteCond %{HTTP_HOST} =webmail.testcpanel.makaleci.com [OR]
                RewriteCond %{HTTP_HOST} =webmail.testcpanel.makaleci.com:443

            RewriteRule ^/(.*) /___proxy_subdomain_ws_webmail/$1 [PT]
</VirtualHost>

1XX.X8.21X.142: Sunucu İpsi olarak değiştirin
testçpanel.makaleci.com: Domain
testçpanel: kullanıcı adı
/opt/cpanel/ea-php73/root/usr/var/run/php-fpm/testcpanel.sock: domaine ait siteyi çalıştıracağınız php versiyonunu burdan belirleyin, ancak bu dosyayı kaydedip apache ye restart atmadan önce çalıştıracağımız php versiyonunada domain ile ilgili dosyalar oluşturmamız gerekiyor, bunun için aşağıdaki adımları izleyin. Aşağıdaki komutu çalıştırıyoruz

Php versiyonunu ve ayarlarını yapalım

nano /opt/cpanel/ea-php73/root/etc/php-fpm.d/testcpanel.conf

açılan sayfaya aşağıdaki kodu yapıştırıp kaydedip çıkıyoruz, öncesinde kendinize göre düzenlemeyi unutmayın:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; cPanel FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; NOTICE This file is generated. Please use our WHM User Interface
; to set these values.

[testcpanel_com]
catch_workers_output = yes
chdir = /home/testcpanel
group = "testcpanel"
listen = /opt/cpanel/ea-php73/root/usr/var/run/php-fpm/testcpanel.sock
listen.group = "nobody"
listen.mode = 0660
listen.owner = "testcpanel"
php_admin_flag[allow_url_fopen] = on
php_admin_flag[log_errors] = on
php_admin_value[disable_functions] = exec,passthru,shell_exec,system
php_admin_value[doc_root] = "/home/testcpanel/public_html/"
php_admin_value[error_log] = /home/testcpanel/testcpanel_com.php.error.log
php_admin_value[short_open_tag] = on
php_value[error_reporting] = E_ALL & ~E_NOTICE
ping.path = /ping
pm = ondemand
pm.max_children = 5
pm.max_requests = 20
pm.max_spare_servers = 5
pm.min_spare_servers = 1
pm.process_idle_timeout = 10
pm.start_servers = 0
pm.status_path = /status
security.limit_extensions = .phtml .php .php3 .php4 .php5 .php6 .php7
user = "testcpanel"

Site dosyaları için klasör oluşturma ve kullanıcı yetkilerini verme

Şimtei site dosyalarımızı barındıracağımız klasörleri ve public_html klasörünü oluşturup kullanıcı yetkisi vereceğiz, böylece anlatımın sonuna yaklaşmış olacağız. Aşağıdaki komutları sırası ile çalıştırın:

chmod 711 /home/testcpanel
mkdir /home/testcpanel/public_html
chmod 755 mkdir /home/testcpanel/public_html
touch /home/testcpanel/public_html/index.php
chown -R testcpanel:testcpanel /home/testcpanel/public_html

Bu işlemlerden sonra http ve php ye restart atarak ayarlarımızın aktif olmasını sağlayalım: Sırasıyla komutları çalıştıralım:

/scripts/restartsrv_apache_php_fpm
service httpd restart

Test için oluşturduğum site şuanda açılıyor, buraya girerek bakabilirsiniz. Sizde de site açılabilir, beyaz ekran görürseniz normaldir, çünkü oluşturduğumuz index.php dosyasında herhangi bir şey yok, eklerseniz sitenizin çalıştığını görebilirsiniz.

CEVAP VER

Lütfen yorumunuzu giriniz!
Lütfen isminizi buraya giriniz

This site uses Akismet to reduce spam. Learn how your comment data is processed.