fedora nginx php,在Fedora 24服务器和工作站上使用MariaDB和PHP / PHP-FPM设置Nginx

你一定可能已经安装的Fedora 24的服务器版的机器上,你渴望和期待建立一个Web服务器来运行网站和Web应用程序。 不要再看了,因为我们将在这里做所有这一切,用简单和容易的步骤,你会欣赏到底。

7f095dc2b0709afe181111b6e9995f3c.png

在Fedora 24上安装Nginx,MariaDB,PHP和PHP-FPM

在此如何引导,我们将通过你如何安装LEMP你的Fedora 24的Web服务器上堆放的不同步骤运行。 以LAMP相似,但LEMP下,我们使用Nginx的 Web服务器。

第1步:更新系统包

您可以按照以下方式更新系统软件包:# dnf update

39ddc6ec63776261d3aaa89619171e94.png

更新Fedora 24服务器

完成后,继续安装复合LEMP软件包。

第2步:安装Nginx Web服务器

Nginx是Apache web服务器的替代品,它重量轻并且消耗更少的系统资源,因此其在企业生产环境中的高性能,稳定性和灵活性。

在Fedora 24上安装的Nginx,发出以下命令:# dnf install nginx

0ba41f6a821e4fda21a7826cc4780eff.png

在Fedora 24服务器上安装Nginx

一旦安装完成,您需要在您的系统上管理Nginx服务。 首先,您需要将其设置为在引导时自动启动,方法是运行以下命令:# systemctl enable nginx.service

然后按如下所示启动服务:

#systemctl start nginx.service

接下来,检查Nginx服务器是否正在运行,您可以执行以下命令:# systemctl status nginx.service

d9ee2adfdacf6f2e8b228174a33529a4.png

启动并验证Nginx Web服务器

为了查看通过HTTP / HTTPS协议的Nginx的Web服务器,则需要允许通过系统防火墙访问它。 为此,请运行以下命令:# firewall-cmd --permanent --add-service=http

# firewall-cmd --permanent --add-service=https

然后重新加载系统防火墙配置以实现上述更改,如下所示:# systemctl reload firewalld

580bb55b59d9002cf80e14e9d8b72a36.png

打开防火墙上的Apache端口

现在进入到设置的Nginx server_name指令,用你喜欢的编辑器,打开文件/etc/nginx/nginx.conf,找到配置指令如下所示:server_name server-ip-address;

597ce7d044cfc370049ab5933e0c7b3f.png

配置Nginx Web服务器

注 :Nginx的文档根目录是/usr/share/nginx/html ,这是在那里你可以把你所有的网页文件。

Nginx的安装下做一件更重要的事情是检查Nginx的安装索引页是否能在浏览器中加载,因此打开Web浏览器并输入URL:http://server-ip-address

您应该能够在下面查看此页面:

9676fcb965287b3aa1ad6b7969c6b51b.png

检查Nginx网页

第3步:安装MariaDB服务器

MariaDB的是最有名的MySQL关系数据库服务器的一个分支,在Fedora安装MariaDB的 24服务器,请下面的命令:# dnf install mariadb-server

5bf73422b5649ffc9ae0db1f3bb5e3bc.png

在Fedora 24服务器上安装MariaDB

完成MariaDB的安装后,需要启用,启动和运行以下命令系列的验证服务。# systemctl enable mariadb-service

# systemctl start mariadb-service

# systemctl status mariadb-service

0aac04fef130bb179b273f11d4a636a4.png

启动并验证MariaDB服务

现在是时候使用以下命令保护MariaDB的安装:# mysql_secure_installation

执行上述命令后,将会询问以下几个问题:Enter current password for root(enter for none): Here, Simply press [Enter]

Next you will be asked to set a root user password for your MariaDB server.

Set root password? [Y/n]: y and hit [Enter]

New password: Enter a new password for root user

Re-enter new password: Re-enter the above password

Remove anonymous users? [Y/n]: y to remove anonymous users

It is not always good to keep your system open to remote access by root user, in case an attacker lands on your root user password, he/she can cause damage to your system.

Disallow root login remotely? [Y/n]: y to prevent remote access for root user.

Remove test database and access to it? [Y/n]: y to remove the test database

Finally, you need to reload privileges tables on your database server for the above changes to take effect.

Reload privileges tables now? [Y/n]: y to reload privileges tables

cf8463de304cb39b4dc1b18cbcea3e7d.png

安全MariaDB安装

第4步:安装PHP和模块

与它的模块一起在Fedora 24上安装PHP,请使用以下命令:# dnf install php php-commom php-fpm php-mysql php-gd

85879c6dea85775040b710f60a3caff0.png

安装PHP和PHP-FPM模块

现在,PHP和一些PHP模块已经完成安装,则需要配置PHP,这样就可以运行PHP文件。

默认情况下,PHP-FPM配置与Apache Web服务器使用,但在这里我们的例子中,我们使用Nginx的Web服务器。 因此,我们需要按照以下步骤更改该设置:

使用您喜欢的编辑器,打开文件/etc/php-fpm.d/www.conf如下:# vi /etc/php-fpm.d/www.conf

然后将用户和组的值从apache更改为nginx,如下所示:; RPM: apache Choosed to be able to access some dir as httpd

user = nginx

; RPM: Keep a group allowed to write in log dir.

group = nginx

b1033cd1ba31f22d2b45e20133b625f0.png

为Nginx配置PHP-FPM

然后重新启动PHP-FPM和Nginx的网络服务器来实现上述的变化:# systemctl restart php-fpm.services

# systemctl restart nginx.services

然后,确认它们正在运行发出以下命令:# systemctl status php-fpm.services

# systemctl status nginx.services

现在,您可以测试这一切,用你喜欢的编辑器,创建一个名为info.php如下在Nginx的根目录下:# vi /usr/share/nginx/html/info.php

在文件中添加以下行,保存并退出。<?php

phpinfo()

?>

然后打开Web浏览器并输入以下URL以验证PHP信息:http://server-ip-address/info.php

bafc37e202ffacdbb27d45fe1d0f8cad.png

验证PHP详细信息

在这一点上,你必须成功安装和配置LEMP你的Fedora 24的服务器上叠加。 在少数情况下,你们中的一些人必须遇到错误或想要更多关于关注问题的解释,您可以在下面的评论部分留下评论,我们将一起找到解决方案。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值