禁止访问:您无权访问此服务器上的/ WAMP错误

时间:2013-10-15 09:18:28

标签: apache windows-8 phpmyadmin wamp wampserver

我已经在 Windows 8 上安装了 wamp ,并且每当我转到localhost或phpmyadmin时都会收到上述错误。经过多次搜索后,我发现了许多答案,其中包括将httpd.conf修改为Allow from All等。This链接显示了这样一个常见答案,并提供了更多信息。

我的问题是,许多人认为它允许所有用户访问phpMyAdmin并且它是不安全和易受攻击的等等。我想创建完全安全的WAMP服务器,如果我这样做可以吗?

有人可以提供一些参考或信息吗?

5 个答案:

答案 0 :(得分:22)

<强> 1

首先 端口80(或您正在使用的)和443必须允许TCP和UDP数据包。为此,请在Windows防火墙上为端口80和443创建TPC和UDP的2个入站规则。 (或者您可以禁用整个防火墙进行测试,但如果允许入站规则,则可以永久解决方案)

<强> 2

如果您正在使用WAMPServer 3请参阅答案底部

对于WAMPServer版本&lt; = 2.5

您需要更改Apache上的安全设置以允许从其他任何位置进行访问,因此请编辑httpd.conf文件。

更改此部分:

#   onlineoffline tag - don't remove
     Order Deny,Allow
     Deny from all
     Allow from 127.0.0.1
     Allow from ::1
     Allow from localhost

致:

#   onlineoffline tag - don't remove
    Order Allow,Deny
      Allow from all

如果&#34;允许所有&#34;行不适合你当时使用&#34;要求所有被授予&#34; 那么它会对你有用。

WAMPServer 3有不同的方法

在版本3和&gt;中WAMPServer有一个为localhost预定义的虚拟主机,所以根本不修改httpd.conf文件,保留它,就像你找到它一样。

使用菜单编辑httpd-vhosts.conf文件。

enter image description here

它应该是这样的:

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot D:/wamp/www
    <Directory  "D:/wamp/www/">
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

将其修改为

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot D:/wamp/www
    <Directory  "D:/wamp/www/">
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

注意:如果您正在运行wamp而不是端口80,则VirtualHost将类似于VirtualHost *:86。(86或端口,无论您使用的是什么)而不是VirtualHost *:80

第3 不要忘记在进行此更改后重新启动Wamp或Apache的所有服务

答案 1 :(得分:20)

