Create PHP Application

Apache/Nginx and PHP engines which allow you to develop web applications and store files in the web space to build your own website. Hence, these files should be compressed into package.tgz. In the start-stop-status script, you should link or copy them to the web space when starting a package. In DSM, the default web space is the web shared folder. You can get the path via /var/services/web which is a symbolic link pointing to the actual path in the volume.

In DSM 5.2 or older, the web application works after the administrator enables Web Station. You can configure the install_dep_services and start_dep_services keys with the apache-web value in the INFO file to make sure Web Station is enabled before the package installation. In DSM 6.0 or newer, the web application works after the administrator installs and starts Web Station and PHP package. You can configure the install_dep_packages with "WebStation:PHP5.6" value in the INFO file to make sure these packages installed and started before the package installation.

You can then provide a URL in order to access your page to adminurl (ex:"/myapp/index.html") in INFO which will be displayed in Package Center to tell the client which URL to open. When the package stops, this URL should not be accessible. You can remove or unlink the website folder in the web space, or let the web page redirect to an error page.

In addition, it is recommended to add an icon to DSM’s main menu so that users can click the icon to launch the application intuitively.

To customize the config settings for Apache, Nginx or PHP, please do not modify any of the config files belonging to DSM. Instead, you should create symbolic links for your config files in the corresponding locations. For Apache/Nginx, link your config to the folder /etc/httpd/sites-enabled-user/your_package_name.conf. For PHP, please refer to PHP INI for more detail.

In addition, add the apache-web in DSM 5.2 or order, or nginx in DSM 6.0 or newer to the start_stop_restart_services to make Apache/Nginx reload config files. Otherwise, these symbolic links should be removed along with the package.

Here is an example of apache config:

<Directory "/var/services/photo">
        Options MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all