<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>php &#8211; Deep Core Labs</title>
	<atom:link href="https://deepcorelabs.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>https://deepcorelabs.com</link>
	<description>Building Extraordinary Brands</description>
	<lastBuildDate>Fri, 23 Oct 2015 06:21:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://deepcorelabs.com/wp-content/uploads/2015/09/deep-core-labs-logo-small-50x50.png</url>
	<title>php &#8211; Deep Core Labs</title>
	<link>https://deepcorelabs.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Automatically Install WordPress and Create Database on Plesk</title>
		<link>https://deepcorelabs.com/automatically-install-wordpress-and-create-database-on-plesk/</link>
					<comments>https://deepcorelabs.com/automatically-install-wordpress-and-create-database-on-plesk/#respond</comments>
		
		<dc:creator><![CDATA[Miro Hristov]]></dc:creator>
		<pubDate>Wed, 21 Oct 2015 18:05:46 +0000</pubDate>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[wordpress]]></category>
		<guid isPermaLink="false">http://deepcorelabs.com/?p=175</guid>

					<description><![CDATA[Overview This code was inspired, well, by laziness. It automatically creates a MySql database and User using the provided information; Downloads the latest version of WP and unzips it; Changes your...]]></description>
										<content:encoded><![CDATA[<h2>Overview</h2>
<p>This code was inspired, well, by laziness.</p>
<p>It automatically creates a MySql database and User using the provided information; Downloads the latest version of WP and unzips it; Changes your config-wp.php to work with the newly created database. Uses SSH2 to connect to shell.</p>
<p>Feel free to use it as is or modify it to your needs. Please report bugs and fixes.</p>
<p>Tested on Plesk 12.0.18.</p>
<h2>Requirements</h2>
<ol>
<li>Odin (former Parallels) Plesk</li>
<li>Root access</li>
<li>PHP 5+</li>
</ol>
<a class="nectar-button n-sc-button small accent-color regular-button" target="_blank" href="https://deepcorelabs.com/wp-content/uploads/2015/10/autowp.zip" data-color-override="false" data-hover-color-override="false" data-hover-text-color-override="#fff"><span>Download ZIP</span></a>
<pre class="lang:php decode:true ">&lt;?php

///////////////////////
// CONFIG
///////////////////////

$rootuser = "root";     // the root user
$rootpass = "PASSWORD"; // the root password
$domainspath = "/var/www/vhosts"; //path to all your domains

///////////////////////
///////////////////////

$db_name = $_REQUEST['db'];
$domain = $_REQUEST['domain'];
$dir = $_REQUEST['dir'];
$user = $_REQUEST['user'];
$pass = $_REQUEST['pass'];
$del = $_REQUEST['del'];
?&gt;

&lt;style&gt;
body {
font-family:sans-serif;
margin:1em;
font-size:1.2em;
color:grey
}

input {
font-size:1.2em;
padding:.3em;
border-radius:4px;
border:1px solid #DEDEDE
}

label {
margin-top:1em
}

input[type='text'] {
width:600px
}

label,input {
display:block
}

.small {
font-size:.5em;
text-transform:uppercase
}

input[type='submit'] {
padding:.5em 1em;
margin:1em 0;
background:#7c3
}

input[type='checkbox'] {
display:inline;
width:.8em;
height:.8em
}
&lt;/style&gt;

&lt;h1&gt;Install WordPress &amp;amp; Create Database&lt;/h1&gt;
&lt;form id="doit" method="post"&gt;
  &lt;label&gt;
    Create Database
    &lt;input id="db" name="db" type="text" /&gt;
  &lt;/label&gt;
  &lt;label&gt;
    Domain
    &lt;input id="domain" name="domain" type="text" /&gt;
  &lt;/label&gt;
  &lt;label&gt;
    Directory
    &lt;input id="dir" name="dir" type="text" /&gt;
  &lt;/label&gt;
  &lt;label&gt;
    Username
    &lt;input id="user" name="user" type="text" /&gt;
  &lt;/label&gt;
  &lt;label&gt;
    Password
    &lt;input id="pass" name="pass" type="text" /&gt;
    &lt;span class="small"&gt;(Must not contain username)&lt;/span&gt;
  &lt;/label&gt;
  &lt;label&gt;
    Delete folder contents? &lt;input type="checkbox" name="del" value="Yes" /&gt;
  &lt;/label&gt;
  &lt;input type="submit" value="Install WP"&gt;
&lt;/form&gt;

&lt;?php

echo "&lt;pre&gt;";

if(empty($domain)){ die("API usage syntax example: ?db=mydb&amp;domain=domain.com&amp;dir=projects/company&amp;user=user&amp;pass=pass"); }
 

//////////////////////////////
// Connect to SSH
//////////////////////////////

//Incude SSH2 phpseclib to use shell commands
set_include_path(get_include_path() . 'SSH2' . PATH_SEPARATOR . 'phpseclib');
include('SSH2/Net/SSH2.php');
$ssh = new Net_SSH2('localhost');
if (!$ssh-&gt;login($rootuser, $rootpass)) {
    exit('SSH2 Login Failed');
}


/////////////////////////////
// CREATE USER
/////////////////////////////
echo $ssh-&gt;exec("/usr/sbin/useradd -g psacln -d /var/www/vhosts/".$domain."/httpdocs/".$dir." ".$user);
//CHMOD to User
echo $ssh-&gt;exec("chown -R ".$user.":psacln /var/www/vhosts/".$domain."/httpdocs/".$dir); 
//echo $ssh-&gt;exec("chown -R apache:psaserv /var/www/vhosts/".$domain."/httpdocs/".$dir); //CHMOD to Apache
echo $ssh-&gt;exec("chmod 775 /var/www/vhosts/".$domain."/httpdocs/".$dir);

/////////////////////////////
// Change Password
/////////////////////////////

$ssh-&gt;write("passwd ".$user."\n");
echo $ssh-&gt;read('New UNIX password:');
$ssh-&gt;write($pass."\n");
echo $ssh-&gt;read('Retype new UNIX password:');
$ssh-&gt;write($pass."\n");
echo $ssh-&gt;read('passwd: all authentication tokens updated successfully.');

echo "&lt;p&gt;===== End Create User =====&lt;/p&gt;";

//////////////////////////
// Plesk DB Create
//////////////////////////

echo $ssh-&gt;exec('cd '.$domainspath);

echo $ssh-&gt;exec('/usr/local/psa/bin/database --create '.$db_name.' -domain '.$domain.' -print-id -server localhost -type mysql');
echo $ssh-&gt;exec('/usr/local/psa/bin/database --update '.$db_name.' -add_user '.$user.' -passwd '.$pass);
echo "&lt;p&gt;===== End DB Create =====&lt;/p&gt;";
echo die();

////////////////////////////////////
// Download and Untar wordpress
////////////////////////////////////
$c = 'cd '.$domainspath.'/'.$domain.'/httpdocs/;';

if(!empty($dir)){
    $c .= 'mkdir -p '.$dir.';'
    .'cd '.$dir.';';
}

if(isset($del) &amp;&amp; $del == 'Yes'){
    $c .='rm * -r;';  //DELETES EVEYTHING INSIDE 
}

$c .='wget --no-check-certificate https://www.wordpress.org/latest.tar.gz;'
    .'tar xfvz latest.tar.gz;'
    .'mv wordpress/* .;'
    .'rmdir wordpress;'
    .'rm latest.tar.gz;'
    .'cp wp-config-sample.php wp-config.php;'
    .'perl -pi -e "s/database_name_here/'.$db_name.'/g" wp-config.php;'
    .'perl -pi -e "s/username_here/'.$user.'/g" wp-config.php;'
    .'perl -pi -e "s/password_here/'.$pass.'/g" wp-config.php;'
    .'mkdir wp-content/uploads;'
    .'chmod 777 wp-content/uploads;';


$pc = str_replace(';', ';&lt;br&gt;', $c);
echo '&lt;br&gt;$ '.$pc;
echo $ssh-&gt;exec($c);

echo "&lt;p&gt;===== End WP download &amp; wp-config =====&lt;/p&gt;";
?&gt;
&lt;/pre&gt;</pre>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://deepcorelabs.com/automatically-install-wordpress-and-create-database-on-plesk/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
