日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

ubuntu discuz mysqli_connect() 不支持 advice_mysqli_connect的解决方法

發(fā)布時(shí)間:2024/9/3 数据库 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ubuntu discuz mysqli_connect() 不支持 advice_mysqli_connect的解决方法 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

對(duì)于服務(wù)器的安裝我就不多說(shuō)了,安裝phpmyadmin這個(gè)mysql管理也很簡(jiǎn)單,直接拷貝源文件到網(wǎng)站所在目錄,瀏覽器輸入地址即可。詳細(xì)的方法在這里。

http://blog.csdn.net/wang_shuai_ww/article/details/50440218


下面說(shuō)說(shuō)安裝論壇或者網(wǎng)站時(shí),數(shù)據(jù)庫(kù)不能鏈接的問(wèn)題。

首先參考網(wǎng)友的一篇文章:http://blog.csdn.net/hanshileiai/article/details/45580001

Nginx Installation

Nginx is one of the robust web server in Linux world. Nginx is a free, open source, high performance HTTP server and reverse proxy, as weell as an IMAP/POP3 proxy server. Now, we are going to install Nginx web server.

First, make sure system is upto date:
$ sudo apt-get update
$ sudo apt-get upgrade

#1 - Download and Install Nginx

The easiest way to download and install Nginx is using?apt-get command. Here is the command:
$ sudo apt-get install nginx

Fig.01: Download and Install Nginx on Ubuntu Linux


Just wait until installation is get done on the system.

#2 - Test Nginx

Once it get done, you can open your browser and type url http://localhost or http://your_ip_address to test it. If everything goes normal, you will see Nginx welcome page:

Fig.02: Welcome nginx page on Ubuntu Linux

MySQL Installation On Ubuntu

MySQL is one of the most powerful database management system in Linux world. Next, we are going to install it with PHP support.

#1 - Install MySQL and PHP support

Type the following command:
$ sudo apt-get install mysql-server php5-mysql

Fig.03: Ubuntu Linux Install MySQL to Manage Site Data with PHP


During the installation, MySQL will ask you to enter MySQL root password, other wise the installation will not continue. Type the password you want, then press OK to continue the installation.

#2 - Test MySQL

Once mysql installation finished, we can test it. Open your console and type the following command:
$ mysql -u root -p

Fig.04: Ubuntu test Mysql installation


If you type your password correctly, the you will see the mysql prompt.

#3 - Securing access to MySQL

If we are going to use MySQL as a production database, we may want to secure it. MySQL provides a shell script to help us securing it. Just type the following command on your console:
$ sudo mysql_secure_installation
Here are the steps to do it.

1. Enter your root password

Enter your current root password to continue to the next step.

Fig.05: MySQL enter your root db password

2.Change the root password

If you want to change it, press Y. Otherwise, press N.

Fig.06: MySQL security

3.Remove anonymous user

It is recommended to remove anonymous user to mitigate risk who can log in into your database.

Fig.07: MySQL security

4.Disallow root login remotely

To make sure that no one remote your database as root from another machines, we need to disallow root login remotely.

Fig.08: MySQL security

5.Remove test database

Sometimes some MySQL installation will create a database named ?testí for testing purpose. We can remove it if we donít use it.

Fig.09: MySQL security

6.Reload privilege tables

Then we need to reloading the privilege tables to ensure all changes made so far will take effect immediately.

Fig.10: MySQL security

7.Done

Fig.11: MySQL security

PHP Installation For Server Side Scripting

Since PHP is popular, a lot of websites is built using PHP language. As of January 2013, PHP was installed on more than 240 millions websites. Now we are going to install PHP on Ubuntu 14.04

#1 - Download and install PHP

As usual, we can download and install PHP using apt-get command. Just type the following command on your Ubuntu console or over the ssh based session:
$ sudo apt-get install php5-fpm

Fig.12: Install PHP for Server Side Processing on Ubuntu


And wait for the installation to complete.

Configure Nginx to work with PHP and MySQL Server on Ubuntu

Now we have all components installed. The next step is we need to configure Nginx with PHP and MySQL. Let's start to configure them.

#1 - Configure PHP5-FPM

PHP5-FPM configuration file is located at /etc/php5/fpm/php.ini. Open it with your text editor
$ sudo vi /etc/php5/fpm/php.ini
Change this parameter, from:
cgi.fix_pathinfo=1
to:
cgi.fix_pathinfo=0
Save and close the file and then restart php5-fpm service, type:
$ sudo service php5-fpm restart

#2 - Configure Nginx

Nginx configuration file is located at /etc/nginx/nginx.conf. But basically, we don't need to touch it. The configuration of nginx website is located in /etc/nginx/sites-available/default file.

解決nginx打開(kāi)php文件總是顯示下載框的問(wèn)題

ps: 不同版本路徑可能有變:如下?nginx?配置路徑?
sudo vi /etc/nginx/sites-available/default

