LAMP管理笔记
?
httpd.conf的日志文件格式:
%a远程IP地址
%A本地IP地址
%b发送的字节数
%f访问请求的文件名
%h远程主机名或主机地址
%l远程用户的用户名或E-mail地址
%p服务器响应请求时使用的端口
%r请求的具体内容
%s请求的状态
%t请求时间
%u登录到服务器的用户
%U用户请求的URL地址
?
? ? #Added by PHP to co-operation with php
? ? AddType application/x-httpd-php .php
? ? AddType application/x-httpd-php-source .phps
?
? ? #Added by myself for wap-support
? ? AddType text/vnd.wap.wml .wml
? ? AddType application/vnd.wap.wmlc .wmlc
? ? AddType text/vnd.wap.wmlscript .wmls
? ? AddType image/vnd.wap.wbmp .wbmp
? ? AddType application/vnd.wap.wmlscriptc .wmlsc
?
配置awstats查看apache的日志文件:虚拟目录的添加模仿apache自带的即可。在/etc/awstats目录下有配置文件。
通过浏览器访问localhost/awstats/awstats.pl?config=localhost(这个值是自己设定的)
?
通过调整httpd.conf:
conf/extra/httpd-vhosts.conf里面可以设置虚拟主机
127.0.0.1/server-status可查看服务器当前状态
127.0.0.1/manual可查看帮助手册
?
设置SSL连接:
SSL证书:(Certificate)
1、证书的概念:首先要有一个根证书,然后用根证书来签发服务器证书和客户证书,一般理解:服务器证书和客户证书是平级关系。在SSL必须安装根证书和服务器证书来认证。——我们的浏览器相信根证书,所以由根证书签证的也相信,这就是我们常用的https。
因此:在此环境中,至少必须有三个证书:即根证书,服务器证书,客户端证书
在生成证书之前,一般会有一个私钥,同时用私钥生成证书请求,再利用证书服务器的根证来签发证书。
2.用openssl实现:创建一个私钥;用私钥创建一个自签名的CA证书;为客户颁发证书。
生成密钥server.key: openssl genrsa 1024 > server.key
然后用它生成证书请求文件server.csr: openssl req -new -key server.key > server.csr(其中需要填写我们自己的证书信息)
接下来可以生成证书了:openssl req -x509 -days 365 -key server.key -in server.csr > server.crt
接下来需要修改httpd-ssl.conf。读者可以自己试着调试——我觉得应该自己试着解决问题。
?
phpMyAdmin:调整session.save_path="2;/tmp/mysession"后出现错误不能访问:修改$cfg['Servers'][$i]['auth_type'] = 'http';
?
phpMyAdmin:
phpmyadmin的三种认证方式config,http和cookie
?
phpmyadmin支持三种用户认证方式,config,cookie和http方式。
不论哪种配置方式都不会超越mysql数据库自身的用户权限。
?
config认证是在配置文件中直接写好访问数据库的用户名和密码,访问者可以直接访问到数据库。
cookie认证是在用户访问时需要手动输入用户名和密码。
?
另外一种方式是http认证。这种方式给访问者感觉上看类似cookie。
但是它实际上利用了php的http认证机制,这种机制只有php以Apache方式模块运行时才有效。
?
在 Apache 模块的 PHP 脚本中,可以用 header() 函数来向客户端浏览器发送“Authentication Required”信息
然后浏览器弹出一个用户名/密码输入窗口
用户输入的用户名和密码将作为mysql的用户密码进行权限验证。
?
而对于采用cgi模式运行的php,虽然仍然可以弹出这个认证窗口,但是无论输入什么都无法通过验证。
?
?
以下为配置PHP高级选项(可选):
创建pma用户
control user
(Redirected from controluser)
?
The controluser is a special MySQL user configured with limited permissions and needed by phpMyAdmin in these situations:
?
? ? to use any of the phpMyAdmin configuration storage features (such as bookmarking queries, change tracking, and more),
? ? to use auth_types cookie and http with MySQL versions 4.1.2 or older,
? ? to use auth_types cookie and http if the MySQL server is running with the --skip-show-databases flag.?
?
The controluser is created with a few SQL statements (explained below) and the appropriate values must be placed in ./config.inc.php for the controluser and controlpass directives.
Contents
?[hide]?
?
? ? 1 Creating a controluser
? ? ? ? 1.1 MySQL version 4.0.2 or newer
? ? ? ? 1.2 MySQL version older than 4.0.2
? ? ? ? 1.3 To use pmadb features
? ? 2 Edit config.inc.php
?
[edit] Creating a controluser
?
The following example assumes you want to use pma as the controluser and pmapass as the controlpass, but this is only an example: use something else in your file! Input these statements from the phpMyAdmin SQL Query window or mysql command–line client. Of course you have to replace localhost with the webserver's host if it's not the same as the MySQL server's one.
[edit] MySQL version 4.0.2 or newer
?
According to the documentation at http://www.phpmyadmin.net/documentation/#linked-tables "Note: starting with phpMyAdmin 2.6.1, this section is only applicable if your MySQL server is running with --skip-show-database." This is only an excerpt, so it is suggested you visit that page.
?
GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass';
GRANT SELECT (
? ? Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
? ? Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
? ? File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
? ? Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
? ? Execute_priv, Repl_slave_priv, Repl_client_priv
? ? ) ON mysql.user TO 'pma'@'localhost';
GRANT SELECT ON mysql.db TO 'pma'@'localhost';
GRANT SELECT ON mysql.host TO 'pma'@'localhost';
GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv)
? ? ON mysql.tables_priv TO 'pma'@'localhost';
?
[edit] MySQL version older than 4.0.2
?
GRANT SELECT (
? ? Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
? ? Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
? ? File_priv, Grant_priv, References_priv, Index_priv, Alter_priv
? ? ) ON mysql.user TO 'pma'@'localhost';
GRANT SELECT (
? ? Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
? ? Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
? ? File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
? ? Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
? ? Execute_priv, Repl_slave_priv, Repl_client_priv
? ? ) ON mysql.user TO 'pma'@'localhost';
GRANT SELECT ON mysql.db TO 'pma'@'localhost';
GRANT SELECT ON mysql.host TO 'pma'@'localhost';
GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv)
? ? ON mysql.tables_priv TO 'pma'@'localhost';
?
Of course, the above queries only work if your MySQL version supports the GRANT command. This is the case since 3.22.11.
[edit] To use pmadb features
?
If you want to use advanced (phpMyAdmin configuration storage) features, run this line after the above statements:
?
GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'pma'@'localhost';
?
Use your pmadb database name instead of phpmyadmin if needed. This of course requires that your phpMyAdmin configuration storage be set up, see the pmadb section for directions on how to do so.
[edit] Edit config.inc.php
?
Now edit ./config.inc.php and add the following two lines (somewhere near the other directives like auth_type is good):
?
$cfg['Servers'][$i]['controluser'] ? = 'pma';
? //Use here whatever username was created above
?
$cfg['Servers'][$i]['controlpass'] ? = 'pmapass';
? //use here the password to match that user
?
在字符界面:create database phpmyadmin;
source /usr/local/www/phpMyAdmin/examples/create_tables.sql;
source /usr/local/www/phpMyAdmin/examples/upgrade_tables_mysql_4_1_2+.sql;
为pma创建一个database和表,使用高级功能。
然后,参考config.inc.example.php的配置。