Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save kmrtylmz/525f3cb3f2f4c41a2c08698860a1c9bc to your computer and use it in GitHub Desktop.

Select an option

Save kmrtylmz/525f3cb3f2f4c41a2c08698860a1c9bc to your computer and use it in GitHub Desktop.

Revisions

  1. @moaalaa moaalaa revised this gist May 10, 2023. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions 2.2 - Echo server runner.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    require('dotenv').config();

    const env = process.env;

    require('laravel-echo-server').run({
    authHost: env.APP_URL,
    devMode: env.APP_DEBUG,
    database: "redis",
    databaseConfig: {
    redis: {
    host: env.REDIS_HOST,
    port: env.REDIS_PORT,
    }
    }
    });
  2. @moaalaa moaalaa revised this gist Oct 31, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 0- install nodejs and redis.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # Node Js
    curl -sL https://rpm.nodesource.com/setup_18.x | sudo bash -
    curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -

    sudo yum install nodejs

  3. @moaalaa moaalaa revised this gist Oct 31, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 0- install nodejs and redis.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # Node Js
    curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
    curl -sL https://rpm.nodesource.com/setup_18.x | sudo bash -

    sudo yum install nodejs

  4. @moaalaa moaalaa revised this gist Aug 9, 2022. 1 changed file with 41 additions and 0 deletions.
    41 changes: 41 additions & 0 deletions Install ffmpeg for centos 7 using build source file .md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    # Install ffmpeg for centos 7 using build source file

    ## 1 - Download FFmpeg build tar file
    ```sh
    cd /opt

    sudo wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz
    ```

    ## 2 - Verify FFmpeg tar file using md5sum

    ```sh
    sudo wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz.md5

    md5sum -c ffmpeg-git-amd64-static.tar.xz.md5
    ```

    ## 3 - Untar the FFmpeg build

    ```sh
    udo tar xvf ffmpeg*.xz
    ```

    ## 4 - Go to ffmpeg directory

    ```sh
    cd ffmpeg-*-static
    ```

    ## 5 - Create symlink for ffmpeg and ffprobe binaries
    ```sh
    sudo ln -s "${PWD}/ffmpeg" /usr/bin/

    sudo ln -s "${PWD}/ffprobe" /usr/bin/
    ```

    ## 6 - Check ffmpeg version
    ```sh
    ffmpeg -version
    ```

  5. @moaalaa moaalaa revised this gist Jul 1, 2021. 1 changed file with 21 additions and 0 deletions.
    21 changes: 21 additions & 0 deletions 0- install nodejs and redis.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # Node Js
    curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -

    sudo yum install nodejs

    node --version

    npm --version

    # Redis
    sudo yum install epel-release

    sudo yum install redis -y

    sudo systemctl start redis.service

    sudo systemctl enable redis

    sudo systemctl status redis.service

    redis-cli ping
  6. @moaalaa moaalaa revised this gist May 4, 2021. 1 changed file with 27 additions and 1 deletion.
    28 changes: 27 additions & 1 deletion 6- start pm2.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,30 @@
    # Start PM2 as Root (server user not host or cpanel normal user) or it will not work
    # Method 1: Start PM2 as normal user (not server user but host or cpanel normal user)

    # Add your host or cpanel user to "wheel" group to use "su" command
    usermod -G wheel your_user_name
    # Remomber now your user can use "su" command but it will required "root" user passowrd keep in mind
    # By allowing your user to use "su" now pm2 will work correctlly and yu don't need to use "su" with it

    # Go to your app root path and Start PM2 and Provide Path to pm2.config.js (autocomplete paths in terminal may not work)
    pm2 start pm2.config.js

    # Stop PM2 and Provide Path to pm2.config.js (autocomplete paths in terminal may not work)
    pm2 stop pm2.config.js

    # Restart PM2 and Provide Path to pm2.config.js (autocomplete paths in terminal may not work)
    pm2 restart pm2.config.js

    # Log All pm2 Apps
    pm2 logs

    # Log specific pm2 app
    # sudo pm2 logs [app name]
    pm2 logs laravel-echo-server
    pm2 logs laravel-queue-worker

    #---------------------------------------#---------------------------------------#---------------------------------------

    # Method 2: Start PM2 as Root (server user not host or cpanel normal user) or it will not work

    # Start PM2 and Provide Path to pm2.config.js (autocomplete paths in terminal may not work)
    sudo pm2 start "/home/CPANEL USER NAME/www/pm2.config.js"
  7. @moaalaa moaalaa revised this gist Mar 16, 2021. 6 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
    File renamed without changes.
    File renamed without changes.
    File renamed without changes.
    File renamed without changes.
  8. @moaalaa moaalaa created this gist Mar 16, 2021.
    2 changes: 2 additions & 0 deletions .env
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    BROADCAST_DRIVER=redis
    QUEUE_CONNECTION=redis
    13 changes: 13 additions & 0 deletions Install PM2 on server.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    # You Must Be Root

    sudo npm install -g pm2

    # Register pm2 to startup
    # Run without sudo it will generate a command just copy/past the generated command
    pm2 startup


    # unRegister pm2 to startup
    # Run without sudo it will generate a command just copy/past the generated command
    pm2 unstartup

    12 changes: 12 additions & 0 deletions allow firewall port.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    # All Command are on CentOs7

    # Allow port 6001 in firewall for using it in laravel echo server
    sudo firewall-cmd --zone=public --add-port=6001/tcp --permanent

    # Reload Firewall
    sudo firewall-cmd --reload

    # Check for port
    sudo iptables-save | grep 6001

    # -A IN_public_allow -p tcp -m tcp --dport 6001 -m conntrack --ctstate NEW,UNTRACKED -j ACCEPT
    38 changes: 38 additions & 0 deletions laravel-echo-server.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    // laravel-echo-server init
    {
    "authHost": "https://your-domain.com",
    "authEndpoint": "/broadcasting/auth",
    "clients": [
    {
    "appId": "bac3036615df07cf",
    "key": "15fdd7bdd669b966a11f1a9bb6409595"
    }
    ],
    "database": "redis",
    "databaseConfig": {
    "redis": {},
    "sqlite": {
    "databasePath": "/database/laravel-echo-server.sqlite"
    }
    },
    "devMode": true,
    "host": "your-domain.com",
    "port": "6001",
    "protocol": "https",
    "socketio": {},
    "secureOptions": 67108864,
    "sslCertPath": "/home/CPANEL USER NAME/ssl/certs/domain_cert",
    "sslKeyPath": "/home/CPANEL USER NAME/ssl/keys/domain key", // it will be hashed file name try all fiels if you can
    "sslCertChainPath": "",
    "sslPassphrase": "",
    "subscribers": {
    "http": true,
    "redis": true
    },
    "apiOriginAllow": {
    "allowCors": true,
    "allowOrigin": "https://your-domain.com",
    "allowMethods": "GET, POST",
    "allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
    }
    }
    28 changes: 28 additions & 0 deletions pm2.config.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    module.exports = {
    apps: [
    {
    name: 'laravel-echo-server',
    script: 'laravel-echo-server',
    instances : 1, // default 'laravel-echo-server' required 1 instance only to work
    exec_mode : 'fork', // default
    interpreter: 'node', // default
    args: 'start',
    error_file: './storage/logs/pm2/pm2.error.log',
    out_file: './storage/logs/pm2/pm2.out.log',
    pid_file: './storage/logs/pm2/pm2.pid.log',
    cwd: "/home/CPANEL USER NAME/www",
    },
    {
    name: 'laravel-queue-worker',
    script: 'artisan',
    exec_mode: 'fork', // default
    interpreter: 'php',
    instances: 1,
    args: 'queue:work --tries=5 --sleep=1',
    error_file: './storage/logs/pm2/pm2.error.log',
    out_file: './storage/logs/pm2/pm2.out.log',
    pid_file: './storage/logs/pm2/pm2.pid.log',
    cwd: "/home/CPANEL USER NAME/www",
    },
    ]
    };
    18 changes: 18 additions & 0 deletions start pm2.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    # Start PM2 as Root (server user not host or cpanel normal user) or it will not work

    # Start PM2 and Provide Path to pm2.config.js (autocomplete paths in terminal may not work)
    sudo pm2 start "/home/CPANEL USER NAME/www/pm2.config.js"

    # Stop PM2 and Provide Path to pm2.config.js (autocomplete paths in terminal may not work)
    sudo pm2 stop "/home/CPANEL USER NAME/www/pm2.config.js"

    # Restart PM2 and Provide Path to pm2.config.js (autocomplete paths in terminal may not work)
    sudo pm2 restart "/home/CPANEL USER NAME/www/pm2.config.js"

    # Log All pm2 Apps
    sudo pm2 logs

    # Log specific pm2 app
    # sudo pm2 logs [app name]
    sudo pm2 logs laravel-echo-server
    sudo pm2 logs laravel-queue-worker