Cacti on pgsql in Laravel - php

Description
I have a laravel app, that I am trying to integrate that with Cacti : is a complete network graphing solution designed to harness the power of RRDTool's data storage and graphing functionality.
Steps
I've downloaded it, and place it in my public/ directory.
Now, when I go to my http://localhost:8888/cacti/
I got
First Try
FATAL: Cannot connect to MySQL server on 'localhost'. Please make sure you have specified a valid MySQL database name in 'include/config.php'
Then, I opened up 'include/config.php'. Since my goal is to try to connect it to pgsql instead of mysql, so I here is my current settings
$database_type = "pgsql";
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'postgres';
$database_password = '';
$database_port = '5432';
$database_ssl = false;
As soon as I hit saved, and refresh the page http://localhost:8888/cacti/
Second Try
Now, I got : The localhost page isn’t working :(
Database
I've already created a cacti database on my localhost running on port 5432.

As given in this site, cacti is designed to work with only MySQL.
Cacti is written in PHP and supports MySQL only for storing the
RRDTool data.
Though, there is this link to setup the cacti with pgsql .
PostgreSQL Host Template

Related

Hard time to connect to my database with php

I am trying to build a homne server for studies on a raspberry pi 3.
I am just trying to connect to my raspberry database and php base to use my database on a HTML page.
I tried everything 9not apparently), to change several times my login, i tried with 'root' and create an other user and give all privileges etc, but nothing seem to work. I have all installed, php work just fine, i can reach my server with a domain name hosted by noip. the html and php content pop just fine.
I can even connect to my database via ssh.
But since few month i tried to make it work and i am desesperate, so if someone can help me ...
<?php
$db = mysqli_connect("mywebsite","root","myLogin","mydbName")
or die(mysqli_error($db));
?>
so i would just be able to make request on my database, i am just blocked on that step
$con=new mysqli("localhost","root","root_password","database_name");
Generally, root has no password so the connection should be like this
$con=new mysqli("localhost","root","","database_name");

php & mysql setup on Linux

I am learning Linux, MySQL (setup) and php, all in one go. Slowly getting the hang of it but I am trying to build the structure for my site and I can't seem to get the connection to my database which I have moved to /var/www/html/site_01/_database/ and the page that is trying to connect to is located at /var/www/html/site_01/_html/ I have been on W3Schools and quite a few other sites giving tutorials on php and everywhere states $servername = "localhost"; but I am still unsure if I need to edit the config files of php or MySQL to have the dir of my database added?
Thanks in advance!
I see that you are probably mistaking URL/URI with phisical path.
You do not need to have your database in any particular directory. As long as its up and running on the same machine as your application server (e.g.:MAMP,XAMP,pure apache,etc) you will be on localhost.
All you need to do is connect to your database on your PHP algorithms, with the correct driver for your DBSM on your project and imported.
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
with the correct mysql_user and mysql_password

Cannot add records on php sqlite in a Linux server

I tested a simple Php program using Sqlite3 instead of mySQL on my own computer and it works fine. What the program does is simple insert of record into a certain table. Now, when I try to do that on a remote web server running on Linux (CentOS) with Sqlite3 enabled it does not work.
I thought at first it was simply a file permission issue since my Sqlite file had an initial permissions of 644 so I changed it to 646 then 767 both to no avail.
The Php version by the way on web server is a little bit dated, namely, Php 5.1.6 but on my local PC it is 5.5.11.
This is the sample code that I ran on both servers.
$db = new PDO('sqlite:test.db');
$lastname = "Doe";
$firstname = "John";
$sql = "INSERT INTO people (Lastname,Firstname) VALUES (:lastname,:firstname)";
$q = $db->prepare($sql);
$q->execute(array(':lastname'=>$lastname,
':firstname'=>$firstname));
I tried a simple query on a sqlite3 database on the webserver by the way and it works.
So, could this be a simple Php version issue?
I cannot by the way change the php.ini so forgo that possible direction for the moment. And I don't have any choice of having a new Php version on that server since I use it for free.

PHP ODBC Extension - Data Source Name Too Long

