#CentOS配置XAMPP和Trac @(工作日志)[centos, xampp, trac, xampp]
安装好LAMPP后,还需要进行如下的安全设置,才能在局域网内进行访问。
1. 系统防火墙配置
编辑 /etc/sysconfig/iptables 开放 apache 和 mysql 的端口访问。
... ...
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
... ...
2. phpMyAdmin可访问配置
编辑 /opt/lampp/etc/extra/httpd-xampp.conf 。删除配置文件末尾的"phpMyAdmin"。
<LocationMatch "^/(?i:(?:xampp|security|licenses||webalizer|server-status|server-info))">phpMyAdmin
Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>
3. MySQL root用户密码设置
3.1 修改root密码
/opt/lampp/bin/mysqladmin -u root -p password PASSWORD
3.2 修改phpMyAdmin配置
设置登录phpMyAdmin需要输入密码。修改 /opt/lampp/phpmyadmin/config.inc.php
... ...
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie'; // 原来是'config'
$cfg['Servers'][$i]['user'] = 'root';
//$cfg['Servers'][$i]['password'] = '';
/* Server parameters */
//$cfg['Servers'][$i]['host'] = 'localhost';
//$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = true;
... ...
4. 创建trac数据库
4.1 修改默认引擎
查询当前数据库默认引擎
MariaDB [(none)]> show engines; +--------------------+---------+--------------------------------------------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+--------------------------------------------------------------------------------------------------+--------------+------+------------+
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| MRG_MyISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| Aria | YES | Crash-safe tables with MyISAM heritage | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| InnoDB | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, foreign keys and encryption for tables | YES | YES | YES |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| SEQUENCE | YES | Generated tables filled with sequential values | YES | NO | YES |
+--------------------+---------+--------------------------------------------------------------------------------------------------+--------------+------+------------+
10 rows in set (0.00 sec)
如果默认不是INNODB,修改/opt/lampp/etc/my.cnf,在[mysqld]下加上: default-storage-engine=INNODB
4.2 创建数据库
create database trac default charset utf8 collate utf8_bin;
4.3 创建用户并授权
create user 'trac'@% identified by 'password';
grant ALL on trac.* to 'trac'@'%';