puphpet install wordpress on ubuntu server - php

I am wondering if anyone has attempted to automate the deployment of wordpress and puphpet.
I am not to familiar with puphpet but I know it uses the hiera.yaml file along with the manifets and modules folder. I attempted something simple
I added this to config.yaml file and imported the wordpress module from vagrant press
wordpress:
install: '1'
It looks like I may need to add something to the main manifest.pp file that puphpet generates. If anyone has attempted something like this I would appreciate any advice. Or is it better to just use yeoman instead?
Update
I add this to the config.yaml file
wordpress:
install: '1'
Then in the manifest.pp file I added this at the bottom form (wordpress vagrant box) and it seems to work:
# Begin wordpess
if $wordpress_values == undef {
$wordpress_values = hiera('wordpress', false)
if hash_key_equals($wordpress_values, 'install', 1) {
# Download WordPress
exec {"download_wordpress":
command => "wget http://wordpress.org/latest.tar.gz",
cwd => "/tmp",
creates => "/tmp/latest.tar.gz",
path => ["/usr/bin", "/bin", "/usr/local/bin"],
unless => "test -f /var/www/index.php",
}
# Extract WordPress
exec {"extract_wordpress":
command => "tar xzf /tmp/latest.tar.gz",
cwd => "/tmp",
creates => "/tmp/wordpress",
path => ["/usr/bin", "/usr/local/bin", "/bin"],
require => Exec["download_wordpress"],
unless => "test -f /var/www/index.php",
}
# Install WordPress
exec {"install_wordpress":
command => "cp -r /tmp/wordpress/* /var/www/wordpress",
cwd => "/tmp",
path => ["/usr/bin", "/usr/local/bin", "/bin", "/usr/local/sbin", "/usr/sbin", "/sbin"],
require => Exec["extract_wordpress"],
unless => "test -f /home/www/index.php",
}
}
}

PuPHPet uses hiera but not in the traditional Puppet way. You still need to actually create the Puppet code that interacts with the hiera values.

Related

Continuous Integration and Development with Laravel

