I use server ubuntu 11.04 install apache2 . I have problem when connect to database. this is my error :
CDbConnection failed to open the DB connection: could not find driver
this is mycode connect to database :
'db'=>array(
'connectionString' => 'mysql:host=localhost;port=3306;dbname=server$
'emulatePrepare' => true,
'username' => 'root',
'password' => '*****',
'charset' => 'utf8',
),
Please help me, thank all so much
Run in console
sudo apt-get install php5-mysql
sudo service apache2 restart
or for native mysql driver
sudo apt-get install php5-mysqlnd
sudo service apache2 restart
Related
I got this error. Any idea?
Thank you.
Error:
PHP Fatal error: Uncaught Error: Undefined constant "CURLOPT_TCP_FASTOPEN"
OS:
CentOs 7.x
Version:
3.10.0-1160.76.1.el7.x86_64
$curl --tcp-fastopen -O http://google.com
curl: option --tcp-fastopen: is unknown
curl: try 'curl --help' or 'curl --manual' for more information
$ php -v
PHP 8.1.12 (cli) (built: Oct 25 2022 17:30:00) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.12, Copyright (c) Zend Technologies
$cat /proc/sys/net/ipv4/tcp_fastopen
3
PHP has been installed using:
sudo yum-config-manager --disable 'remi-php*'
sudo yum-config-manager --enable remi-php81
sudo yum repolist
sudo yum -y install php php-{cli,mbstring,curl,json}
php.ini
cURL support => enabled
cURL Information => 7.29.0
Age => 3
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => Yes
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => No
SSL => Yes
SSPI => No
TLS-SRP => No
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp
Host => x86_64-redhat-linux-gnu
SSL Version => NSS/3.53.1
ZLib Version => 1.2.7
libSSH Version => libssh2/1.8.0
You are using CentOS 7 which is more than 8 years old, and is close to its end of life (in June 2024).
I heartily recommend to use a more recent distribution version (8 or 9), especially for modern features.
CURLOPT_TCP_FASTOPEN was introduced in curl 7.49
EL-7 have 7.19
EL-8 have 7.61
EL-9 have 7.76
So you cannot fix this error in EL-7 without rebuilding nearly everything.
CURLOPT_TCP_FASTOPEN requires libcurl 7.49.0 or newer, while your PHP is compiled against libcurl 7.29.0. upgrade your libcurl and compile php again.
maybe try
git clone -b 'OpenSSL_1_1_1k' --single-branch --depth 1 https://github.com/openssl/openssl
cd openssl
./config
make -j $(nproc)
mkdir lib
cp *.a lib;
cd ..
git clone -b 'curl-7_76_1' --single-branch --depth 1 https://github.com/curl/curl.git
cd curl
./buildconf
LDFLAGS="-static" ./configure --with-ssl=$(realpath ../openssl) --enable-static
make -j $(nproc)
cd ..
git clone -b 'PHP-8.1' --single-branch --depth 1 'https://github.com/php/php-src.git'
cd php-src;
./buildconf;
./configure --with-curl=$(realpath ../curl)
make -j $(nproc)
I' trying to install apache2 and php in a Vagrant box (Ubuntu 14.04) using Chef Solo. This is my recipe:
include_recipe "apache2"
include_recipe "apache2::mod_rewrite"
include_recipe "apache2::mod_ssl"
include_recipe "apache2::mod_php5"
### some changes due to php5 reqs. ###
#-------------------------------------
apache_module "mpm_event" do
enable false
end
apache_module "mpm_prefork" do
enable true
end
service "apache2" do
action :restart
end
This because apache2 is installed with mpm_event by default, and I need to change it because of php.
For some reasons, this not always works (sometimes, apache2 won't restart due to mpm_event still enabled), so I'm searching a more idiomatic and chef-safe way to install apache2 directly with prefork module rather than event.
Is there a way to do so?
It is possible to set mpm in vagrant file
config.vm.provision "chef_solo" do |chef|
chef.json = {
"apache" => {
"mpm" => "prefork"
}
}
end
I've been running into issues when trying to run the rvm::user recipe from fnichol/chef-rvm. I'm using chef along with a Vagrant box. rvm installs fine, but every time chef tries to install a ruby, it fails with this error:
WARN: Failed to install rvm_ruby[ruby-1.9.3-p448]. Check logs in /log/ruby-1.9.3-p448
Here's my Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = 'precise32'
config.vm.box_url = 'http://files.vagrantup.com/precise32.box'
config.vm.provision "chef_solo" do |chef|
chef.add_recipe "rvm::vagrant"
chef.add_recipe "rvm::user"
chef.json = {
:rvm => {
:user_installs => [
{
:user => "vagrant",
:default_ruby => "1.9.3",
:rubies => ["1.9.3"],
:global_gems => [
{ :name => 'bundler' }
],
}
]
}
end
end
Environment Details:
Vagrant version: 1.2.7
Vagrant vm: precise32
rvm version: 1.22.11
chef-rvm ref: 59dc482
It turns out that Vagrant was running chef in a non-interactive/non-tty session. The sudo command doesn't like to run in non-interactive sessions, and causes rvm to fail when it tries install dependencies (via apt-get in ubuntu).
You can allow sudo to run non-interactively by adding this to /etc/sudoers:
vagrant ALL= (ALL:ALL) NOPASSWD: ALL
Once I added this, chef installed the rvm::user recipe successfully.
My setup was much more complicated, however the error was the same. Ultimately i found that adding the apt chef recipe fixed everything.
chef.add_recipe "apt"
chef.add_recipe "rvm::vagrant"
chef.add_recipe "rvm::user"
> Run List is [recipe[apt], recipe[curl], recipe[rvm::vagrant], recipe[rvm::user]]
Adding the line
vagrant ALL=(ALL:ALL) NOPASSWD: ALL
didn't work for my scenario.
I believe the apt chef recipe runs apt update which fixes an issue with old and ill matched versions.
The error messages i received were
Error executing action `install` on resource 'package[libxml2-dev]'
apt-get -q -y install libxml2-dev=2.7.8.dfsg-5.1ubuntu4.1 returned 100, expected 0
....
Error executing action `install` on resource 'rvm_ruby[2.1.1]'
I've setup a simple Vagrant box with puppet provisioner.
With puppet I've installed rvm:
exec { 'install_rvm':
command => "${as_vagrant} 'curl -L https://get.rvm.io | bash -s stable'",
creates => "${home}/.rvm",
require => Package['curl']
}
and ruby:
exec { 'install_ruby':
command => "${as_vagrant} '${home}/.rvm/bin/rvm install 2.0.0 --latest-binary --autolibs=enabled && rvm --fuzzy alias create default 2.0.0'",
creates => "${home}/.rvm/bin/ruby",
require => Exec['install_rvm']
}
I'm trying to install a gem that would be available on the default ruby version of rvm (in this case 2.0.0)
If I try the puppet documented code it doen's work (I suppose it instals the gem on the system ruby):
package { 'sinatra':
ensure => 'installed',
provider => 'gem',
}
Current workaround: If I execute a command as a vagrant user it works, but it doesn't look nice:
$as_vagrant = 'sudo -u vagrant -H bash -l -c'
exec { "${as_vagrant} 'sudo -u vagrant -H bash -l -c gem install stasis'":
require => Exec['install_ruby']
}
Any ideas?
Thank you.
You could use this rvm module from puppet forge. Check the Vagrant documentation about puppet to know how to use puppet modules with vagrant.
I am trying to deploy an app with Mongrel2-rack-rails3 stack. I am using khi-rack-mongrel2 handler for ruby rack. The problem is that even if I setup everything for local development, I can't make rails server daemonize itself by running it with -d option. While starting without daemonization option I get following output:
% rails s Mongrel2
=> Booting Mongrel2
=> Rails 3.0.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
The handler starts and I can make requests to my rails app. However If I start my server with -d option I get this:
% rails s Mongrel2 -d
=> Booting Mongrel2
=> Rails 3.0.9 application starting in development on http://0.0.0.0:3000
The handler starts, but does not daemonize itself. Can someone point me out to the issue at hand?
Here are the contents of my config.ru file:
require ::File.expand_path('../config/environment', __FILE__)
Rack::Handler::Mongrel2.run(MyProject::Application,
:recv => 'tcp://127.0.0.1:2050',
:send => 'tcp://127.0.0.1:2051',
:uuid => 'my_project'
)