Want more timely Centmin Mod News Updates?
Become a Member

Nginx Letsencrypt Issues while changing a site's domain name with HTTPS and Letsencrypt SSL Certificate

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by tommy2024, Oct 24, 2024.

  1. tommy2024

    tommy2024 New Member

    11
    0
    1
    Aug 22, 2024
    Ratings:
    +0
    Local Time:
    6:16 PM
    140.00beta01
    MariaDB Ver
    Hi @eva2000 ,
    Good day!

    I am trying to follow your instructions on the forum post below on how to change a site's domain name with HTTPS and Letsencrypt SSL Certificate to other domains, but I got some issues that need your help to give some advise with:

    https://community.centminmod.com/th...-https-and-letsencrypt-ssl-certificate.18381/

    Notes:

    • My website is just newly installed a fresh WordPress via centmin.sh menu option 22
    • Let's say I was used old domain = olddomain.com and new domain = newdomain.com
    • Both olddomain.com and newdomain.com are using Cloudflare's DNS Records/ Configuration
    • Server name = "thundersv"

    ** Step 1: I had done copying my Letsencrypt issued SSL certificate files from old domain name directory to create a copy in new domain name's directory by following command:

    Code (Text):
    cp -a /usr/local/nginx/conf/ssl/olddomain.com /usr/local/nginx/conf/ssl/newdomain.com


    ❯❯ At this Step I noticed that there is no changes made yet for all the copied files under the following newly created folder for the new domain:

    ** Step 2: I had done copying my old domain's Nginx vhost config file at:


    and created my new domain's Nginx vhost config file at

    by following command:

    Code (Text):
    cp -a /usr/local/nginx/conf/conf.d/olddomain.com.ssl.conf /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf


    ❯❯ At this Step I noticed that there is Only One new Nginx vhost config file created, which was "newdomain.com.ssl.conf" for the new replacement domain, but it seems there was a missing of a basic domain file: "newdomain.com.conf" when a new vHost is added.

    ** Step 3: I tried to modify my newly created Nginx vhost config file:

    I also tried to modify all references to olddomain.com in:

    by following command:

    Code (Text):
    sed -i 's|olddomain.com|newdomain.com|g' /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf
    sed -i 's|olddomain.com|newdomain.com|g' /usr/local/nginx/conf/ssl/newdomain.com/newdomain.com.crt.key.conf


    Then noticed that in the "Step 1" above, when copying all files under the old domain: /usr/local/nginx/conf/ssl/olddomain.com to newly created folder for the new domain: /usr/local/nginx/conf/ssl/newdomain.com. The above "sed -i" command in your instructions didn't mention anything about modifying/ replacing the remaining copied files under the new domain folder, which are:

    So I just leave those files there and done nothing.

    ** Step 4: Since this is just a testing, i already set up my server to have more than enough disk space for domain's site directory and public web root files, in order to make a copy so that both /home/nginx/domains/olddomain.com and /home/nginx/domains/newdomain.com exist at same time.

    Then, I tried follow your instructions to use the following command to proceed with domain's site directory and public web root files copying:

    Code (Text):
    cp -a /home/nginx/domains/olddomain.com /home/nginx/domains/newdomain.com


    After that, I tried to restart Nginx, and got the following errors:

    Code (Text):
    [10:33][root@thundersv home]# nprestart
    Redirecting to /bin/systemctl restart nginx.service
    Job for nginx.service failed because the control process exited with error code.
    See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
    Restarting php-fpm (via systemctl) [  OK  ]
    


    error-1.png

    Then, I tried to open "systemctl status nginx.service", I saw this:

    Code (Text):
    [10:37][root@thundersv home]# systemctl status nginx.service
    × nginx.service - Centmin Mod NGINX Server
         Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: disabled)
        Drop-In: /etc/systemd/system/nginx.service.d
                 └─failure-restart.conf, openfileslimit.conf
         Active: failed (Result: exit-code) since Wed 2024-10-16 10:37:26 UTC; 12s ago
       Duration: 1d 5h 5min 50.459s
        Process: 580671 ExecStartPre=/usr/local/sbin/nginx -t (code=exited, status=1/FAILURE)
            CPU: 58ms
    
    Oct 16 10:37:26 thundersv systemd[1]: nginx.service: Scheduled restart job, restart counter is at 5.
    Oct 16 10:37:26 thundersv systemd[1]: Stopped Centmin Mod NGINX Server.
    Oct 16 10:37:26 thundersv systemd[1]: nginx.service: Start request repeated too quickly.
    Oct 16 10:37:26 thundersv systemd[1]: nginx.service: Failed with result 'exit-code'.
    Oct 16 10:37:26 thundersv systemd[1]: Failed to start Centmin Mod NGINX Server.
    [10:37][root@thundersv home]# journalctl -xeu nginx.service
    ░░ The job identifier is 48526 and the job result is failed.
    Oct 16 10:37:26 thundersv systemd[1]: nginx.service: Scheduled restart job, restart counter is at 5.
    ░░ Subject: Automatic restarting of a unit has been scheduled
    ░░ Defined-By: systemd
    ░░ Support: https://access.redhat.com/support
    ░░
    ░░ Automatic restarting of the unit nginx.service has been scheduled, as the result for
    ░░ the configured Restart= setting for the unit.
    Oct 16 10:37:26 thundersv systemd[1]: Stopped Centmin Mod NGINX Server.
    ░░ Subject: A stop job for unit nginx.service has finished
    ░░ Defined-By: systemd
    ░░ Support: https://access.redhat.com/support
    ░░
    ░░ A stop job for unit nginx.service has finished.
    ░░
    ░░ The job identifier is 48598 and the job result is done.
    Oct 16 10:37:26 thundersv systemd[1]: nginx.service: Start request repeated too quickly.
    Oct 16 10:37:26 thundersv systemd[1]: nginx.service: Failed with result 'exit-code'.
    ░░ Subject: Unit failed
    ░░ Defined-By: systemd
    ░░ Support: https://access.redhat.com/support
    ░░
    ░░ The unit nginx.service has entered the 'failed' state with result 'exit-code'.
    Oct 16 10:37:26 thundersv systemd[1]: Failed to start Centmin Mod NGINX Server.
    ░░ Subject: A start job for unit nginx.service has failed
    ░░ Defined-By: systemd
    ░░ Support: https://access.redhat.com/support
    ░░
    ░░ A start job for unit nginx.service has finished with a failure.
    ░░
    ░░ The job identifier is 48598 and the job result is failed.
    lines 1555-1585/1585 (END)
    ░░ The job identifier is 48526 and the job result is failed.
    Oct 16 10:37:26 thundersv systemd[1]: nginx.service: Scheduled restart job, restart counter is at 5.
    ░░ Subject: Automatic restarting of a unit has been scheduled
    ░░ Defined-By: systemd
    ░░ Support: https://access.redhat.com/support
    ░░
    ░░ Automatic restarting of the unit nginx.service has been scheduled, as the result for
    ░░ the configured Restart= setting for the unit.
    Oct 16 10:37:26 thundersv systemd[1]: Stopped Centmin Mod NGINX Server.
    ░░ Subject: A stop job for unit nginx.service has finished
    ░░ Defined-By: systemd
    ░░ Support: https://access.redhat.com/support
    ░░
    ░░ A stop job for unit nginx.service has finished.
    ░░
    ░░ The job identifier is 48598 and the job result is done.
    Oct 16 10:37:26 thundersv systemd[1]: nginx.service: Start request repeated too quickly.
    Oct 16 10:37:26 thundersv systemd[1]: nginx.service: Failed with result 'exit-code'.
    ░░ Subject: Unit failed
    ░░ Defined-By: systemd
    ░░ Support: https://access.redhat.com/support
    ░░
    ░░ The unit nginx.service has entered the 'failed' state with result 'exit-code'.
    Oct 16 10:37:26 thundersv systemd[1]: Failed to start Centmin Mod NGINX Server.
    ░░ Subject: A start job for unit nginx.service has failed
    ░░ Defined-By: systemd
    ░░ Support: https://access.redhat.com/support
    ░░
    ░░ A start job for unit nginx.service has finished with a failure.
    ░░
    ░░ The job identifier is 48598 and the job result is failed.
    ~
    lines 1555-1585/1585 (END)
    ░░ The job identifier is 48526 and the job result is failed.
    Oct 16 10:37:26 thundersv systemd[1]: nginx.service: Scheduled restart job, restart counter is at 5.
    ░░ Subject: Automatic restarting of a unit has been scheduled
    ░░ Defined-By: systemd
    ░░ Support: https://access.redhat.com/support
    ░░
    ░░ Automatic restarting of the unit nginx.service has been scheduled, as the result for
    ░░ the configured Restart= setting for the unit.
    Oct 16 10:37:26 thundersv systemd[1]: Stopped Centmin Mod NGINX Server.
    ░░ Subject: A stop job for unit nginx.service has finished
    ░░ Defined-By: systemd
    ░░ Support: https://access.redhat.com/support
    ░░
    ░░ A stop job for unit nginx.service has finished.
    ░░
    ░░ The job identifier is 48598 and the job result is done.
    Oct 16 10:37:26 thundersv systemd[1]: nginx.service: Start request repeated too quickly.
    Oct 16 10:37:26 thundersv systemd[1]: nginx.service: Failed with result 'exit-code'.
    ░░ Subject: Unit failed
    ░░ Defined-By: systemd
    ░░ Support: https://access.redhat.com/support
    ░░
    ░░ The unit nginx.service has entered the 'failed' state with result 'exit-code'.
    Oct 16 10:37:26 thundersv systemd[1]: Failed to start Centmin Mod NGINX Server.
    ░░ Subject: A start job for unit nginx.service has failed
    ░░ Defined-By: systemd
    ░░ Support: https://access.redhat.com/support
    ░░
    ░░ A start job for unit nginx.service has finished with a failure.
    ░░
    ░░ The job identifier is 48598 and the job result is failed.
    


    Then, i tried to access my olddomain.com, i got this Error code 521 from Cloudflare:

    error-2.png


    And this is the newdomain.com error when i tried to access at the same time:

    error-3.png


    Could you help to check all above Steps if i missed out something?

    Really appreciated your help!

    Thank you!
     
  2. eva2000

    eva2000 Administrator Staff Member

    58,895
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    9:16 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    when nginx fails to restart run nginx config check command to find out why
    Code (Text):
    nginx -t
    
     
  3. tommy2024

    tommy2024 New Member

    11
    0
    1
    Aug 22, 2024
    Ratings:
    +0
    Local Time:
    6:16 PM
    140.00beta01
    MariaDB Ver
    I got the following error when using command: "nginx -t"

    Code (Text):
    [09:48][root@thundersv ~]# nginx -t
    nginx: [emerg] open() "/usr/local/nginx/conf/wpincludes/newdomain.com/wpcacheenabler_newdomain.com.conf" failed (2: No such file or directory) in /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf:70
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed


    Please take note that while installing Wordpress via centmin.sh menu option 22, i selected option (1) for Wordpress Caching:

    Could you help to advise what should i do next to fix above error?

    Thank you!
     
  4. eva2000

    eva2000 Administrator Staff Member

    58,895
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    9:16 PM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    Find the missing file from the other instance and copy it over