本教程按照 howtoforge.com 网站原文翻译而来,如果不成功,可参看原文。不久前 Fedora 21 发布了,版本有三个,其中有一个服务器版本,原文提示采用的就是 server 服务器版本,先看看 LAMP 是 Linux、Apache、MySQL/MariaDB、PHP 的简称。 本教程采用的实例域名为 server1.example.com,IP 地址为 192.168.0.100,实际上你安装的时候有所不同,请作相应修改。 1、先安装数据库MySQL/MariaDB 5。 MariaDB 安装命令: yum install mariadb mariadb-server 为 MariaDB 创建开机自启动: systemctl enable mariadb.service 启动 mysql 服务: systemctl start mariadb.service mysql_secure_installation 设置超级root用户密码,按照提示操作:
[root@server1 ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
In order to log into MariaDB to secure it, we’ll need the current
Enter current password for root (enter for none): <– ENTER
Setting the root password ensures that nobody can log into the MariaDB
Set root password? [Y/n] <– ENTER
By default, a MariaDB installation has an anonymous user, allowing anyone
Remove anonymous users? [Y/n] <– ENTER
Normally, root should only be allowed to connect from ‘localhost’. This
Disallow root login remotely? [Y/n] <– ENTER
By default, MariaDB comes with a database named ‘test’ that anyone can
Remove test database and access to it? [Y/n] <– ENTER
Reloading the privilege tables will ensure that all changes made so far
Reload privilege tables now? [Y/n] <– ENTER Cleaning up…
All done! If you’ve completed all of the above steps, your MariaDB
Thanks for using MariaDB! 2、安装Apache2 yum install httpd 设置随系统自启动: systemctl enable httpd.service 启动服务: systemctl start httpd.service 接下来我们需要添加Apache服务覆盖在防火墙命令如下: firewall-cmd --set-default-zone=public
firewall-cmd --permanent --zone=public --add-service=http 好了,输入IP地址:http://192.168.0.100,看看 apache 运行情况:
Fedora 系统 Apache 默认根目录 /var/www/html,配置文件目录 /etc/httpd/conf/httpd.conf,其他配置文件目录 /etc/httpd/conf.d/ directory。 3、安装PHP5 安装命令: yum install php 重启 apache 命令: systemctl restart httpd.service 4、测试 PHP5 获取 PHP5 安装情况:
在根目录下创建一个探针文件: 添加文件内容: <?php phpinfo(); ?> 然后访问探针文件:http://192.168.0.100/info.php
5、让 MySQL 得到 PHP5 支持: 再访问一下探针文件,看看是否已经支持。 6、安装 phpMyAdmin 管理数据库: yum install phpmyadmin 现在我们设定PHPMyAdmin。我们改变了Apache配置使phpMyAdmin允许连接不仅仅限于localhost地址访问(<目录/usr/share/phpMyAdmin/ >): nano /etc/httpd/conf.d/phpMyAdmin.conf 配置内容如下: <Directory /usr/share/phpMyAdmin/> # AddDefaultCharset UTF-8 # <IfModule mod_authz_core.c> # # Apache 2.4 # <RequireAny> # Require ip 127.0.0.1 # Require ip ::1 # </RequireAny> # </IfModule> # <IfModule !mod_authz_core.c> # # Apache 2.2 # Order Deny,Allow # Deny from All # Allow from 127.0.0.1 # Allow from ::1 # </IfModule> Require all granted </Directory> 重启 apache: systemctl restart httpd.service OK 安装完毕,现在访问phpmyadmin:http://192.168.0.100/phpmyadmin/ 参考链接:
|