BFH Handwriting Website Deployment: Difference between revisions
(Created page with "Category:BFH Handwriting Category:Web Development == `composer` == === Installation === `composer` is not available on Namecheap servers. It's necessary to install i...") |
|||
| (4 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
[[ | == PHP == | ||
=== App code === | |||
App code is uploaded using PHPStorm's "sync with deployed" command. | |||
* Create a remote host (it's possible to copy an existing host in order to apply existing excluded paths) | |||
* Set permissions options such that files are uploaded with `644` permissions and directories have `755` permissions. | |||
Ultimately, it would be preferable to use git instead of PHPStorm, even with Namecheap hosting. That will require cloning the repo on the remote server, which will take some time for copying over files not under version control, e.g. images, and for QA. | |||
=== `common_lib` library === | |||
Ultimately, this will be replaced with `littled_lib` and this step can be removed. | |||
Until then, there is a separate GitHub repo for `common_lib`, and a separate PHPStorm project for it also. | |||
A separate "sync with deployed" job is performed with the `common_lib` project open in PHPStorm. | |||
=== `littled_lib` library === | |||
This is installed using [[#composer|`composer`]]. | |||
== `composer` == | == `composer` == | ||
`composer` is the standard for installing PHP packages. The Authorize.net and PayPal SDKs are distributed with `composer`. | |||
=== Prerequisites === | |||
* `git` | |||
** See [https://www.namecheap.com/support/knowledgebase/article.aspx/9586/89/how-to-deal-with-git-on-our-shared-servers Namecheap's documentation about using `git` on shared servers]. | |||
** Basically `git` is installed, but the path to `git` (`/usr/local/cpanel/3rdparty/bin`) has to be added to bash's `PATH`. | |||
=== Installation === | === Installation === | ||
| Line 8: | Line 38: | ||
* `ssh` to the server | * `ssh` to the server | ||
* `cd` to site root directory | * `cd` to site root directory | ||
* Follow the instructions from the [https://getcomposer.org/download/ Download Composer] page. | * Follow the instructions from the [https://getcomposer.org/download/ Download Composer] page. | ||
** `.phar` files are not whitelisted in Namecheap's `php.ini`. It's necessary to override this when installing and running `composer`, e.g. `php -d suhosin.executor.include | |||
=== Installing and updating packages === | |||
* Composer requirements are stored in `composer.json`. | |||
** Edit this file locally and upload it to the Namecheap server. | |||
** Do not edit `composer.json` directly on the production server. | |||
** Do not add requirements to `composer.json` on production by running `composer require` commands on the production server. | |||
* `composer` arguments | |||
** `.phar` files are not whitelisted in Namecheap's `php.ini`. It's necessary to override this when installing and running `composer`, e.g. `-d suhosin.executor.include/whitelist=phar` | |||
** Namecheap puts a low memory limit on the PHP processes. It may be necessary to increase this limit, e.g. `-d memory_limit=1G` | |||
** Authorize.net's documentations places some dependencies in `require-dev`, however running composer with the `--no-dev` option throws a bunch of errors. Even in production environments it's therefore necessary to not use this option. | |||
** Some of Authorize.net's dependencies are hosted on GitHub. Therefore it's necessary to have access to the `git` executable in order to run `composer update`. | |||
On the production server, in the root directory of the site, run: | |||
<syntaxhighlight lang="bash"> | |||
$ php -d suhosin.executor.include.whitelist=phar -d memory_limit=1G composer.phar update | |||
</syntaxhighlight> | |||
[[Category:BFH Handwriting]][[Category:Web Hosting]][[Category:Web Development]] | |||
Latest revision as of 20:43, 27 August 2020
PHP[edit]
App code[edit]
App code is uploaded using PHPStorm's "sync with deployed" command.
- Create a remote host (it's possible to copy an existing host in order to apply existing excluded paths)
- Set permissions options such that files are uploaded with
644permissions and directories have755permissions.
Ultimately, it would be preferable to use git instead of PHPStorm, even with Namecheap hosting. That will require cloning the repo on the remote server, which will take some time for copying over files not under version control, e.g. images, and for QA.
common_lib library[edit]
Ultimately, this will be replaced with littled_lib and this step can be removed.
Until then, there is a separate GitHub repo for common_lib, and a separate PHPStorm project for it also.
A separate "sync with deployed" job is performed with the common_lib project open in PHPStorm.
littled_lib library[edit]
This is installed using composer.
composer[edit]
composer is the standard for installing PHP packages. The Authorize.net and PayPal SDKs are distributed with composer.
Prerequisites[edit]
git- See Namecheap's documentation about using
giton shared servers. - Basically
gitis installed, but the path togit(/usr/local/cpanel/3rdparty/bin) has to be added to bash'sPATH.
- See Namecheap's documentation about using
Installation[edit]
composer is not available on Namecheap servers. It's necessary to install it manually.
sshto the servercdto site root directory- Follow the instructions from the Download Composer page.
Installing and updating packages[edit]
- Composer requirements are stored in
composer.json.- Edit this file locally and upload it to the Namecheap server.
- Do not edit
composer.jsondirectly on the production server. - Do not add requirements to
composer.jsonon production by runningcomposer requirecommands on the production server.
composerarguments.pharfiles are not whitelisted in Namecheap'sphp.ini. It's necessary to override this when installing and runningcomposer, e.g.-d suhosin.executor.include/whitelist=phar- Namecheap puts a low memory limit on the PHP processes. It may be necessary to increase this limit, e.g.
-d memory_limit=1G - Authorize.net's documentations places some dependencies in
require-dev, however running composer with the--no-devoption throws a bunch of errors. Even in production environments it's therefore necessary to not use this option. - Some of Authorize.net's dependencies are hosted on GitHub. Therefore it's necessary to have access to the
gitexecutable in order to runcomposer update.
On the production server, in the root directory of the site, run:
$ php -d suhosin.executor.include.whitelist=phar -d memory_limit=1G composer.phar update