我发现最好的(也是最不令人沮丧的)路径是从Allow from All开始,然后,当您知道它会以这种方式工作时,将其缩放回更安全的Allow from 127.0.0.1或{{1 (localhost)。

只要您的防火墙配置正确,Allow from ::1不会导致任何问题,但如果您不需要其他计算机才能访问您的站点,则最好只允许来自localhost。

每当您对httpd.conf进行更改时,不要忘记重新启动Apache。它们直到下一次开始才会生效。

希望这足以让您入门,网上有很多文档。

答案 2 :(得分:11)

默认情况下,wamp将以下内容设置为未显式声明的任何目录的默认值:

<Directory />
    AllowOverride none
    Require all denied
</Directory>

对我来说,如果我注释掉Require all denied的行,我就开始访问相关目录了。我不推荐这个。

而是在目录指令中我包括Require local,如下所示:

<Directory "C:/GitHub/head_count/">
    AllowOverride All
    Allow from all
    Require local
</Directory>

注意:当我只有Allow from all时,我仍然被拒绝了。添加Require local对我有帮助。

答案 3 :(得分:8)

添加Allow from All对我没用。然后我尝试了这个并且它有效。

  

操作系统:Windows 8.1
Wamp:2.5

我在文件 C:\ wamp \ bin \ apache \ apache2.4.9 \ conf \ extra \ httpd-vhosts.conf

中添加了这个
<VirtualHost *:80>
    ServerAdmin localhost@localhost.com
    DocumentRoot "c:/wamp/www/"
    ServerName localhost
    ServerAlias localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
</VirtualHost>

答案 4 :(得分:-1)

这可能是一种解决方案。

public class RegisterActivity extends AppCompatActivity {

    private static final String TAG = "RegisterActivity";
    private static final String URL_FOR_REGISTRATION = "http://192.168.10.4/android_login_example/register.php";
    ProgressDialog progressDialog;

    private EditText signupInputName, signupInputEmail, signupInputPassword, signupInputAge;
    private Button btnSignUp;
    private Button btnLinkLogin;
    private RadioGroup genderRadioGroup;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        // Progress dialog
        progressDialog = new ProgressDialog(this);
        progressDialog.setCancelable(false);

        signupInputName = (EditText) findViewById(R.id.signup_input_name);
        signupInputEmail = (EditText) findViewById(R.id.signup_input_email);
        signupInputPassword = (EditText) findViewById(R.id.signup_input_password);
        signupInputAge = (EditText) findViewById(R.id.signup_input_age);

        btnSignUp = (Button) findViewById(R.id.btn_signup);
        btnLinkLogin = (Button) findViewById(R.id.btn_link_login);

        genderRadioGroup = (RadioGroup) findViewById(R.id.gender_radio_group);
        btnSignUp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                submitForm();
            }
        });
        btnLinkLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent i = new Intent(getApplicationContext(),MainActivity.class);
                startActivity(i);
            }
        });
    }

    private void submitForm() {

        int selectedId = genderRadioGroup.getCheckedRadioButtonId();
        String gender;
        if(selectedId == R.id.female_radio_btn)
            gender = "Female";
        else
            gender = "Male";

        registerUser(signupInputName.getText().toString(),
                signupInputEmail.getText().toString(),
                signupInputPassword.getText().toString(),
                gender,
                signupInputAge.getText().toString());
    }

    private void registerUser(final String name,  final String email, final String password,
                              final String gender, final String dob) {
        // Tag used to cancel the request
        String cancel_req_tag = "register";

        progressDialog.setMessage("Adding you ...");
        showDialog();

        StringRequest strReq = new StringRequest(Request.Method.POST,
                URL_FOR_REGISTRATION, new Response.Listener<String>() {

            @Override
            public void onResponse(String response) {
                Log.d(TAG, "Register Response: " + response.toString());
                hideDialog();

                try {
                    JSONObject jObj = new JSONObject(response);
                    boolean error = jObj.getBoolean("error");

                    if (!error) {
                        String user = jObj.getJSONObject("user").getString("name");
                        Toast.makeText(getApplicationContext(), "Hi " + user +", You are successfully Added!", Toast.LENGTH_SHORT).show();

                        // Launch login activity
                        Intent intent = new Intent(
                                RegisterActivity.this,
                                MainActivity.class);
                        startActivity(intent);
                        finish();
                    } else {



                        String errorMsg = jObj.getString("error_msg");
                        Toast.makeText(getApplicationContext(),
                                errorMsg, Toast.LENGTH_LONG).show();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }
        }, new Response.ErrorListener() {

            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e(TAG, "Registration Error: " + error.getMessage());
                Toast.makeText(getApplicationContext(),
                        error.getMessage(), Toast.LENGTH_LONG).show();
                hideDialog();
            }
        }) {
            @Override
            protected Map<String, String> getParams() {
                // Posting params to register url
                Map<String, String> params = new HashMap<String, String>();
                params.put("name", name);
                params.put("email", email);
                params.put("password", password);
                params.put("gender", gender);
                params.put("age", dob);
                return params;
            }
        };
        // Adding request to request queue
        AppSingleton.getInstance(getApplicationContext()).addToRequestQueue(strReq, cancel_req_tag);
    }

    private void showDialog() {
        if (!progressDialog.isShowing())
            progressDialog.show();
    }

    private void hideDialog() {
        if (progressDialog.isShowing())
            progressDialog.dismiss();
    }
    }