I want to launch an Amazon Linux EC2 instance and on boot-up I want to run a PHP script. I am using the AWS PHP SDK.
Referring to this, I understand that I can run a shell script by passing it as userdata. However, is it possible to run a PHP script on bootup?
What are other ways to run PHP scripts on boot-up?
PS: I am running the instance from ab AMI which already has PHP 5.4 installed.
Pass a Bash script in the user data, like your link describes. Have the Bash script download the PHP script from S3 and then execute it. Or you could embed the PHP script directly in the Bash script and skip the S3 part.
Related
I formatted my system and after that i noticed that my laravel clear code on CMD is no longer working rather each time i try to clear my cache on CMD, i get this error message 'php is not recognized as an internal or external command, operable program or batch file'. Please i need help as this has really been tormenting my laravel project. This is the code i have been using for the clearing C:\xam\htdocs\ib>php artisan cache:clear. I want to understand if am doing something wrong. And this started after i reinstalled my window 8.1 to window 10.
Actually it has nothing to do with cache or artisan. Everything you need to know to fix this is to understand this error.
php is not recognized as an internal or external command
Is is error directly from Windows command line, and not Laravel. You are trying to use "php" command that Windows does not understand because it is not build-it functionality.
You need to have installed PHP on your system and set alias that will point to php executable file (where you installed PHP).
If you already have PHP somewhere installed then you need to just set alias (system variable): How to access PHP with the Command Line on Windows?
But I guess previously you had some all-in-one server solution that will include PHP, Apache/Nginx, Mysql/Mariadb etc, and there ale many ways to do that on Windows:
XAMPP It will install Apache, Mysql, PHP etc.
Laragon Similar to XAMPP but it is more focused on Laravel.
Laradock Pack of Docker images with all software needed.
Laravel Homestand Ready to use environment on virtual machine.
Or just manually install PHP standalone ;)
MacOS 10.13.3 (17D102)
I have composer 1.6.3 installed on PHP 7.1.7.
My end goal is to set up Drupal 8 in a dual Docker container setup; web in one, DB in another. We have scripts to do that. I cannot update this script.
When I try to run that script, I get errors like "composer: command not found".
On the command line, composer works, but in my .bash_profile, I see:
alias composer="php /usr/local/bin/composer.phar"
so that alias isn't available to my script (guess).
Others running composer on Mac don't have the alias. On their machines:
type composer
reveals
composer is hashed (/usr/local/bin/composer)
So they don't use an alias and the script does work.
What is the best way to get composer available to scripts? A fresh and different install method for composer?
When I SSH into homestead, I no longer need to prepend my artisan commands with php. ie. I can write, for example
artisan -h
rather than
php artisan -h
But on my local machine, I always have to first issue the command through php. How is it that this is not necessary within homestead, and is there a way to replicate this behaviour on my local machine. I am running Windows 7.
The answer really depends on what OS you're running locally. On macOS / Linux, you can edit (or create) a .bash_aliases file in your user folder and add the line:
alias artisan='php artisan'
You can see this in action by running the following command in homestead:
nano ~/.bash_aliases
Just finished developing a web application using laravel 5.3, how can i create an installation procedures (html,script) like that of wordpress that will create database,run a script to create tables, create .env file and sort of stuff/
Is there any package that can do this?
Thanks.
If you use homestead or vagrant you could write a script to configure your bootstrap.sh and vagrantfile to provision your box and install your box. Then have it vagrant up to start your box.
bootstrap.sh file can be found https://www.vagrantup.com/intro/getting-started/provisioning.html. Homestead has a folder scripts that shows all the different scripts and the configuration that can be used to provision your box. You would simply just write a script to automate the installation of homestead or vagrant and that should be it.
If you are pushing this out into the wild and need to automate builds, run unit tests and create migrations you could use https://jenkins.io/
I have pushed my local app to openshift and now get the following error message
PHP Fatal error: Class 'Illuminate\Html\HtmlServiceProvider' not found in /var/lib/openshift/5728b9782d5271802600015c/app-root/runtime/repo/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 150
How do I fix this on Openshift?
The solution locally would be to run composer update but how do I run that command on Openshift? I know there is rhc command line tool but is it possible to do a composer update with rhc?
You should check for the files first. You may have corrupted/missing files during upload. If you do not have vendor directory, you shoudl run composer update.
If files are there, run composer dumpauto on the server.
You can connect to you server with SSH and run these commands from terminal.
If you do not have access to SSH, you could try to run there commands using small PHP script with shell_exec('composer update'); clause in it, or just upload all vendor files manually.
I got ssh access and did the commands necessary to correct the problems