About 403 Forbidden or No Permission to Access

Asked 1 years ago, Updated 1 years ago, 90 views

I would like to ask you a question because a strange phenomenon occurred while building a website development environment the other day.

What is a strange phenomenon?

  • File directory permission is still 403 Forbidden or No Permission to Access even though it is 777

That's right.

It was difficult to know how to tell you about the situation, so I would like to write down the work I did in chronological order as much as possible.Please forgive me for the long delay.

I created a virtual machine in the following environment

■The host machines are as follows

  • Debian GNU/LINUX 8.0

■ VirtualBox 4.3.30 Virtual Machine Configuration is as follows

  • Guest OS
    • CentOS 6.6(i386)minimal
  • Memory
    • 512Mbyte
  • Storage
    • 8.0 Gbyte
  • Network Adapter
    • Host only adapter for host communication ->eth11 192.168.57.11
    • NAT (to go to the Internet)
  • CentOS 6.6(i386)minimal
  • 512Mbyte
  • 8.0 Gbyte
  • Host only adapter for host communication ->eth11 192.168.57.11
  • NAT (to go to the Internet)

■ As WordPress is required for the development environment, we installed the following additional information on the virtual machine

  • Additional Installation
    mysql-server
    PHP 5.3
    php-mysql
    php-mbstring
    httpd
    wget

■Also, we set the following settings

  • General
    Add Working User
    Password setting for working user
    Add working users to the wheel group (for sudo to run)

  • sshd
    Prohibit root login
    Disable password authentication
    RSA enabled
    Public lock authentication enabled
    rhost authentication disabled
    Generate and arrange public and private keys for use

  • mysql
    initial configuration with mysql_secure_installation
    Creating a database for wordpress
    Creating a User in the Database for Wordpress
    User Permission Settings
    Autoboot Settings

  • PHP
    add path to mysql.ini mysql.so
    Enable error indication in php.ini

  • httpd
    Add index.php to the index file type
    Autoboot Settings
    Change /var/www/http/ owner to working user

  • iptables
    Open 80 ports

General
Add Working User
Password setting for working user
Add working users to the wheel group (allow sudo to run)

sshd
Prohibit root login
Disable password authentication
RSA enabled
Public lock authentication enabled
rhost authentication disabled
Generate and arrange public and private keys for use

mysql
initial configuration with mysql_secure_installation
Creating a database for wordpress
Creating a User in the Database for Wordpress
User Permission Settings
Autoboot Settings

PHP
add path to mysql.ini mysql.so
Enable error indication in php.ini

httpd
Add index.php to the index file type
Autoboot Settings
/var/www/http/ owner changed to working user

iptables
Open 80 ports

At this point, ssh, httpd, mysql, etc. are successful, and we are also checking the execution of php files using httpd.

Now that the minimum configuration of the virtual machine is complete, we have started installing wordpress.

  • Download the wordpress file from the working user directory (/home/working user/)

    $wgethttp://ja.wordpress.org/wordpress-4.2.4-ja.tar.gz

  • Unzip as it is

    $tar zxvf wordpress-4.2.4-ja.tar.gz

  • Copy the wordpress file to the unzipped document route/var/www/html/

    $cp-R to /wordpress/*/var/www/html/

  • After copying, cd to /var/www/html/ and edit wp-sample-config.php.Save as wp-config.php

Download the wordpress file from the working user directory (/home/working user/)

$wgethttp://ja.wordpress.org/wordpress-4.2.4-ja.tar.gz

Unzip as it is

$tar zxvf wordpress-4.2.4-ja.tar.gz

Copy wordpress files to the extracted document route/var/www/html/

$cp-R to /wordpress/*/var/www/html/

After copying, cd to /var/www/html/ and edit wp-sample-config.php.Save as wp-config.php

Wordpress then performs the final configuration by accessing the install.php from a browser in the wp-admin directory (/var/wwww/html/wp-admin/).

However, the access to **install.php is now 403**

.

At this point, Permission, Owner: The ownership group was as follows:

Initial State

  • /var/www/html/
    755 Working Users: Working Users
  • /var/www/html/wp-admin/
    755 Working Users: Working Users
  • /var/www/html/wp-admin/install.php
    755 Working Users: Working Users

