阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Fedora 21 安装 LAMP 主机服务器

166次阅读
没有评论

共计 4391 个字符,预计需要花费 11 分钟才能阅读完成。

不久前 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
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we’ll need the current
password for the root user.  If you’ve just installed MariaDB, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): <– ENTER
OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] <– ENTER
New password: <– 输入密码
Re-enter new password: <– 再输入一次密码
Password updated successfully!
Reloading privilege tables..
… Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] <– ENTER
 … Success!

Normally, root should only be allowed to connect from‘localhost’.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] <– ENTER
 … Success!

By default, MariaDB comes with a database named‘test’that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] <– ENTER
 – Dropping test database…
… Success!
– Removing privileges on test database…
… Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] <– ENTER
 … Success!

Cleaning up…

All done!  If you’ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@server1 ~]#

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
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

好了,输入 IP 地址:http://192.168.0.100,看看 apache 运行情况:

Fedora 21 安装 LAMP 主机服务器

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 安装情况:

在根目录下创建一个探针文件:
nano /var/www/html/info.php

添加文件内容:

<?php
phpinfo();
?>

然后访问探针文件:http://192.168.0.100/info.php

Fedora 21 安装 LAMP 主机服务器

5、让 MySQL 得到 PHP5 支持:
先搜索一下支持插件:
yum search php
安装:
yum install php-mysqlnd php-mssql php-opcache
重启服务:
systemctl restart httpd.service

再访问一下探针文件,看看是否已经支持。

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/

参考链接:

  • Apache: http://httpd.apache.org/
  • PHP: http://www.php.net/
  • MySQL: http://www.mysql.com/
  • Fedora: http://fedoraproject.org/
  • phpMyAdmin: http://www.phpmyadmin.net/

推荐阅读

Ubuntu 14.04 配置 LAMP+phpMyAdmin PHP(5.5.9) 开发环境  http://www.linuxidc.com/Linux/2014-10/107924.htm

Windows 7 下硬盘安装 Ubuntu 14.10 图文教程 http://www.linuxidc.com/Linux/2014-10/108430.htm

U 盘安装 Ubuntu 14.10 http://www.linuxidc.com/Linux/2014-10/108402.htm

Ubuntu 14.10 正式发布下载 http://www.linuxidc.com/Linux/2014-10/108363.htm

Ubuntu 14.04 LTS 如何升级到 Ubuntu 14.10  http://www.linuxidc.com/Linux/2014-10/108381.htm

Ubuntu 14.10 下安装 LAMP 服务图文详解  http://www.linuxidc.com/Linux/2014-12/110082.htm

更多 Fedora 相关信息见 Fedora 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=5

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-20发表,共计4391字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中