I'm new to Laravel, currently working on my first project. I have worked with CI before but never with Laravel. So, here's my deploy script for our Dev server. Not sure if this is the best approach. Anyway, the migrate part is giving me an error. After I get this to work I will try some php plugins to analyze code quality, duplication, unit tests, etc.
Please, see below
Script:
rsync -a . /var/www/html/dev/
cd /var/www/html/dev/
# cfg file for dev
cp .env.dev .env
# run composer
composer clearcache
composer install --optimize-autoloader
# optimize
php artisan cache:clear
php artisan optimize
php artisan route:cache | true
# migrate DB
php artisan migrate
Error:
[Illuminate\Database\QueryException]
SQLSTATE[42S01]: Base table or view already exists:
Am I supposed to delete all my tables before doing the migration? If so, I don't see what's the useful part of using them for auto deployment. Besides, we have our tables filled with data for testing (manually filled as we don't want to auto seed).
You shouldn't delete all your tables before run migration.
This error come from your migrations table and your migrations at database\migrations folder have conflict.
You should resolve this conflict before return to continue configure Jenkins.
My suggestion:
You should use Rocketeer for control release versions of your projects.
You can share your .env file by shared folder.
You can run composer install and npm install by default configure of Rocketeer.
Here is my steps install and configure Rocketeer:
Install Rocketeer:
$ wget http://rocketeer.autopergamene.eu/versions/rocketeer.phar
$ chmod +x rocketeer.phar
$ mv rocketeer.phar /usr/local/bin/rocketeer
//TODO Install PHP for Jenkins server
$ sudo apt-get install php
//TODO Check rocketeer
$ rocketeer check
No connections have been set, please create one: (production) <~ Succeed
Setup remote server information
$ cd /var/lib/jenkins/drone-deploy/drone-deploy/server-dev
$ rocketeer ignite
No connections have been set, please create one: (production)develop
No host is set for [develop], please provide one:35.166.x.x
No username is set for [develop], please provide one:ec2-user
No password or SSH key is set for [develop], which would you use? (key) [key/password]key
Please enter the full path to your key (/var/lib/jenkins/.ssh/id_rs/var/lib/jenkins/.ssh/xxx.pem
If a keyphrase is required, provide it
No repository is set for [repository], please provide one:git#bitbucket.org:xx/xxxxxx.git
No username is set for [repository], please provide one:xxx
No password is set for [repository], please provide one:
develop/0 | Ignite (Creates Rocketeer's configuration)
What is your application's name ? (drone-php)drone_deploy
The Rocketeer configuration was created at server-dev/.rocketeer
Configure
$ cd /var/lib/jenkins/drone-deploy/drone-deploy/drone-php
$ nano .rocketeer/config.php
Replace connections name production --> develop //It's Rocketeer bug
$ nano .rocketeer/remote.php
'root_directory' => '/var/www/html/',
'shared' => [
'storage/logs',
'storage/framework/sessions',
'.env',
],
'permissions' => [
// The folders and files to set as web writable
'files' => [
//'app/database/production.sqlite',
'bootstrap',
'storage',
'public',
],
// Here you can configure what actions will be executed to set
// permissions on the folder above. The Closure can return
// a single command as a string or an array of commands
'callback' => function ($task, $file) {
return [
sprintf('chmod -R 777 %s', $file),
sprintf('chmod -R g+s %s', $file),
sprintf('chown -R ec2-user:ec2-user %s', $file),
];
},
],
$ nano .rocketeer/strategies.php
//'test' => 'Phpunit',
'test' => '',
//return $composer->install([], ['--no-interaction' => null, '--no-dev' => null, '--prefer-dist' => null]);
return $composer->install([]);
Running test
rocketeer deploy --on="develop" --tests

how to use YiiShop extension?

I downloaded YiiShop extension from here
Then I followed the instruction:
1.Make a folder in my webapp named modules, then extracted the extension there
2.Do some configuration in webapp/protected/config/main.php
'modules' => array(
...
'shop' => array('debug' => 'true'),
...
),
3.I tried to run it as instructed, webapp/shop/install, but it turns error:
Alias "shop.ShopModule" is invalid. Make sure it points to an existing PHP file and the file is readable.
Any ideas how to fix this?
Thanks.
may be a permission error..
What operating system you are using?
If linux then try this command in terminal -
sudo chmod 777 -R /path_to_root_dir/project_name
warning : do not use this command in your file system!

Composer update ran via puppet times out

I'm using composer to manage dependencies. And basically want I want to do is automatically run composer update in puppet config when vagrant up is running.
I'm using puphpet to generate puppet files for vagrant.
I added composer::exec section in this code in the default.pp file:
if $php_values['composer'] == 1 {
class { 'composer':
target_dir => '/usr/local/bin',
composer_file => 'composer',
download_method => 'curl',
logoutput => true,
tmp_path => '/tmp',
php_package => "${php::params::module_prefix}cli",
curl_package => 'curl',
suhosin_enabled => false,
}
composer::exec { 'composer-update':
cmd => 'update',
cwd => '/var/www/myproject'
}
}
Some times I'm getting this error in output:
Error: Command exceeded timeout
Error: /Stage[main]//Composer::Exec[composer-update]/Exec[composer_update_composer-update]/returns: change from notrun to 0 failed: Command exceeded timeout
And there is no timeout property in puppet composer.
How to solve it?
Take a look at http://docs.puppetlabs.com/references/latest/type.html#exec-attribute-timeout - it is possible to set a timeout for an exec resource. If the puppet composer module does not provide an option to override that, it really should IMO. And if by a chance it is composer itself that's timing out, not puppet exec, you'd wanna try
export COMPOSER_PROCESS_TIMEOUT=600

Error! Symfony2 with KNP Snappy Bundle & WKHTML2PDF

When I go to /fileDownload I receive a 500 Internal Server Error - RuntimeException:
The process stopped because of a "0" signal.
Controller Action:
public function fileAction()
{
$html = $this->render('MyBundle:Downloads:file.html.twig', array(
'fileNumber' => '1234'
));
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="file.pdf"'
)
);
}
I've used terminal commands for WKHTMLTOPDF and it has successfully generated the PDF. It just will not work in Symfony2 app.
In my config.yml:
knp_snappy:
pdf:
enabled: true
binary: /usr/local/bin/wkhtmltopdf
options: []
I'm assuming Symfony is issuing an exec() at some stage. You need to get the exact command line error returned. The fact it works for you in a terminal session doesn't necessarily mean it will work when a different user/process is running it.
Check permissions on wkhtmltopdf that apache or whoever is running your web server has access to run the command.
Also, check this question out wkhtmltopdf: cannot connect to X server and also the first post here: http://geekisland.org/index.php?m=05&y=11&entry=entry110518-114630
X Server is required to run certain builds of wkhtmltopdf and it is not present when running via cron or from within an apache process. If this is the case you need to use the bash wrapper in the first link above.
Be sure that wkhtmltopdf is indeed in the folder you specify, with correct permissions: /usr/local/bin/wkhtmltopdf
I am successfully using KNP Snappy Bundle with Symfony 2.0, try using RenderView instead of render when generating the html (check my code that is working):
Controller:
$html = $this->renderView('YOPYourOwnPoetBundle:thePoet:poemPDF.html.twig', array(
'poem' => $customizedPoem,
'fontType' => $fontType,
'fontSize' => $formData['fontSize'],
'fontWeight' => $fontWeight,
'fontStyle' => $fontStyle,
));
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="'.$session->get('poemTitle').'.pdf"',
)
);
I had this same issue and i finally solved it, my advice is if you installed the wkhtmltopdf lib from your OS repos then remove it, and download the static version from the google code website, and don't use version 11rc, use the version 9 static lib, it's the one that worked with me.
http://code.google.com/p/wkhtmltopdf/downloads/list
It looks like the selinux is blocking your command, I had the same issue once but I solved it by disabling the SELinux and now I'm able to generate the pdf file using wkhtmltopdf+php.
exec("/usr/local/bin/wkhtmltopdf http://www.google.com /var/www/html/google.pdf");
To disable selinux run setenforce 0,
try again and see if it works.
Re-enable it with setenforce 1
But disabling selinux is not the best solution for this, you need to extend it instead using audit2allow, it will automatically create a custom policy module that will resolve this issue,
First install audit2allo if not already installed
yum -y install policycoreutils-python
grep httpd_t /var/log/audit/audit.log | audit2allow -m httpdlocal > httpd.te
checkmodule -M -m -o httpdlocal.mod httpd.te
semodule_package -o httpdlocal.pp -m httpdlocal.mod
semodule -i httpdlocal.pp
try again and see if it works
I experienced the same issue on same scenario with wkhtmltopdf. And I got rid of with the following command:
setsebool httpd_execmem on

