Discover Centmin Mod today
Register Now

Nginx Mistake by remove home directory

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Josephm, Apr 18, 2015.

  1. Josephm

    Josephm Active Member

    132
    44
    28
    Aug 26, 2014
    Ratings:
    +48
    Local Time:
    5:24 AM
    1.9.5
    10.0.21
    Hi @eva2000 , I did the huge mistake when remove my /home directory.
    I did the recovery from zip file but still not access my website.
    I copied the nginx environment(from my local virtual machine) .bash to /home/nginx but still not working.
    Any solution this case?
    Thank you very much.

     
  2. eva2000

    eva2000 Administrator Staff Member

    53,530
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    8:24 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    ouch.. what isn't working ?

    how does the restored /home directory structure look like ?

    Code:
    ls -lAh /home/nginx/domains/
    ls -lAh /home/nginx/domains/yourdomain.com
    ls -lAh /home/nginx/domains/yourdomain.com/public
     
  3. Josephm

    Josephm Active Member

    132
    44
    28
    Aug 26, 2014
    Ratings:
    +48
    Local Time:
    5:24 AM
    1.9.5
    10.0.21
    I did some workaround and it's ok now:
    1. Copied .bash_logout, .bash_profile, .bashrc into /home/nginx
    2. Rebuild the file usertmp_donotdelete by your command
    Code:
        # only mount /tmp on tmpfs if CentOS system
        # total memory size is greater than 8GB
        # will give /tmp a size equal to 1/2 total memory
        if [[ "$TOTALMEM" -ge '8000000' ]]; then
           rm -rf /tmp
           mkdir -p /tmp
           mount -t tmpfs -o rw,noexec,nosuid tmpfs /tmp
           chmod 1777 /tmp
           echo "tmpfs /tmp tmpfs rw,noexec,nosuid 0 0" >> /etc/fstab
           rm -rf /var/tmp
           ln -s /tmp /var/tmp
        elif [[ "$TOTALMEM" -ge '2000000' || "$TOTALMEM" -lt '8000000' ]]; then
           # set on disk non-tmpfs /tmp to 4GB size
           # if total memory is between 2GB and <8GB
           rm -rf /tmp
           dd if=/dev/zero of=/home/usertmp_donotdelete bs=1024 count=4000000
           echo Y | mkfs.ext4 /home/usertmp_donotdelete
           mkdir -p /tmp
           mount -t ext4 -o rw,noexec,nosuid /home/usertmp_donotdelete /tmp
           chmod 1777 /tmp
           echo "/home/usertmp_donotdelete /tmp ext4 rw,noexec,nosuid 0 0" >> /etc/fstab
           rm -rf /var/tmp
           ln -s /tmp /var/tmp
        elif [[ "$TOTALMEM" -le '2000000' ]]; then
           # set on disk non-tmpfs /tmp to 2GB size
           # if total memory is <2GB
           rm -rf /tmp
           dd if=/dev/zero of=/home/usertmp_donotdelete bs=1024 count=2000000
           echo Y | mkfs.ext4 /home/usertmp_donotdelete
           mkdir -p /tmp
           mount -t ext4 -o rw,noexec,nosuid /home/usertmp_donotdelete /tmp
           chmod 1777 /tmp
           echo "/home/usertmp_donotdelete /tmp ext4 rw,noexec,nosuid 0 0" >> /etc/fstab
           rm -rf /var/tmp
           ln -s /tmp /var/tmp
        fi
    
    This command is needed for Wordpress, otherwise, you can't upload anything by webgui.
    3. Run chown -R nginx:nginx nginx in /home

    Thanks for your reply anway ;)