I've been attempting to set up a version of my website on my computer so that I stop making live updates on my website. The website runs on a PHP based CMS.
I posted a question earlier: mysql connect - Moving my website to a local host
The question was about mysql-connect - the outcome was that I connected my database to my localhost as opposed to the current live host.
Now, the local version of my site loads except all styling is gone and the nav links do not work. I suspect the answer may be to do with the same file I edited in the question above: application/config/database.php
Here is what the code looked like originally:
$config['default'] = array(
'benchmark' => TRUE,
'persistent' => FALSE,
'connection' => array(
'type' => 'mysql',
'user' => 'mywebsite',
'pass' => 'somestringoftext',
'host' => 'mywebsitecom.fatcowmysql.com',
'port' => FALSE,
'socket' => FALSE,
'database' => 'mywebsiteDB4',
Then I changed it to this:
$config['default'] = array(
'benchmark' => TRUE,
'persistent' => FALSE,
'connection' => array(
'type' => 'mysql',
'user' => 'root',
'pass' => '',// Since it's on local host there is no password right now
'host' => 'localhost',
'port' => FALSE,
'socket' => FALSE,
'database' => 'mywebsite',//this is what I called the DB I created and imported to in PHPmyadmin
It may be that this all looks correct and the issue lies elsewhere. I have a suspicion that it could be to do with the .htaccess file as, when I initially set up the site, I had issues with that, except all I had to do was set permissions. Thing is, the way the local version appears right now is very similar to how it looked when the .htaccess file was not "working".
I realize that I've just dropped a bunch of code and said "help"! I'm really stuck on where to look next. If anyone does have any ideas I'd be grateful to hear them. If any further info could help anyone with suspect ideas please let me know and I'l update.
If site loads and you can see at page data taken from database, it means, what you DB connection is OK.
Since you can't see styling and menu not works, it means what you .JS/.CSS files not loaded correctly from you local server.
You can use addon FireFox called FireBug and here "Net" tab, to see which files loaded correctly and which not. For not loaded files you will need or change path to include it in you HTML file or change files location in you local filesystem
Related
So, I have tried 4 different ways of doing this, none of them worked.
There's a 3rd party server that I can create and delete files on via Filezilla. This was for testing purposes however.
There's a script on my Laravel application that'll run once a day, create a few XML files and those need to automagically transfer to that same server.
When I create an ftp filesystem I get the error "ftp_rawlist(): php_connect_nonb() failed: Operation now in progress (115)" after a timeout.
When I try PHP's ftp_put or ftp_fput I get the error "ftp_put(): php_connect_nonb() failed: Operation now in progress (115)" (or ftp_fput, same error).
When I try PHP's fwrite with the ftp as a destination I get the error "failed to open stream: operation failed". This also fails in the browser.
I have made sure credentials are correct. I've copy/pasted them from the working Filezilla connection details.
Filesystem code:
'ftp' => [
'driver' => 'ftp',
'host' => env('FTP_HOST'),
'username' => env('FTP_USERNAME'),
'password' => env('FTP_PASSWORD'),
'root' => '/Production',
'ssl' => true,
'ignorePassiveAddress' => true,
],
I know about the server behind NAT problem, but it won't accept my changes to use original address in filesystems. I've cleared cache, and config and fed the hamsters, but nothing changes.
I'm honestly at the end of my knowledge right now. And asking the 3rd party to change their configuration/settings isn't an option. This server is one of many and they're all exactly the same, but different clients. They might help me by providing the logs on their end, but that's about it.
The only other that I see which could be a difference is that I'm running this code from command line (ie, as if it's run via cron). Not sure if that causes problems with connecting and creating files on a remote server. I'm not that experienced with writing Laravel commands.
Any help would be greatly appreciated.
Ok.
Ok. Inside the configuration file like this:
'ftp' => [
'driver' => 'ftp',
'host' => 'ftp.example.com',
'username' => 'your-username',
'password' => 'your-password',
'passive' => 'false',
'ignorePassiveAddress' => true,
'port' => 21,
]
add file 'test.pdf' inside the ftp
simply run
$contents = \Storage::disk('ftp')->exists('test.pdf');
dd( $contents );
and it works.
I'm trying to create a file upload where admin would upload file from admin application to another application for regular users (they are on different domains).
I got it working with FTP filesystem but I would like to test it on localhost, before I fully deploy it.
I made a config entry in filesystem.php:
'ftp' => [
'driver' => 'ftp',
'host' => env('FTP_HOST'),
'username' => env('FTP_USERNAME'),
'password' => env('FTP_PASSWORD'),
'root' => '',
'port' => 21,
'timeout' => 30,
'ssl' => true,
]
And on my test function in admin_app I do this:
Storage::disk('ftp')->put('/public_app/storage/test3.png', $file);
I have to separate laravel applications: admin_app and public_app. How could I test the same thing on localhost? Another config entry point or do I need to download FTP for localhost?
What about using something like remote server that contain your assets?
For example use S3 and upload all your files there and access it from your second app or any other app.
Check this Article
I have installed cakephp 2.7.5 on xampp but when I run my application I get an error message >CakePHP is NOT able to connect to the database.
Database connection "Mysql" is missing, or could not be created.< I suspect that my mysql server is not properly configured and I have particular concerns over the PDO and pdo_mysql settings in the php.ini file. How do I enable them? (I am totally lost here)Thanks in advance.
You don't mention configuring the connection, so your problem is most probably that of a missing initial database configuration.
You will obviously need to create a database (and maybe a user with sufficient permissions in that DB) before you setup the configuration. Don't mess with PDO configuration in php.ini, it should run out of the box with XAMPP.
Rename file name from database.php.default to database.php .Create a database in mysql. Open the file and change your mysql login,password and database from default variable.Then run your application.
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'user',
'password' => 'password',
'database' => 'database_name',
'prefix' => '',
//'encoding' => 'utf8',
);
they are all configured identically.
the environment is definitely set to production.
the database credentials do not get read at all - it wants to use ''#localhost password: NO as the default.
i set
'mysql' => array(
'driver' => 'mysql',
'host' => getenv('DB_HOST'),
'database' => getenv('DB_NAME'),
'username' => getenv('DB_USERNAME'),
'password' => getenv('DB_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
in all 4 of the sites app/config/database.php, and i set the related environment variables in forge. i have tried leaving the environment field blank, and also typing in 'production'. i also tried using $_ENV['environmentvariable'] in database.php.
this gives me a different error of Undefined Index DB_HOST. so clearly the env vars aren't getting read.
i've taken everything down and re-created the repo and the laravel server many times. all 3 other sites are configured identically. it detects the environment in bootstrap/start with
$env = $app->detectEnvironment(function()
{
return getenv('ENV') ?: 'development';
});
i appreciate any help guys. it works fine on homestead btw.
edit: i can ssh into forge and do whatever i want in any of the sites or databases as well, except in the problem one any php artisan command fails with the 'Access Denied for ''#localhost password: NO', even if i run it with --env="production".
I am not entirely sure if you are using .env files at root to specify different environment vars, but after going through this myself I realized that while when environment is 'local' it reads '.env.local.php', when environment is 'production', it wants '.env.php'.
It's in the docs, but I forget almost every time. I'm hoping that typing this out will help. :)
I have scoured the web for an answer but as of now have been unsuccessful. I am attempting to connect CakePHP to a database. But I keep getting the same response:
CakePHP is NOT able to connect to the database.
Database connection "Mysql" is missing, or could not be created.
Here is part of my database.php file
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'cake',
'prefix' => '',
//'encoding' => 'utf8',
);
^I've also tried different host/login combinations based from the access privileges list in phpmyadmin.
I think one problem might be that Wampserver is finding the wrong php.ini file. It seems that it is loading the file at: "C:\Program Files (x86)\PHP\php.ini" instead of something under "C:\wamp...". How would I set it to point at the right file??
However, I had added the line "extension=php_pdo_mysql.dll" to both files and still no luck. Any help would be appreciated.
I had the exact same issue. There was no problem in the mysql database as it was accessible through phpMyadmin and other applications running on the server. The issue was caused due to the mysql port not mentioned alongwith the host. Append the port with the host like... 'host' => 'localhost:3307'.
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost:3307',
'login' => 'root',
'password' => 'mypass',
'database' => 'cake_todos',
'prefix' => '',
//'encoding' => 'utf8',
);
Now, how to know the mysql port? For that you need to go to the server configuration file.. e.g. the in my case it was the properties.ini file in the home directory of the wamp folder. Open the file and you will most probably find an entry like this:
mysql_port=3307
mysql_host=127.0.0.1
So, here it is, the mysql_port. Hope it helps.
First check there is database called cake in your localhost/phpmyadmin, and if that mysql use the username root and no password and also make sure you set php_mysql on the right php.ini file (extension=php_mysql.dll).
Second, if you think the problem is because of php.ini file location, you can set it:
go to your wamp folder (C:\wamp) and
under that folder you'll find wampmanager.ini file and
Find php.ini word in that file you'll get this kind of line
(Type: item; Caption: "php.ini"; Glyph: 6; Action: run; FileName: "notepad.exe"; parameters: "...path here...")and locate the path and set "C:/wamp/bin/apache/apache2.2.21/bin/php.ini"
please tell me (vote) if it works. I hope it helps.
Thanks