hcho3 / xgboost-devops

DevOps / Continuous Integration tools for XGBoost project
Apache License 2.0
3 stars 2 forks source link

How to serve PHP files from a subdirectory of xgboost-ci.net #10

Open hcho3 opened 4 years ago

hcho3 commented 4 years ago

I've set up a website from a subdirectory of xgboost-ci.net: https://xgboost-ci.net/dashboard/. In #6, we chose Nginx for the web server, so we modify the Nginx configuration here.

  1. Create the directory /var/www/xgboost-ci.net/html/dashboard.
  2. Create the file index.php in /var/www/xgboost-ci.net/html/dashboard with the following content:
    <?php phpinfo(); ?>
  3. Since Nginx doesn't contain native PHP processing like Apache, we install the FastCGI PHP bridge by running sudo apt install php7.2-fpm php7.2-mbstring php7.2-xml php-pear.
  4. Open the configuration file /etc/nginx/sites-enabled/xgboost-ci.net. Add the following configuration block to the server block:
    location ^~ /dashboard {
    alias /var/www/xgboost-ci.net/html/dashboard;
    try_files $uri $uri/ =404;
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    }
    }

    Also, change the line index index.html index.htm; to index index.html index.htm index.php;.

  5. Run sudo nginx -t to verify the modified configuration.
  6. Restart Nginx to apply the new configuration: sudo systemctl reload nginx.
  7. Verify that https://xgboost-ci.net loads the Jenkins website and that https://xgboost-ci.net/dashboard/ loads the index.php we created earlier.
hcho3 commented 4 years ago

Enabling YAML parser in PHP:

sudo apt-get install php-dev php-pear libyaml-dev
sudo pecl install yamL
sudo sh -c "echo 'extension=yaml.so' >> /etc/php/7.2/fpm/php.ini"
sudo service php7.2-fpm restart
sudo systemctl restart nginx