php custom C++ module works from command line, not on webserver

I made a custom PHP module with C++ and Swig. It works from the command line, but not with my webserver:
php index.php
php-cgi index.php
Both of those work fine.
I'm using lighttpd and php. I didn't configure these in any special way. I just installed them using sudo apt-get install.
Unfortunately if I make a webpage I get this:
Fatal error: Call to undefined function minikey_to_wif() in /var/www/index.php on line 6
Calling function_exists("minikey_to_wif") returns False too.
The phpinfo() does not show my module called minikey, and shows the same configuration path as the file I edited (/etc/php5/cgi/php.ini):
extension=/path/to/php-ext/minikey/minikey.so
I also tried copying it to where the other PHP extensions seem to be installed (/usr/lib/php5/20090626+lfs/) but that didn't work either.
I've been stopping, and starting lighttpd countless times. Each time, when I run ps aux | grep php, there are no results. I've also rebooted a few times to no effect. I have no idea what's up.
OK found the answer.
The extension relied on a library which was installed in a non-standard location. Normally I set LD_LIBRARY_PATH in ~/.bashrc. But when the web server ran the extension, it didn't have that environment variable.
Fix was to create a file in /etc/ld.so.conf.d/genjix.conf with /home/genjix/usr/lib and run ldconfig as root.
Try running phpinfo() using lighty. Make sure that its pointing to the correct php.ini.
If you think this is the problem you can launch php using the -c switch from inside lighttpd.conf with "bin-path" => "/path/to/php-cgi -c /path/to/php.ini":
e.g.
fastcgi.server = (
".php" => (
(
"bin-path" => "/path/to/php-cgi -c /path/to/php.ini",
"socket" => "/tmp/php.socket",
"max-procs" => 4,
"idle-timeout" => 30,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "1000"
)
)
)
)

Categories