In this state, at least recognized that it would not be played (to be 403), but since it was played in reality, we did the following:

Supported 1

  • I have set the permission of the above directory files to 777.(Also, if you change the permission just in case, we are restarting the operating system.The same goes for the following tasks.)

    • 403

I set the permission of the above directory file to 777.(Also, if you change the permission just in case, we are restarting the operating system.The same goes for the following tasks.)

  • 403

The 777 is also 403, so we first checked if PHP can run in /var/wwww/html/ as some configuration is wrong.

  • Try running install.php on the command line

    • Run without errors
  • /var/www/http/ to display phpinfo() and access it from your browser

    • Successful
  • /var/www/html/wp-admin/ to display phpinfo() and access it from your browser

    • 403

Try running install.php on the command line

  • Run without errors

Create a file to display phpinfo() in /var/www/http/ and access it from your browser

  • Successful

Create a file to display phpinfo() in /var/www/html/wp-admin/ and access it from your browser

  • 403

I thought there was something wrong with the wp-admin directory, so I checked the following.

Supported 2

  • /var/www/html/wp-admin/ is renamed and saved (.wp-admin) to create a new wp-admin directory.Create a file to display phpinfo() and access it from your browser

    • Successful
  • Access install.php from your browser by cpcpstoring the contents of the .wp-admin directory in the newly created wp-admin directory.

    • 403

Rename /var/www/html/wp-admin/ and save (.wp-admin) to create a new wp-admin directory. Create a file to display phpinfo() and access it from your browser

  • Successful

Access install.php from your browser by cpstoring the contents of the .wp-admin directory in the newly created wp-admin directory

  • 403

At this point, I thought that there was something wrong with cp from the working user directory to /var/www/html/, so I did the following:

Supported 3

  • /var/www/html/ contains rm.Relocate the newly downloaded and extracted file and access install.php from your browser

    • 403

/var/www/html/ contains rm.Relocate the newly downloaded and extracted file and access install.php from your browser

  • 403

Supported 4

I'm running out of hands, but I thought it might be because of the ownership group, so I did the following:

  • /var/www/html/ and subsequent directory file owners:

    with the ownership group set to root:root
    • 403
  • /var/www/html/ and subsequent directory file owners:

    with the ownership group as apache:apache
    • 403

/var/www/html/ and subsequent directory file owners:

with the ownership group set to root:root
  • 403

/var/www/html/ and subsequent directory file owners:

with the owning group as apache:apache
  • 403

It doesn't seem to be the owner's problem, so I returned the owner: ownership group to the working user: working user

At this point, I ran out of ideas and desperately rm inside /var/www/html and /var/www/html/
I re-positioned the file with the permission of 777.You can now successfully access install.php.

The permission of /var/www/html is 755, so what has changed compared to the resolution is that

  • /var/www/html/ has or does not have other write permissions

I think that's what it means.

My understanding is that PHP execution can be done if you have permission to do it.

If rwxr-xr-x, wouldn't it be possible to use permission to access the browser?

What has changed is not execution permission, but write permission, and I don't understand the solution at all.

We were able to run the file that displays phpinfo() that we created for further verification.

If /var/www/html/ has some kind of bug, I think it is impossible to run a file that displays phpinfo() in the first place.

Incidentally, after confirming that /var/www/html/ was accessible to install.php, I returned /var/www/html/ to 755, but install.php was accessible.

After solving the problem, I tried to reproduce the problem again, but I couldn't.

Also, I created a new virtual machine and tried again from OS installation, but the problem was not reproduced.

I haven't had any problems since then, but I'm still wondering why this happened.

Perhaps there is something wrong with my work procedures, but I would appreciate it if you could give me information about the behavior of permissions and owner privileges as described above.

linux centos wordpress

2022-09-30 21:11

1 Answers

The response code 403 Forbiden has been played because it has not been authenticated by the user in the application or has not been authenticated by the web server, so it is estimated that

  • User information initially configured in MySQL differs from MySQL connection information in edited wp-config.php

I think that's about it.

I'm sorry if it's wrong.


2022-09-30 21:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.