How to setup Wordpress with https://box.scotch.io/? - wordpress

I have setup scotch box and now trying to setup WordPress with scotch box how would I go by doing this please.

I have recently set this up.
To set up Wordpress, place the Wordpress install files inside the scotch/public folder that is created when you first run scotch.io
You will then need to ssh into your vagrant box, and set up a new MySQL database. You can import a dump via the command line, or export/import using Sequel like I did.
Even though mod_rewrite is already enabled in scotch.io, I found it helpful to restart the apache2 server in the vagrant box.
Once that's done - you should be able to navigate to 192.168.33.10 on your browser to see your install.
Set the wp_config.php database host to localhost.
I found the following code great for getting permalinks working, place this at the top of your wp_config file:
$s = empty($_SERVER['HTTPS']) ? '' : ($_SERVER['HTTPS'] == 'on') ?
's' : '';
$port = ($_SERVER['SERVER_PORT'] == '80') ? '' : (":".$_SERVER['SERVER_PORT']);
$url = "http$s://" . $_SERVER['HTTP_HOST'] . $port;
define('WP_HOME', $url);
define('WP_SITEURL', $url);
unset($s, $port, $url);
If you get a Database access error - this is a good sign you're on the right track, you need to put in the user: root / pass: root details fro the vagrant web host to access the database inside the box.

Related

WordPress Error establishing a database connection MySQL on non-default port

I'm trying to install wordpress on my localhost with XAMPP. My Apache module is on ports 80,443 and my MySQL module is on port 3307 (default is 3306). I can't start installing wordpress. After entering localhost/wordpress in my browser there apears error "Error establishing a database connection". I don't have wp-config.php file i guess it creates after starting installation which i can't start
I tried changing wp-config-sample.php but it looks like it doesn't change anything i also tried creating wp-config.php on my own and changing DB details there
You have to change config.php not config-sample.php.
define( 'DB_NAME', 'your_dbname' );
define( 'DB_USER', 'your_dbuser' );
define( 'DB_PASSWORD', 'your_dbpasw' );
define( 'DB_HOST', 'localhost:3307' );
That's all you need. Just append ":" after localhost (or your machine ip address/host name)
Having a database connection issue would mean there's a "wp-config.php" file being used, and the credentials are incorrect -- hostname, port, credentials, or possibly not having a database created yet.
During an initial setup, WordPress will create the wp-config.php file with the MySQL credentials, when the connection is a success. If you're not getting a setup page, review your "wp-config.php" file, or delete all of the contents and start over with a new WordPress download. Extract the zip/tar.gz archive, and move the contents in the "wordpress/" folder into your site's DocumentRoot.
You can also test your MySQL credentials with this command:
mysql -h localhost -P 3307 -u DatabaseUsername -p
The uppercase "P" is for port, and the lowercase "p" is for password. If entering the password at the prompt is successful, check that you've got a database with show databases;.

Phpmyadmin fail wordpress

I try to install wordpress in local but I have problem with I create database.
[]
I don't know why phpmyadmin doesn't work. I had change some port like database . I change the "mi.ini" file in 3306 in 3307. Anyone can help me?
Looks like you might already be running a copy of mysql (or something else) on port 3306. PhpMyAdmin has a config file probably pointing to port 3306 with incorrect credentials.
You need to either alter your mysql config or update your phpmyadmin config (xampp\phpmyadmin\config.inc.php) to point to the new port number (3307 according to xampp) The line will look like $cfg['Servers'][$i]['host'] = '127.0.0.1:3307';

How to access to symfony Dev environnement behind varnish?