I've been trying to install the ODBC extension for PHP onto one of our servers (Redhat), and i think it got it installed correctly but now when i try to test the connection i get the error message about the data source name being too long... It sounds like a simple thing to fix, but i can't work out..how..or where.
Basically these are the settings i've got at the moment:
# odbcinst -j
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN SIze.......: 4
SQLSETPOSIROW......: 2
I've got my MySQL driver defined in the odbcinst.ini as such:
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/libmyodbc5.so
Setup = /usr/lib/libodbcmyS.so
FileUsage = 1
I've double checked and the Driver & Setup paths are correct and pointing to the correct files.
So now I'm trying to add a System Data Source by editing the odbc.ini file. I've tried it in various different formats, following examples from different sites, e.g.
http://developer.mindtouch.com/en/kb/Using_the_ODBC_extension_on_Linux#Install_unixODBC
http://dev.mysql.com/doc/refman/5.0/en/connector-odbc-configuration-dsn-unix.html
As you can see i've commented some of them out and tried different ones:
;[mytest]
;driver = MySQL
;Database = moodle
;Server = localhost
;Socket = /var/lib/mysql/mysql.sock
;[mynew]
;Description = MySQL
;Driver = MySQL
;SERVER = localhost
;USER = root
;PASSWORD =
;PORT = 3306
;DATABASE = moodle
[Default]
Driver = /usr/lib/libmyodbc5.so
Description = Connector/ODBC 5 Driver DSN
SERVER = localhost
PORT =
USER = root
Password =
Database = moodle
SOCKET =
However, whenever i run
isql -v
to see if there are any problems, i always get:
[IM010][unixODBC][Driver Manager]Data source name too long
[ISQL]ERROR: Could not SQLConnect
My googling around the error only ever seems to turn up results for people having a connection string within something like ASP, nothing about how to get it working on the server in this way...
Could anyone offer me any advice/help?
If you need more information, let me know.
Thank you!
When launching isql you have to specify the data source name as defined in the man page.
SYNOPSIS
isql DSN [UID [PWD]] [options]
OPTIONS
DSN Name of the data source you want to connect to.
Given your configuration in /etc/odbc.ini, you would launch isql -v Default to test your connection. In the configuration file, the data source name is the one you've defined between brackets.

Connecting to MySQL with PHP

I have MySQL running such that I can open a client command line and log on and make databases, tables, etc.
I wanted to do some AJAX. Doing AJAX with ASP, SQL Server, etc is not advisable since both places where I am hosting my websites do not use the Microsoft products. So I am forced to do my development with PHP and MySQL.
I just about have everything set up. I have set up IIS so that I can go to my localhost and I can test out web pages. I have PHP installed so that I can pull up the PHP setting pages.
The problem occurs when I try to bring up the MySQL database in PHP. I use this very simple PHP command:
<?php
$con = mysql_connect('localhost', 'testuser', 'testpassword');
?>
When I try to connect to the mysql database through PHP, I get this error:
Click here
I figure the problem must be in the settings that are in the php.ini. But it seems that my php.ini is set up for MySQL although it is not mentioned in the output when I query the phpinfo page with this code
Here is the result from this:
Click here
It looks that your php is missing mysql module
in php.ini make sure that you have correct extensions path eg.:
extension_dir = "C:\php\ext"
and make sure you have commented out:
extension=php_mysql.dll
extension=php_mysqli.dll
Which version of PHP are you running and are you sure you have MySQL installed and running on localhost with a username of "testuser" and a password of "testpassword" (and have you reloaded the privilege tables after creating those users)?
Have you got IIS configured to log errors into a file - does that provide any more information?
Create a new PHP file that contains the following:
<?php
phpinfo();
?>
This will helpy you to discover if MySQL has been compiled in properly etc. Can you access the MySQL server from the command line; using something similar to:
mysql -u testuser -ptestpassword testdatabase
If you get a prompt from MySQL, the service is running and we can better help from there.
Hope that helps a little!
Are you selecting the database? After your connect statement, you need to use:
mysql_select_db($databaseName, $conn);
Documentation here: http://php.net/mysql_select_db
What I would do is to download the complete package in one go (Server, MySQL and PHP). There are tons of good resources like WAMP or MAMP (for MAC users). Once you download the package the installation is just easy and you don't have to set anything as it does it automatically.
They also have phpMyAdmin where you can manage your database and its users and privileges.
Once you got your server running you can test that code that seems fine for me. Try running something like this:
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected';
mysql_close($link);
?>
Cheers

Categories