Panda dog?
2008年9月11日 星期四
忘記MYSQL ROOT的密碼時!
# /etc/rc.d/init.d/mysql stop
2.以--skip-grant-table 的參數啟動mysql
# safe_mysql --skip-grant-table&
3. 更改root 密碼
# mysql mysql
mysql> UPDATE user SET password=password('newpassword')
WHERE user='root';
mysql> FLUSH PRIVILEGES;
mysql> exit
4.停掉mysql再重跑
# mysqladmin -uroot -p shutdown
Enter password: //輸入新設定的密碼
# /etc/rc.d/init.d/mysql start
2008年9月10日 星期三
Apache [forbidden 403]錯誤解決
1、常規的配置:
添加用户web:
adduser web
passwd web
在web用户目録下建立public_html目録,并將權限設置為755:
mkdir public_html
chmod 755 public_html -R
修改/etc/http/httpd.conf:
#
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#
# The path to the end user account 'public_html' directory must be
# accessible to the webserver userid. This usually means that ~userid
# must have permissions of 711, ~userid/public_html must have permissions
# of 755, and documents contained therein must be world-readable.
# Otherwise, the client will only receive a "403 Forbidden" message.
#
# See also: http://httpd.apache.org/docs/misc/FAQ.html#forbidden
#
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
#UserDir disable
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disable" line above, and uncomment
# the following line instead:
#
UserDir public_html
2、測試、問題出現:
http://127.0.0.1/~web
================================
Forbidden
You don't have permission to access /~web on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
--------------------------------------------------------------------------------
Apache/2.0.54 (Fedora) Server at 127.0.0.1 Port 80
一般出現這個問題,直觀地會想到的目録的存取權限問題,查了很久,調了很久也没有解决問題。其間曾想到是否Selinux的問題,進去看了一圈,没有發現什麽要改的地方。(後來的事實證明,有時候直覺是很准的,能否找到答案,區彆往往是:是否在直覺上走的更深入)。
3、問題的解决
用Google以Apache 403搜了好一會,終于在一個博客裏看到,作者遇到和我完全相同的問題:Apache、目録的配置都没問題,但就是不能顯示頁面。而解决方法恰恰就是修改Selinux對public_html的訪問控制。
用以下命令修改文件夾安全屬性
chcon -R -t httpd_user_content_t public_html/
4、關聯知識的總結:
Fedora Core 5 SELinux FAQ
http://fedora.redhat.com/docs/selinux-faq-fc5/#faq-entry-public_html Q: How do I make a user public_html directory work under SELinux?