After installing varnish in front of apache2, I can not access the dev environment of symfony2 project (connected from localhost, so it worked before installing varnish).
I got the symfony2 access denied message "You are not allowed to access this file. Check app_dev.php for more information."
When looking into app_dev.php file:
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(#$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1')) || php_sapi_name() === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
After debuging the problem, i found that the $_SERVER['HTTP_CLIENT_IP'] is NULL.
How to fix this ?
Thank you.
Note: I'm using ubuntu 14.04 + apache2.4 + varnish 3 + Symfony2.4
The line would return a 403 if either:
HTTP_CLIENT_IP header is present
HTTP_X_FORWARDED_FOR header is present
$_SERVER['REMOTE_ADDR'] is not one of '127.0.0.1', 'fe80::1', '::1'
Probably you are setting the HTTP_X_FORWARDED_FOR header in varnish, or varnish is setting it for you, depending on the varnish version. Unset it or rewrite the condition, it's a safety measure so act accordingly.
You have some interesting info here: http://symfony.com/doc/current/cookbook/cache/varnish.html

Symfony2 get error code for flush function

I am using Symfony and creating a soft with 3 tiers (client, apache, mysql). So I don't know how to get the statut when the symfony application persists and flushs something?
When I add something in database I display an alert like "Add done!" but if my database is down I will display "Add done" despite the fail...
So how can I get the statut of these functions (flush/persist)? How can I change my alert switch the statut?
Best regards,
Use a try & catch block:
try {
$article = new Article(); //Example entity
$em = $this->getDoctrine()->getEntityManager();
$em->persist($article);
$em->flush();
$this->get('session')->setFlash('flash_key',"Add done!");
} catch (Exception $e) {
$this->get('session')->setFlash('flash_key',"Add not done: " . $e->getMessage());
}
In case you get errors try using "\Doctrine\ORM\ORMException $e", \Doctrine\DBAL\DBALException $e" or "\Exception $e" inside catch()
My issue was that I was passing a complex object into a field that expected a string even though I had set that column up to be a ManyToOne. Apparently #ORM\Column overrode that.
However! It's not what the error was that's interesting, it's how I fixed it.
I was having a PDOException. I had to deep dive into the code with xdebug and PHPStorm. xdebug is supported by many PHP IDEs. xdebug is tough to set up the first several times that you set it up. There's always some firewall hassle or hassle getting it to show up in your phpinfo() or xdebug.enable_remote or xdebug.remote_host.
Get used to it. JUST DO IT! No seriously. Don't write another line of code in PHP until you have got xdebug working; even if you run into 8 million issues. You will save years of your life in coding.
I don't know about Symfony, but ZF3 now comes with a Vagrantfile. You install vagrant and Oracle VirtualBox, type vangrant up in your Zf3 project directory, and you have a fully-functional local web server running your ZF3 application at http://localhost:8080. From there all I had to do was:
... Well first, before I called vagrant up for the first time, I added the following line to the Vagrantfile
config.vm.network "private_network", ip: "192.168.33.10" ... then I called vagrant up
vangrant ssh
sudo -s
apt-get install php-xdebug
echo "xdebug.remote_enable = 1" >> /etc/php/7.0/apache2/php.ini
echo "xdebug.remote_host = 192.168.33.1" >> /etc/php/7.0/apache2/php.ini
apachectl restart
In your phpinfo(), you should see xdebug somwhere. Just ctrl + f for it. If it's there, you're mostly in business.
Then I added a rule for port 9000 on my firewall. Then I started an xdebug session. If it doesn't work You can temporarily shut down Windows Firewall just to check if it works, but remember to enable it right away and make sure it's not just the firewall. Setup a firewall rule for incoming on port 9000 and allow ip 192.168.33.10. If you don't know how to do this ... why are you trying to develop web software?
Learn to use xdebug!!!

Your PHP installation appears to be missing the MySQL extension which is required by WordPress - for multiple instance

My system is running 2 MySQL instance
One is running on port 3306 another on port 3307
Now I want to connect my WordPress to MySQL which is running on port 3307
But I am getting error when I try to access index page - Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
Please let me guide how to resolve the problem.
Edit the definition of DB_HOST in your wp-config.php file by adding :3307. From the documentation:
If your host uses an alternate port number for your database you'll
need to change the DB_HOST value in the wp-config.php file to reflect
the alternate port provided by your host.
For localhost
define( 'DB_HOST', 'localhost:3307' );
Other
define( 'DB_HOST', 'mysql.example.com:3307' );
Replace 3307 with whatever port number your host gives you.
Solution 1:
Check your php.ini and make sure that you have extension=php_mysql.dll un-commented.
Solution 2:
You can use the following library if you do not have mysql_connect enabled but have PDO enabled:
https://github.com/AzizSaleh/mysql
Create a new file: wp-content/db.php and place this code in it (update your path to mysql with path to your extracted folder):
<?php
$pathToMySQL = 'C:\\xampp\\htdocs\\mysql\\';
require_once($pathToMySQL . 'MySQL_Definitions.php');
require_once($pathToMySQL . 'MySQL.php');
require_once($pathToMySQL . 'MySQL_Functions.php');

Resources