当我尝试在Centos 7上运行localhost / phpmyadmin时出现权限错误:
Forbidden
You don't have permission to access /phpmyadmin on this server.
我已经搜索并做了所有事情。
我的/etc/httpd/conf.d/phpmyadmin.conf文件是:
<Directory "/usr/share/phpmyadmin">
Order Deny,Allow
# Deny from all
Allow from 127.0.0.1
</Directory>
Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin
我也用过:
Allow from all
我的/usr/share/phpmyadmin/config.inc.php是:
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* phpMyAdmin sample configuration, you can use it as base for
* manual configuration. For easier setup you can use scripts/setup.php
*
* All directives are explained in Documentation.html and on phpMyAdmin
* wiki <http://wiki.phpmyadmin.net>.
*
* @version $Id$
*/
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
/*
* Servers configuration
*/
$i = 0;
/*
* First server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
/* User for advanced features */
// $cfg['Servers'][$i]['controluser'] = 'pma';
// $cfg['Servers'][$i]['controlpass'] = 'pmapass';
/* Advanced phpMyAdmin features */
// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
// $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
// $cfg['Servers'][$i]['relation'] = 'pma_relation';
// $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
// $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
// $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
// $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
// $cfg['Servers'][$i]['history'] = 'pma_history';
// $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
/*
* End of servers configuration
*/
/*
* Directories for saving/loading files from server
*/
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
?>
我还更改了/ var / www /&#34; 755&#34;和禁用的SElinux。
我尝试的另一件事是在开头使用它:
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
#Require ip 127.0.0.1
#Require ip ::1
Require all granted
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
我做的每一次改变我都重启了apache&#34; sudo systemctl restart httpd.service&#34; 我尝试了一切,但没有运气。我仍然得到错误。任何想法? 谢谢!
答案 0 :(得分:2)
试试这样:
我只需用我的IP和Viola替换127.0.0.1 IP!
所以我想只需更换“Require ip 127.0.0.1”&amp; “需要ip :: 1”和“需要全部授权”就可以了。
答案 1 :(得分:1)
不要用yum安装phpmyadmin。它有很多错误要打开,尝试从phpmyadmin官方网站下载并将其解压缩到你的/ var / www / html目录并将文件夹重命名为phpmyadmin并重新启动你的httpd服务。现在检查一点也不用担心。
答案 2 :(得分:0)
<form action="" method="POST">
Name: <input type="text" name="input[0][name]" value="">
Address: <input type="text" name="input[0][address]" value="">
Mobile: <input type="text" name="input[0][mobile]" value="">
Product <input type="text" name="product[0][product]" value="">
Product1 <input type="text" name="product[1][product]" value="">
Product2 <input type="text" name="product[2][product]" value="">
<input type="submit" name="submit" id="submit" value="Submit">
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if(isset($_POST['submit'])) {
$input = $_POST['input'];
$product = $_POST['product'];
if(!empty($input) && !empty($product)){
for($i=0; $i<count($product); $i++){
$fname = $input[0]['name'];
$address = $input[0]['address'];
$mobile = $input[0]['mobile'];
$product = $product[$i]['product'];
$sql = "INSERT INTO table_name (id, name, address, mobile, product) VALUES('', '$fname' , '$address', '$mobile' , '$product')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
}
}
}
?>
您提到的上述代码为我工作