1

I'm trying to set up my Xampp htdocs location to a Google Drive folder so that I can work on my wordpress site from any location and also sharing it with my PC-laptop.

Following along some tips & tutorials (such as: how to change xampp htdocs directory in OSX?) I now can access my localhost. However, browsing to my wordpress site located in localhost/testsite/ results in:

'Error establishing a database connection"

Any suggestions what can be wrong? Is it no possible to share htdocs-folder between PC & MAC?

my vhost.conf looks like (unchanged):

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/Applications/XAMPP/xamppfiles/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/Applications/XAMPP/xamppfiles/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error_log"
    CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>

And the changes made to http.conf

DocumentRoot "/Users/username/Google Drive/htdocs"
<Directory "/Users/username/Google Drive/htdocs">

..

# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User username

UPDATE:

I've tried to make some changes to my wp-config.php file accordingly to some threads on this problem.

/** MySQL database username */
define('DB_USER', ''); 

/** MySQL hostname */
define('DB_HOST', '127.0.0.1'); 

Changes - Removed root from DB_USER - Tried changing DB_HOST to both Localhost (notice capital L) and 127.0.0.1. This makes the wp-config-file compatible with PC but just wanted to troubleshoot.

Localhost throws parse error and 127.0.0.1 results in "Error establishing a database connection"

Community
  • 1
  • 1
user3789629
  • 357
  • 1
  • 5
  • 17
  • This would probably be a question better suited for [ServerFault](http://serverfault.com/). – Jon Jan 05 '16 at 17:00
  • I would start by checking wp-config.php if the values for the DB connection are correctly set up. – eselskas Jan 05 '16 at 17:11
  • Thanks @EdvinasSelskas I've tried to make som changes to the wp-config.php file (see update) accordingly to some threads on this issue. still no success. Still unsure whether its possible to collaborate PC + MAC on same htdocs folder or not... – user3789629 Jan 06 '16 at 12:14

3 Answers3

0

try accessing http://localhost/phpmyadmin and checking the credentials. Usually user is root and no password by default. Also, don't forget to create a database for wordpress if you haven't done so already. So your wp-config.php should contain something like this:

define('DB_NAME', 'wordpress');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
eselskas
  • 808
  • 8
  • 17
  • Yep, works (from mac&pc) and confirms that no password is set! Just to clarify, wordpress works fine on my PC. I can access both localhost and my wordpress site and make changes to it without any problems. If I had two PC:s I guess I'd just copy the httpd-conf file and run Xampp the same way. However, changing the default htdocs location are different on MAC and PC – user3789629 Jan 06 '16 at 20:00
0

Architecturally, Google Drive was not designed for what you are trying to do. You may hack something together and get it working, but there are much better solutions.

  • VVV is a good solution for creating a local development server. It builds a box you control via the command line and can access through a browser anywhere on your LAN. You can a git based deployment strategy and have this box wherever you need it.
  • An even better solution is using Trellis, part of the Roots.io ecosystem. It uses Ansible to provision a ready-to-go vagrant instance and you can even deploy the entire server onto a bare-metal instance (like AWS or Digital Ocean). I have used this with great success, but you have to get more into the dev ops.
  • For cross-browser testing, I would recommend using browsersync as part of a gulp build process. You'd run gulp serve locally and, if you have browsersync as part of your build script, it will watch your codebase, automatically make updates for you in the browser and allow you to remotely access your local dev box for cross-browser testing.
serraosays
  • 7,163
  • 3
  • 35
  • 60
  • thanks for the tips but I'm not looking for any super smooth solution on this. I have built a wordpress site on my PC laptop which saves all changes to my Google Drive folder, which I now also want to work with at home. If I had two PCs I guess I'd just mirror the Xampp settings on my stationary PC. However, changing the default htdocs location are somewhat different on Mac vs. PC – user3789629 Jan 06 '16 at 20:04
  • If that's the use case, you should still go with Vagrant and store the instance in the cloud. That way you can check out a full server on each machine, keeping the instance identical. There is just too much variation between local dev setups not to have something fall out of sync at some point and cause problems. – serraosays Jan 06 '16 at 21:44
  • Alright I've tried this now. Message still appears though. I Guess that there must be something wrong with my wp-config file for my Mac setup. DB_HOST set to both Localhost, localhost and 127.0.0.1. no success. Gah, so frustrating! – user3789629 Jan 07 '16 at 17:37
  • I dont think you can link to a dynamic data store like google drive with a static IP. Their custom server will do dynamic routing and rotate the IPs. If you use a vagrant instance, you just upload the whole instance to gdrive and run it on whatever machine - it will solve this problem. – serraosays Jan 07 '16 at 20:10
  • These stand-alone dev environments that use Vagrant are OS-independent, thats the beauty of it. You just get vagrant on your machine, then you run the VVV or Trellis image and it's a fully-optimized dev environment on your computer that is 100% portable. – serraosays Jan 08 '16 at 18:06
0

Alright, solution to this is far from revolutionary. Of course its not only the htdocs-folder that has to be synced between the PC and MAC but also the MySQL data folder.

Exporting the database from phpmyadmin on the PC and importing it into my Xampp setup on Mac solve this problem with "Error establishing a database connection" message.

user3789629
  • 357
  • 1
  • 5
  • 17