localhost/joomla = Showing only Error not Work - joomla

I am facing the issue of localhost/joomla is not showing login page, just show word Error
I have attached permission details and other corresponding files. Please help me to solve this issue.
Thankyou for your time.

Seems like the database the site it's not connected.
Check your configuration.php (in the root of the site) for this parameters:
public $dbtype = 'mysqli'; // Driver you are using to connect to the MySQL database.
public $host = 'localhost'; // The host for the database. If it's in the same server, it's ok like this.
public $user = 'root'; // Username for the database
public $password = 'root'; // Password of the database
public $db = 'NAME_OF_THE_DATABASE'; // Name of the database.

Related

Joomla 3 test site vs. production site: which files should change?

I am maintaining a Joomla 3 site, and I want to set up a test site in a different web host, so that we can test code changes in it first. The test web host is in a different server, uses a different DB, etc., but otherwise I want it to be as identical as possible to the production site.
Which files should I pay attention to, when downloading and uploading the site to the other host? I know about configuration.php. Is there anything else?
(All the docs I've found when searching were about older versions of Joomla: 1.5, 2.x...)
Here is another solution which does not involve any third party component. You need to take care of some points though. Steps are explained below.
Copy the entire files from 1st server to 2nd server.
From phpmyadmin copy the database from 1st to 2nd server.
Change the database details and other configuration details in the configuration.php file. Mainly you need to change the database details and the log and tmp path. Check the log and tmp folders are writable.
<?php
class JConfig {
public $db = 'joomla';
public $dbprefix = 's5oiy_';
public $log_path = 'C:/xampp/htdocs/joomla/administrator/logs';
public $memcache_server_host = 'localhost';
public $memcache_server_port = '11211';
public $password = 'dbpass';
public $sendmail = '/usr/sbin/sendmail';
public $smtpauth = '0';
public $smtphost = 'localhost';
public $smtppass = '';
public $smtpport = '25';
public $smtpsecure = 'none';
public $smtpuser = '';
public $tmp_path = 'C:/xampp/htdocs/joomla/tmp';
public $user = 'root';
public $memcached_server_host = 'localhost';
public $memcached_server_port = '11211';
public $redis_server_host = 'localhost';
public $redis_server_port = '6379';
public $redis_server_auth = '';
public $redis_server_db = '0';
public $proxy_enable = '0';
public $proxy_host = '';
public $proxy_port = '';
public $proxy_user = '';
public $proxy_pass = '';
public $session_memcache_server_host = 'localhost';
public $session_memcache_server_port = '11211';
public $session_memcached_server_host = 'localhost';
public $session_memcached_server_port = '11211';
}
?>
These are the variables in configuration.php file that need to be checked once you change the server.
If you dont know the Base directory path you may give wrong log and tmp path. So to know the directory path you can use this code
<?php
$dir = getcwd();
echo $dir;
?>
For things like this I suggest using Akeeba Backup and Kickstart
https://www.akeebabackup.com/products/akeeba-backup.html
https://www.akeebabackup.com/products/akeeba-kickstart.html
Just create a backup of your site and use Kickstart to install it on your test server. The install process will take care of the different settings. Make sure you disable sending mails from the test system. Otherwise your users might get mails the should not get.
Sven's suggestion is great, here are a couple of other options.
There might be some advantages to creating your test site on the same server as your production site, for one thing, you'll know that the server environment will be the same. Here are 2 ways you could do this.
You could create a new 'test' subdirectory on your production site and use Akeeba backup to install a copy of your site in that location. If you do this, take care to create a second test database and specify this new database when you use Akeeba backup. When you are finished your production site will be at www.domain.com and your test site will be at www.domain.com/test/
Alternatively StageIt is a very good commercial plugin which will setup a staging environment on your production server. You can test your ideas and sync them back from the test to the production site when you are finished.
Good luck!

select the right database according to input login field

I have 3 login fields (name, pass, company id). Now when user clicks "Log me in" button CI should select and work with database according to company id (and check user in this database and when he is logged in, work with this database over whole session /each company has its own database/).
How can I do this?
I found this but it looks like it is not the right solution.
Many thanks
CodeIgniter: Connection to your Database
Maybe the link above will help you out.
You have to set a new db connection for the specific company. In CodeIgniter it is really simple.
Combine it with THIS PROBLEM to get access to the database settings setted in the database-config.
Example:
<?php
$config = array();
$config['hostname'] = $this->db->hostname;
$config['username'] = $this->db->username;
$config['password'] = $this->db->password;
$config['database'] = 'companydb';
$config['dbdriver'] = $this->db->dbdriver;
$companydb = $this->load->database($config);
$companydb->query('SELECT ... FROM ... WHERE ...');
?>

Ion Auth (Codeigniter) - How to use different database

Is it possible to use different database for authenticating user through Ion Auth?
I would like to create a database dedicated only for user authentication. So, it should be separated from transactional database.
How to do that?
Thank you.
In short...yes it is possible for you to use a different database for your authentication. You would need to create a second database configuration in your application/config/database.php file (similar to the below) in addition to your default config.
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "";
$db['default']['database'] = "db_name";
$db['default']['dbdriver'] = "mysql";
$db['authentication']['hostname'] = "localhost";
$db['authentication']['username'] = "root";
$db['authentication']['password'] = "";
$db['authentication']['database'] = "auth_db_name";
$db['authentication']['dbdriver'] = "mysql";
For further reference see - http://ellislab.com/codeigniter/user-guide/database/configuration.html
You would then have to modify your ion_auth model to use this second db configuration, which you would set when loading the database.
$auth_db = $this->load->database('authentication', TRUE);
Then change all database queries in the model replacing $this->db with $auth_db.
So, $this->db->select('password, salt') would become $auth_db->select('password, salt').
For further reference see - http://ellislab.com/codeigniter/user-guide/database/connecting.html
Hope that helps!
The simplest way would be to expand on what MY_Mark said.
Create the new DB config
$db['authentication']['hostname'] = "localhost";
$db['authentication']['username'] = "root";
$db['authentication']['password'] = "";
$db['authentication']['database'] = "auth_db_name";
$db['authentication']['dbdriver'] = "mysql";
Then in the constructor of the ion_auth_model.php do this:
$this->db = $this->load->database('authentication', TRUE);
And it should just work after that.

How we can give permission to a user to create database in phpmyadmin(cPanel)?

I have a database and a user which is created through cpanel(i have added that user to that database and i am able to access that database using that user and its password. i have given all privileges to that user through cPanel(by clicking on the username in 'current database' table in cpanel and clicking on all privileges check box ).
In my application(which is created using PHP- Codeigniter framework) i want to create new database and tables in that database as per users requirement. For that i am using Codeigniter dbforge class for creating database and the tables in that.
$this->load->dbforge();
if ($this->dbforge->create_database($database_name)){
$config['hostname'] = "localhost";
$config['username'] = "user_name";
$config['password'] = "users_password";
$config['database'] = $database_name;
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = TRUE;
$config['db_debug'] = TRUE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";
$config['swap_pre'] = '';
$config['autoinit'] = TRUE;
$config['stricton'] = FALSE;
$db_new=$this->load->database($config,TRUE);
$this->db=$db_new;
$this->load->dbforge();
$fields=array(
'id'=>array('type'=>'INT','auto_increment'=>TRUE,'constraint'=>'5'),
'first_name'=>array('type'=>'VARCHAR','constraint'=>'60'),
'last_name'=>array('type'=>'VARCHAR','constraint'=>'60','null' => TRUE),
);
$this->dbforge->add_field($fields);
$this->dbforge->add_key('id',TRUE);
$this->dbforge->create_table('clients');
}
In the above code i am creating a database first and then loading that database as the current database . This code works perfectly in local host WAMP server but when i uploaded it to the server and then tried to create the database it gives the following Error
Error No 1044: Access denied for user 'username'#'localhost' to database 'database_name'
The line of code which caused thr error is
if ($this->dbforge->create_database($database_name)){
*In that database config setting shown in the above code the 'username' and 'password' is given as the username and password of the already existing database(which is created through cPanel) . Is that the problem...?* .
the current user using which we are trying to create new database is having all the avilable privileges. but in that 'CREATE DATABASE ' privilege is not there.
For database naming I have used the ' prefix_ ' in the database name(CPanel database naming format)
How can i create the database using dbforge class and access to that database using a existing user ...?
Try Create a Super User first
mysql > GRANT ALL PRIVILEGES on databasename.* TO "username"#"localhost" IDENTIFIED BY "password";

Codeigniter Database - Automatic Selection

I have a multi-tenancy application that I am developing and I'm nearly there.
Currently I am using one database per customer - copying it each time and naming depending based on $_SERVER['http_host']...
A lot of the tables each database never change, and contain the same information.
I would like to have a main application database that contains this information, including a list of clients and what there database is called. This database would then be used to select the correct customers database...
Is this possible and can anyone point me in the direction of a suitable tutorial?
Thanks
OK, so you'll need different database configs for your "administrative" database and your "customer" databases.
Use the examples from this page to generate those separate configs:
http://ellislab.com/codeigniter/user_guide/database/configuration.html
Then, in your main controller (please tell me your extending a MY_Controller.php and not just using CI_Controller.php), you'll want to read your 'admin' database and get all client information. You'll then want to generate a $config array for this client database and reload the database with the new $config array:
// in MY_Controller constructor
// do your thing here to connect to the admin database and get client details
// ...
//
$config['hostname'] = "localhost";
$config['username'] = $client_db_username; // you got this from the 'admin' database
$config['password'] = $client_db_password; // you got this from the 'admin' database
$config['database'] = $client_db_name; // you got this from the 'admin' database
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";
$this->load->database($config);
You'll then have a connection to the client database.
Note
If you'll need to connect to both databases back and forth, then you can connect to multiple databases as explained on this page: http://ellislab.com/codeigniter/user_guide/database/connecting.html

Resources