### Create V2Ray User Source: https://github.com/v2fly/fhs-install-v2ray/wiki/To-use-the-VLESS-protocol Creates a new system user named 'v2ray' with a login shell set to '/usr/sbin/nologin' for enhanced security. ```bash # useradd -s /usr/sbin/nologin v2ray ``` -------------------------------- ### Create V2Ray Certificate Directory Source: https://github.com/v2fly/fhs-install-v2ray/wiki/To-use-the-VLESS-protocol Creates a directory for V2Ray's SSL certificates, owned by the 'v2ray' user and group, with specific permissions. ```bash # install -d -o v2ray -g v2ray /etc/ssl/v2ray/ ``` -------------------------------- ### Deploy Fullchain Certificate Source: https://github.com/v2fly/fhs-install-v2ray/wiki/To-use-the-VLESS-protocol Copies the fullchain certificate file to the V2Ray certificate directory with read/write permissions for the owner and read for others. ```bash # install -m 644 -o v2ray -g v2ray /etc/letsencrypt/live/example.com/fullchain.pem -t /etc/ssl/v2ray/ ``` -------------------------------- ### Deploy Private Key Certificate Source: https://github.com/v2fly/fhs-install-v2ray/wiki/To-use-the-VLESS-protocol Copies the private key certificate file to the V2Ray certificate directory with read/write permissions only for the owner. ```bash # install -m 600 -o v2ray -g v2ray /etc/letsencrypt/live/example.com/privkey.pem -t /etc/ssl/v2ray/ ``` -------------------------------- ### Create V2Ray Certificate Directory Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/To-use-the-VLESS-protocol-zh-Hans-CN Creates a directory for V2Ray's SSL certificates with ownership and group set to 'v2ray', ensuring proper permissions for certificate files. ```bash # install -d -o v2ray -g v2ray /etc/ssl/v2ray/ ``` -------------------------------- ### Make Renewal Script Executable Source: https://github.com/v2fly/fhs-install-v2ray/wiki/To-use-the-VLESS-protocol Grants execute permissions to the V2Ray certificate renewal deployment script, allowing it to be run automatically by Certbot. ```bash # chmod +x /etc/letsencrypt/renewal-hooks/deploy/v2ray.sh ``` -------------------------------- ### Deploy V2Ray Certificates Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/To-use-the-VLESS-protocol-zh-Hans-CN Copies the fullchain and private key certificates obtained from Certbot to the designated V2Ray certificate directory, setting appropriate file permissions for security. ```bash # install -m 644 -o v2ray -g v2ray /etc/letsencrypt/live/example.com/fullchain.pem -t /etc/ssl/v2ray/ # install -m 600 -o v2ray -g v2ray /etc/letsencrypt/live/example.com/privkey.pem -t /etc/ssl/v2ray/ ``` -------------------------------- ### V2Ray Configuration - Certificates Source: https://github.com/v2fly/fhs-install-v2ray/wiki/To-use-the-VLESS-protocol Specifies the paths to the SSL certificate and private key files within the V2Ray configuration, enabling HTTPS for the VLESS protocol. ```json "certificates": [ { "certificateFile": "/etc/ssl/v2ray/fullchain.pem", "keyFile": "/etc/ssl/v2ray/privkey.pem" } ] ``` -------------------------------- ### Create V2Ray System User Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/To-use-the-VLESS-protocol-zh-Hans-CN Creates a new system user named 'v2ray' with a disabled login shell, intended for running V2Ray services with restricted permissions. ```bash # useradd -s /usr/sbin/nologin v2ray ``` -------------------------------- ### Make Renewal Script Executable Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/To-use-the-VLESS-protocol-zh-Hans-CN Grants execute permissions to the V2Ray certificate renewal deploy script, allowing Certbot to run it automatically after certificate renewals. ```bash # chmod +x /etc/letsencrypt/renewal-hooks/deploy/v2ray.sh ``` -------------------------------- ### Configure V2Ray Service User Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/To-use-the-VLESS-protocol-zh-Hans-CN Edits the systemd service file for V2Ray to specify the user under which the service should run, enhancing security by isolating the process. ```bash # systemctl edit v2ray.service [Service] User=v2ray ``` -------------------------------- ### Edit V2Ray Systemd Service Source: https://github.com/v2fly/fhs-install-v2ray/wiki/To-use-the-VLESS-protocol Allows modification of the v2ray.service unit file to specify the user under which the V2Ray service will run. ```bash # systemctl edit v2ray.service [Service] User=v2ray ``` -------------------------------- ### V2Ray TLS Configuration Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/To-use-the-VLESS-protocol-zh-Hans-CN A JSON snippet representing the TLS configuration for V2Ray, specifying the paths to the certificate and private key files used for secure connections. ```json { "certificates": [ { "certificateFile": "/etc/ssl/v2ray/fullchain.pem", "keyFile": "/etc/ssl/v2ray/privkey.pem" } ] } ``` -------------------------------- ### Install cURL on openSUSE Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Migrate-from-the-old-script-to-this-zh-Hans-CN Refreshes repositories and installs the cURL utility on openSUSE systems. ```shell # zypper refresh # zypper install curl ``` -------------------------------- ### Download install-release.sh Script Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Migrate-from-the-old-script-to-this-zh-Hans-CN Downloads the fhs-install-v2ray installation script from its official GitHub repository using cURL. ```shell $ curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh ``` -------------------------------- ### Install cURL on openSUSE Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Migrate-from-the-old-script-to-this This command refreshes the package repositories and installs the cURL utility on openSUSE systems. cURL is needed to download the V2Ray installation script. ```shell zypper refresh zypper install curl ``` -------------------------------- ### Run install-release.sh Script Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Migrate-from-the-old-script-to-this-zh-Hans-CN Executes the downloaded install-release.sh script to install or update V2Ray using bash. ```shell # bash install-release.sh ``` -------------------------------- ### Install V2Ray Executables and Data Files Source: https://github.com/v2fly/fhs-install-v2ray/blob/master/README.zh-Hans-CN.md This command installs the V2Ray executable files and the geoip.dat and geosite.dat data files. It fetches the latest release script from GitHub. ```shell # bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) ``` -------------------------------- ### Install or Update V2Ray Source: https://github.com/v2fly/fhs-install-v2ray/blob/master/README.md Installs or updates V2Ray executable files and .dat data files using a curl command to fetch the release script. ```bash bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) ``` -------------------------------- ### V2Ray Certificate Renewal Deploy Script Source: https://github.com/v2fly/fhs-install-v2ray/wiki/To-use-the-VLESS-protocol A bash script to automatically copy renewed certificates and restart the V2Ray service when Certbot performs a renewal. It checks if the renewed certificate lineage matches the specified domain. ```bash #!/bin/bash V2RAY_DOMAIN='example.com' if [[ "$RENEWED_LINEAGE" == "/etc/letsencrypt/live/$V2RAY_DOMAIN" ]]; then install -m 644 -o v2ray -g v2ray "/etc/letsencrypt/live/$V2RAY_DOMAIN/fullchain.pem" -t /etc/ssl/v2ray/ install -m 600 -o v2ray -g v2ray "/etc/letsencrypt/live/$V2RAY_DOMAIN/privkey.pem" -t /etc/ssl/v2ray/ sleep "$((RANDOM % 2048))" systemctl restart v2ray.service fi ``` -------------------------------- ### Install cURL on Debian Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Migrate-from-the-old-script-to-this-zh-Hans-CN Updates package lists and installs the cURL utility on Debian-based systems. ```shell # apt update # apt install curl ``` -------------------------------- ### Remove Old V2Ray Documentation Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Migrate-from-the-old-script-to-this These commands are used to remove old V2Ray installation files and service configurations. This includes the V2Ray binary directory, systemd service files, and init.d scripts. ```shell rm -r /usr/bin/v2ray/ rm /etc/systemd/system/v2ray.service rm /lib/systemd/system/v2ray.service rm /etc/init.d/v2ray ``` -------------------------------- ### Execute fhs-install-v2ray Script Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Migrate-from-the-old-script-to-this This command executes the downloaded `install-release.sh` script using Bash. This script will handle the installation or update of V2Ray according to the FHS (Filesystem Hierarchy Standard) guidelines. ```shell bash install-release.sh ``` -------------------------------- ### V2Ray Certificate Renewal Deploy Script Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/To-use-the-VLESS-protocol-zh-Hans-CN A bash script designed to be used as a Certbot renewal hook. It deploys updated certificates to the V2Ray directory and restarts the V2Ray service upon successful certificate renewal. ```bash #!/bin/bash V2RAY_DOMAIN='example.com' if [[ "$RENEWED_LINEAGE" == "/etc/letsencrypt/live/$V2RAY_DOMAIN" ]]; then install -m 644 -o v2ray -g v2ray "/etc/letsencrypt/live/$V2RAY_DOMAIN/fullchain.pem" -t /etc/ssl/v2ray/ install -m 600 -o v2ray -g v2ray "/etc/letsencrypt/live/$V2RAY_DOMAIN/privkey.pem" -t /etc/ssl/v2ray/ sleep "$((RANDOM % 2048))" systemctl restart v2ray.service fi ``` -------------------------------- ### Install cURL on CentOS/Fedora Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Migrate-from-the-old-script-to-this This command updates the package cache and installs the cURL utility on CentOS and Fedora systems. cURL is essential for downloading the installation script. ```shell dnf makecache dnf install curl ``` -------------------------------- ### Deploy Certificates with Specific Permissions Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Insufficient-permissions-when-using-certificates These commands use the 'install' utility to copy the fullchain.pem and privkey.pem files to the V2Ray certificate directory, setting specific permissions (644 for fullchain.pem and 600 for privkey.pem) and ownership (nobody:nogroup). ```shell # install -m 644 -o nobody -g nogroup /etc/letsencrypt/live/example.com/fullchain.pem -t /etc/ssl/v2ray/ ``` ```shell # install -m 600 -o nobody -g nogroup /etc/letsencrypt/live/example.com/privkey.pem -t /etc/ssl/v2ray/ ``` -------------------------------- ### Modify Installation Script for Configuration Path Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Migrate-from-the-old-script-to-this This snippet shows how to edit the `install-release.sh` script using `vim` to change the `JSON_PATH` variable if you choose not to migrate the configuration directory automatically. ```shell vim install-release.sh # Inside vim, change: # JSON_PATH='/etc/v2ray/' # to your desired path. ``` -------------------------------- ### Install cURL on CentOS/Fedora Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Migrate-from-the-old-script-to-this-zh-Hans-CN Updates the package cache and installs the cURL utility on CentOS or Fedora systems using dnf. ```shell # dnf makecache # dnf install curl ``` -------------------------------- ### Remove V2Ray Installation Source: https://github.com/v2fly/fhs-install-v2ray/blob/master/README.zh-Hans-CN.md This command removes the V2Ray installation from the system. It utilizes the main installation script with the --remove flag. ```shell # bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove ``` -------------------------------- ### Remove V2Ray Source: https://github.com/v2fly/fhs-install-v2ray/blob/master/README.md Removes V2Ray installation using the install script with the --remove flag. ```bash bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove ``` -------------------------------- ### Install Latest geoip.dat and geosite.dat Source: https://github.com/v2fly/fhs-install-v2ray/blob/master/README.md Updates only the geoip.dat and geosite.dat files using a curl command to fetch the data release script. ```bash bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh) ``` -------------------------------- ### Migrate V2Ray Configuration Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Migrate-from-the-old-script-to-this This command moves the V2Ray configuration directory from its old location to a new standard location. If you do not wish to migrate the configuration, you can modify the installation script directly. ```shell mv /etc/v2ray/ /usr/local/etc/ ``` -------------------------------- ### Install cURL on Debian/Ubuntu Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Migrate-from-the-old-script-to-this This command updates the package list and installs the cURL utility on Debian-based systems like Ubuntu. cURL is used for transferring data with URLs, commonly used for downloading files. ```shell apt update apt install curl ``` -------------------------------- ### Prevent GeoIP/GeoSite Update Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Do-not-install-or-update-geoip.dat-and-geosite.dat-zh-Hans-CN This command creates an empty file named '.undat' in the V2Ray data directory. When this file exists, the installation script will skip the download and update process for geoip.dat and geosite.dat. ```bash # touch /usr/local/share/v2ray/.undat ``` -------------------------------- ### Skip GeoIP/GeoSite Update Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Do-not-install-or-update-geoip.dat-and-geosite.dat Create an empty file named '.undat' in the V2Ray data directory to instruct the installation script to skip the geoip.dat and geosite.dat update process. This is useful if you have specific requirements for these data files. ```bash #!/bin/bash # Create a marker file to prevent geoip.dat and geosite.dat installation/update touch /usr/local/share/v2ray/.undat ``` -------------------------------- ### Stop V2Ray Service Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Migrate-from-the-old-script-to-this This command stops the V2Ray service and disables it from starting automatically on boot. It uses systemctl, a standard tool for managing system services on modern Linux distributions. ```shell systemctl disable v2ray.service --now ``` -------------------------------- ### Update geoip.dat and geosite.dat Source: https://github.com/v2fly/fhs-install-v2ray/blob/master/README.zh-Hans-CN.md This command specifically updates the geoip.dat and geosite.dat data files to their latest versions. It uses a separate release script for data file updates. ```shell # bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh) ``` -------------------------------- ### Deploy Private Key Certificate Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Insufficient-permissions-when-using-certificates-zh-Hans-CN This command deploys the private key certificate to the V2Ray certificate directory with 600 permissions and 'nobody' ownership. ```bash # install -m 600 -o nobody -g nogroup /etc/letsencrypt/live/example.com/privkey.pem -t /etc/ssl/v2ray/ ``` -------------------------------- ### Move v2ray directory Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Move-.dat-files-from-lib-directory-to-share-directory-zh-Hans-CN This command demonstrates how to move the entire v2ray directory from its original location in /usr/local/lib to the /usr/local/share directory. ```bash # mv /usr/local/lib/v2ray/ /usr/local/share/ ``` -------------------------------- ### Remove Original V2Ray Documentation and Service Files Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Migrate-from-the-old-script-to-this-zh-Hans-CN Removes old V2Ray binaries, service files, and init scripts. ```shell # rm -r /usr/bin/v2ray/ # rm /etc/systemd/system/v2ray.service # rm /lib/systemd/system/v2ray.service # rm /etc/init.d/v2ray ``` -------------------------------- ### Create V2Ray Certificate Directory Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Insufficient-permissions-when-using-certificates-zh-Hans-CN This command creates a directory for V2Ray certificates with specified ownership and permissions. ```bash # install -d -o nobody -g nogroup /etc/ssl/v2ray/ ``` -------------------------------- ### Deploy Fullchain Certificate Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Insufficient-permissions-when-using-certificates-zh-Hans-CN This command deploys the fullchain certificate to the V2Ray certificate directory with 644 permissions and 'nobody' ownership. ```bash # install -m 644 -o nobody -g nogroup /etc/letsencrypt/live/example.com/fullchain.pem -t /etc/ssl/v2ray/ ``` -------------------------------- ### Download fhs-install-v2ray Script Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Migrate-from-the-old-script-to-this This command uses cURL to download the `install-release.sh` script from the official v2fly GitHub repository. The `-O` flag saves the file with its original name in the current directory. ```shell curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh ``` -------------------------------- ### Check User and Group ID Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Insufficient-permissions-when-using-certificates-zh-Hans-CN This command retrieves the user and group information for the 'nobody' user, which is often used for unprivileged processes. ```bash # id nobody ``` -------------------------------- ### Migrate V2Ray Configuration Directory Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Migrate-from-the-old-script-to-this-zh-Hans-CN Moves the V2Ray configuration directory from /etc/v2ray/ to /usr/local/etc/. ```shell # mv /etc/v2ray/ /usr/local/etc/ ``` -------------------------------- ### Make Renewal Hook Script Executable Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Insufficient-permissions-when-using-certificates-zh-Hans-CN This command grants execute permissions to the V2Ray renewal hook script, allowing it to be run automatically by Certbot. ```bash # chmod +x /etc/letsencrypt/renewal-hooks/deploy/v2ray.sh ``` -------------------------------- ### Check User ID and Group for 'nobody' Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Migrate-from-the-old-script-to-this-zh-Hans-CN Checks the user ID (uid) and group ID (gid) for the 'nobody' user to determine log ownership. ```shell $ id nobody ``` -------------------------------- ### Change Directory Ownership (Scenario 2b) Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Insufficient-permissions-when-using-certificates-zh-Hans-CN This command recursively changes the ownership of the /srv/http/ directory to the 'nobody' user and 'nobody' group. ```bash # chown -R nobody:nobody /srv/http/ ``` -------------------------------- ### Change Key File Permissions Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Insufficient-permissions-when-using-certificates-zh-Hans-CN This command changes the file permissions of the private key file to 644, which is a common solution for certificate permission issues. ```bash # chmod 644 /srv/http/example.com.key ``` -------------------------------- ### Change Directory Ownership (Scenario 2a) Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Insufficient-permissions-when-using-certificates-zh-Hans-CN This command recursively changes the ownership of the /srv/http/ directory to the 'nobody' user and 'nogroup' group. ```bash # chown -R nobody:nogroup /srv/http/ ``` -------------------------------- ### Check 'nobody' User ID and Group Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Migrate-from-the-old-script-to-this These commands display the user ID (uid) and group ID (gid) for the 'nobody' user. This information is crucial for correctly setting file permissions for V2Ray logs. ```shell id nobody ``` -------------------------------- ### Set V2Ray Log Permissions (nobody:nobody) Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Migrate-from-the-old-script-to-this This command changes the ownership of the V2Ray log directory to the 'nobody' user and the 'nobody' group. This is an alternative permission setting, depending on your system's group configurations. ```shell chown -R nobody:nobody /var/log/v2ray/ ``` -------------------------------- ### Update systemd unit file for V2RAY_LOCATION_ASSET Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Move-.dat-files-from-lib-directory-to-share-directory-zh-Hans-CN This snippet illustrates how to edit the v2ray.service systemd unit file to set the V2RAY_LOCATION_ASSET environment variable, ensuring v2ray can find its assets in the new location. ```bash # systemctl edit v2ray.service [Service] Environment=V2RAY_LOCATION_ASSET=/usr/local/share/v2ray/ ``` -------------------------------- ### Change Log Directory Ownership to nobody:nobody Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Migrate-from-the-old-script-to-this-zh-Hans-CN Sets the ownership of the /var/log/v2ray/ directory to the 'nobody' user and 'nobody' group. ```shell # chown -R nobody:nobody /var/log/v2ray/ ``` -------------------------------- ### Create V2Ray Certificate Directory Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Insufficient-permissions-when-using-certificates This command creates a directory for V2Ray's certificates with the specified owner ('nobody') and group ('nogroup'). This is part of the Certbot solution to organize certificates for V2Ray. ```shell # install -d -o nobody -g nogroup /etc/ssl/v2ray/ ``` -------------------------------- ### Change Log Directory Ownership to nobody:nogroup Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Migrate-from-the-old-script-to-this-zh-Hans-CN Sets the ownership of the /var/log/v2ray/ directory to the 'nobody' user and 'nogroup' group. ```shell # chown -R nobody:nogroup /var/log/v2ray/ ``` -------------------------------- ### Modify install-release.sh for Configuration Path Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Migrate-from-the-old-script-to-this-zh-Hans-CN Edits the install-release.sh script to specify a custom path for the V2Ray configuration file if the default migration is not desired. ```shell # vim install-release.sh JSON_PATH='/etc/v2ray/' ``` -------------------------------- ### Stop V2Ray Service Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Migrate-from-the-old-script-to-this-zh-Hans-CN Stops and disables the V2Ray service using systemctl. ```shell # systemctl disable v2ray.service --now ``` -------------------------------- ### Change Directory Ownership Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Insufficient-permissions-when-using-certificates This command recursively changes the owner and group of the specified directory to 'nobody' and 'nogroup' (or 'nobody' and 'nobody' depending on the system's configuration). This ensures the user running v2ray has the necessary permissions to access the certificate files. ```shell # id nobody # chown -R nobody:nogroup /srv/http/ ``` ```shell # id nobody # chown -R nobody:nobody /srv/http/ ``` -------------------------------- ### Set V2Ray Log Permissions (nobody:nogroup) Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Migrate-from-the-old-script-to-this This command changes the ownership of the V2Ray log directory to the 'nobody' user and 'nogroup' group. This is a common practice for security, ensuring that the V2Ray process runs with minimal privileges. ```shell chown -R nobody:nogroup /var/log/v2ray/ ``` -------------------------------- ### Modify install-release.sh for DAT_PATH Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Move-.dat-files-from-lib-directory-to-share-directory-zh-Hans-CN This snippet shows how to modify the install-release.sh script to update the DAT_PATH variable to point to the new location of v2ray assets in the share directory. ```bash # vim install-release.sh DAT_PATH='/usr/local/share/v2ray/' ``` -------------------------------- ### Modify Private Key Permissions Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Insufficient-permissions-when-using-certificates This command changes the file permissions of the private key to 644, allowing read access for the owner and group, and read access for others. This is a quick fix but may not be the most secure. ```shell # chmod 644 /srv/http/example.com.key ``` -------------------------------- ### Certbot Deployment Hook Script Source: https://github.com/v2fly/fhs-install-v2ray/wiki/Insufficient-permissions-when-using-certificates This bash script is designed to be placed in Certbot's renewal hooks directory. It automatically copies the renewed certificate and key files to a specified v2ray certificate directory with the correct ownership and permissions, and then restarts the v2ray service. This is a recommended approach for automated certificate management. ```bash # vim /etc/letsencrypt/renewal-hooks/deploy/v2ray.sh #!/bin/bash V2RAY_DOMAIN='example.com' if [[ "$RENEWED_LINEAGE" == "/etc/letsencrypt/live/$V2RAY_DOMAIN" ]]; then install -m 644 -o nobody -g nogroup "/etc/letsencrypt/live/$V2RAY_DOMAIN/fullchain.pem" -t /etc/ssl/v2ray/ install -m 600 -o nobody -g nogroup "/etc/letsencrypt/live/$V2RAY_DOMAIN/privkey.pem" -t /etc/ssl/v2ray/ sleep "$((RANDOM % 2048))" systemctl restart v2ray.service fi ``` ```shell # chmod +x /etc/letsencrypt/renewal-hooks/deploy/v2ray.sh ``` -------------------------------- ### V2Ray Certificate Renewal Hook Script Source: https://github.com/v2fly/fhs-install-v2ray/wiki/locale/zh-CN/Insufficient-permissions-when-using-certificates-zh-Hans-CN This bash script is designed to be run after Certbot renews certificates. It copies the new certificates to the V2Ray directory with the correct permissions and restarts the V2Ray service. ```bash # vim /etc/letsencrypt/renewal-hooks/deploy/v2ray.sh #!/bin/bash V2RAY_DOMAIN='example.com' if [[ "$RENEWED_LINEAGE" == "/etc/letsencrypt/live/$V2RAY_DOMAIN" ]]; then install -m 644 -o nobody -g nogroup "/etc/letsencrypt/live/$V2RAY_DOMAIN/fullchain.pem" -t /etc/ssl/v2ray/ install -m 600 -o nobody -g nogroup "/etc/letsencrypt/live/$V2RAY_DOMAIN/privkey.pem" -t /etc/ssl/v2ray/ sleep "$((RANDOM % 2048))" systemctl restart v2ray.service fi ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.