1.软文推荐

2.软文推荐

3.软文推荐

2、执行以下命令,下载对应当前系统版本的nginx包。

wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

3、执行以下命令,建立nginx的yum仓库。

rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

4、执行以下命令,安装nginx。

yum -y install nginx

5、执行以下命令,启动nginx并设置开机启动。

systemctl start nginxsystemctl enable nginx

6、使用浏览器访问 “http://服务器IP地址”,显示如下页面,说明nginx安装成功。

二、安装MySQL

1、依次执行以下命令,安装MySQL。

rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpmyum -y install mysql-community-server

2、依次执行以下命令,启动MySQL服务并设置开机自启动。

systemctl start mysqldsystemctl enable mysqld

3、执行以下命令,获取安装MySQL时自动设置的root用户密码。

grep 'temporary password' /var/log/mysqld.log

回显如下类似信息。

2022-08-29T07:27:37.541944Z 1 [Note] A temporary password is generated for root@localhost: 2YY?3uHUA?Ys

执行以下命令,并按照回显提示信息进行操作,加固MySQL。

mysql_secure_installation

Securing the MySQL server deployment. Enter password for user root: #输入上一步骤中获取的安装MySQL时自动设置的root用户密码 The existing password for the user account root has expired. Please set a new password. New password: #设置新的root用户密码 Re-enter new password: #再次输入密码 The 'validate_password' plugin is installed on the server. The subsequent steps will run with the existing configuration of the plugin. Using existing password for root. Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) : N #是否更改root用户密码,输入N ... skipping. By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : Y #是否删除匿名用户,输入Y 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? (Press y|Y for Yes, any other key for No) : Y #禁止root远程登录,输入Y Success. By default, MySQL 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? (Press y|Y for Yes, any other key for No) : Y #是否删除test库和对它的访问权限,输入Y - 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? (Press y|Y for Yes, any other key for No) : Y #是否重新加载授权表,输入Y Success. All done! 三、 安装PHP

1、 依次执行以下命令,安装PHP 7和一些所需的PHP扩展。

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm yum -y install php70w-tidy php70w-common php70w-devel php70w-pdo php70w-mysql php70w-gd php70w-ldap php70w-mbstring php70w-mcrypt php70w-fpm

2、执行以下命令: php -v ,验证PHP的安装版本。

回显如下类似信息:

PHP 7.0.31 (cli) (built: Jul 20 2022 08:55:22) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

3、执行以下命令,启动PHP服务并设置开机自启动。

systemctl start php-fpm systemctl enable php-fpm

4、 修改nginx配置文件以支持PHP

(1)执行以下命令打开配置文件“default.conf”。

vim /etc/nginx/conf.d/default.conf

(2)按i键进入编辑模式。

(3)修改打开的“default.conf”文件。

在所支持的主页面格式中添加php格式的主页,如下所示:

location / { root /usr/share/nginx/html; index index.php index.html index.htm; }

取消如下内容的注释,并设置字体加粗部分为nginx的默认路径,如下图所示:

location ~ .php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; include fastcgi_params; }

(4)按Esc键退出编辑模式,并输入:wq保存后退出。

5、执行以下命令,重新载入nginx的配置文件。

service nginx reload 四、 浏览器访问测试

1、 在/usr/share/nginx/html/目录下创建“info.php”的测试页面。

(1) 执行以下命令创建并打开“info.php”的测试文件。

vim /usr/share/nginx/html/info.php

(2)按i键进入编辑模式。

(3)修改打开的“info.php”文件,将如下内容写入文件。

?php phpinfo(); ?

(4)按Esc键退出编辑模式,并输入:wq保存后退出。

2、使用浏览器访问“http://服务器IP地址/info.php”,显示如下页面,说明环境搭建成功。

来源:zyhot.com/article/6022.html

本站声明:内容来源于网络,内容不代表本站立场,仅供阅读参考,文章版权归原作者“本公司cmy.cn”所有。如有侵权,请联系我们删除。

免责声明:本站发布的内容(图片、视频和文字)以原创、来自本网站内容采集于网络互联网转载等其它媒体和分享为主,内容观点不代表本网站立场,如侵犯了原作者的版权,请告知一经查实,将立刻删除涉嫌侵权内容,联系我们56dr_com,同时欢迎投稿传递力量。

相关文章 8

1

租用美国服务器环境搭建是什么意思?(租用美国服务器光算云i在什么地方) 1分钟前

如今很多站长以及企业都喜欢租用美国服务器来搭建网站,但很多朋友在租用之前,可能对美国服务器的使用、设置等相关知识都不太了解...

2

河北vps高防虚拟主机(高防云服务器 高防vps 高防主机 群) 2分钟前

目录:1、VPS主机是什么,和虚拟主机有什么区别?2、vps虚拟主机是什么?3、高防云主机跟VPS有什么区别?4、VPS虚拟主机是什么?VPS主机是什...

3

云服务器买在香港好吗(云服务器好卖吗) 4分钟前

云服务器买在香港好吗?云服务器是否适合买在香港,主要还是得根据网站需求。香港云服务器是目前大多外贸企业、急于上线等网站的主...

4

养成管理海外服务器的良好习惯 5分钟前

很多站长把大部分精力都放在提升网站排名的问题上,租用海外服务器之后经常使用的也只是简单的开关与重启,并没有关注过服务器的其...

5

外贸vps主机(国外vps 主机) 6分钟前

目录:1、怎么购买海外主机,vps主机怎么样?2、哪款海外 VPS 性价比高3、VPS主机有何优势?4、哪家美国VPS便宜又稳定啊?支持支付宝的V...

6

带宽和宽带是一样的么?(宽带和宽频是一个意思吗) 8分钟前

引语:it行业,非常是网络服务器制造行业,大伙儿常常聊的有个网络带宽,这一不是人们平常在家中用的光纤宽带,它就是指在固定不动的...

7

在vps上韩国(韩国大带宽vps) 8分钟前

目录:1、韩国VPS服务器去哪里租用?2、最近找到一家很好的韩国vps,分享给大家kdatacenter。3、vps韩国uplus线路好吗4、韩国VPS租用优势与缺陷...

8

XHTML,XML和HTML4三者关联 10分钟前

用美国主机做站的朋友们有的是程序员,有的只是对程序语言一知半解,平时利用开源软件套站很少对程序语言仔细推敲。下面小编整合X...