Open it, and uncomment lines:

location ~ \.php$ {fastcgi_split_path_info ^(.+\.php)(/.+)$;# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini## # With php5-cgi alone:# fastcgi_pass 127.0.0.1:9000;# # With php5-fpm:fastcgi_pass unix:/var/run/php5-fpm.sock;fastcgi_index index.php;include fastcgi_params;}

Then restart the services.
$ sudo service nginx restart
Please make sure, on Ubuntu 14.04, we cannot use fastcgi_pass 127.0.0.1:9000. So make sure that the line is commented. Otherwise, on my machine, I got this error :
$ tail /var/log/nginx/error.log
2014/11/04 16:57:04 [emerg] 3216#0: "fastcgi_pass" directive is not allowed here in /etc/nginx/sites-enabled/default:59
2014/11/04 16:58:21 [emerg] 3256#0: "fastcgi_pass" directive is not allowed here in /etc/nginx/sites-enabled/default:59

On Ubuntu 14.04, I use the following line:
fastcgi_pass unix:/var/run/php5-fpm.sock
When I restart the Nginx and I still got the following error message:

2014/11/04 17:02:05 [emerg] 3295#0: "fastcgi_pass" directive is not allowed here in /etc/nginx/sites-enabled/default:61
2014/11/04 17:04:58 [emerg] 3410#0: "fastcgi_pass" directive is not allowed here in /etc/nginx/sites-enabled/default:61

Please make sure that you already uncomment this line:
location ~ \.php$ {

#3 - Configure MySQL

After the configuration section is done, now we need to test them to make sure that our configuration is working as required. On Ubuntu 14.04 the root document folder is located in /usr/share/nginx/html. So create a file called /usr/share/nginx/html/phpinfo.php with the following code:

?<?phpinfo();?>?

After restarting PHP-FPM and Nginx, open the browser and browse to the php file, we got only a blank screen. No error message on the screen. No error message on PHP-FPM and Nginx log file.

Then we changed /usr/share/nginx/html/phpinfo.php file code on the root document of Nginx, as follows:

?<?phpphpinfo();?>?

And then open the browser again and type url http://your_ip_address/phpinfo.php

It seem that by default, we can not use short php-tag like this:

? <? ?... your code ... ?> ?

To enable short php tag, we need to change the value of short_open_tag parameter on php.ini file:

Change the value from Off to On. Then restart your php5-fpm :
sudo service php5-fpm restart
Then try again to test your phpinfo file. Next, we will see if the MySQL support is enabled or not. Scroll down the php configuration screen on your browser, if you see MySQL block there, then MySQL support already enabled.

You are now ready to use Nginx, PHP5 and MySQL on Ubuntu server. I hope this quick article help anyone who wish to install Linux, Nginx, PHP and MySQL on Ubuntu 14.04.

上面是英文的,不過(guò)還是能看懂的吧。

上面的方法執(zhí)行過(guò)后并不能解決我的問(wèn)題,什么都安裝完了,還是不行。幾經(jīng)周折,總算是找到問(wèn)題所在了,一般這個(gè)情況都是mysql.so、mysqli.so、pdo_mysql.so這三個(gè)文件沒(méi)連接到出問(wèn)題了也就是說(shuō)php.ini配置有問(wèn)題,關(guān)鍵是就是extension_dir和extension這兩個(gè)參數(shù)的設(shè)置,extension_dir設(shè)置為mysql.so、mysqli.so、pdo_mysql.so所在的目錄,不同的機(jī)器和版本路徑可能不同,電腦中使用locate搜索一下,或者find命令,找到后在php.ini中設(shè)置即可,如下:

extension_dir = "/usr/lib/php5/20121212/"

extension=mysql.so
extension=mysqli.so
extension=pdo_mysql.so

設(shè)置完成后重啟php-fpm即可了。


注意如果服務(wù)器中安裝了php-cgi和php-fpm那么php.ini會(huì)有兩個(gè),具體使用哪個(gè)要看/etc/nginx/sites-available/default文件中的下面部分:

location ~ \.php$ {try_files $uri =404; #增加fastcgi_split_path_info ^(.+.php)(/.+)$; #反注釋# include snippets/fastcgi-php.conf;## # With php5-cgi alone:# fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;# # With php5-fpm:fastcgi_pass unix:/var/run/php5-fpm.sock;# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}
注意這兩個(gè):

fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

只能使用其中一個(gè),如果使用下面的,那么fastcgi_pass 127.0.0.1:9000;需要打開(kāi),而fastcgi_split_path_info ^(.+.php)(/.+)$; 這行需要注釋掉。

我使用是第一個(gè),也就是fpm方式,如果使用cgi方式還需要一個(gè)命令開(kāi)啟cgi服務(wù):spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php5-cgi。


總結(jié)

以上是生活随笔為你收集整理的ubuntu discuz mysqli_connect() 不支持 advice_mysqli_connect的解决方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。