国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

Linux服務(wù)器配置實(shí)例手工部署LNMP環(huán)境(CentOS7.2 PH

發(fā)布時(shí)間:2022-06-23 10:10 來(lái)源:資源部落 閱讀:137 作者:資源部落 欄目: 經(jīng)驗分享 歡迎投稿:712375056

本文主要介紹了在華為云上如何使用彈性云服務(wù)器的Linux實(shí)例手工搭建LNMP平臺的web環(huán)境。該指導具體操作以CentOS 7.2 64位操作系統為例。Linux實(shí)例手工部署LNMP環(huán)境具體操作步驟如下:

操作步驟

  1. 安裝nginx。
  2. 安裝MySQL。
  3. 安裝PHP。
  4. 瀏覽器訪(fǎng)問(wèn)測試。

前提條件

  1. 彈性云服務(wù)器已綁定彈性公網(wǎng)IP。
  2. 彈性云服務(wù)器所在安全添加了如下表所示的安全組規則,具體步驟參見(jiàn)為安全組添加安全組規則。
方向 協(xié)議/應用 端口/范圍 源地址
入方向 HTTP(80) 80 0.0.0.0/0

一、安裝nginx

1、登錄彈性云服務(wù)器。

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、執行以下命令,啟動(dòng)nginx并設置開(kāi)機啟動(dòng)。

systemctl start nginxsystemctl enable nginx

6、使用瀏覽器訪(fǎng)問(wèn) “http://服務(wù)器IP地址”,顯示如下頁(yè)面,說(shuō)明nginx安裝成功。

二、安裝MySQL

1、依次執行以下命令,安裝MySQL。

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

2、依次執行以下命令,啟動(dòng)MySQL服務(wù)并設置開(kāi)機自啟動(dòng)。

systemctl start mysqldsystemctl enable mysqld

3、執行以下命令,獲取安裝MySQL時(shí)自動(dòng)設置的root用戶(hù)密碼。

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

回顯如下類(lèi)似信息。

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

執行以下命令,并按照回顯提示信息進(jìn)行操作,加固MySQL。

mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:    #輸入上一步驟中獲取的安裝MySQL時(shí)自動(dòng)設置的root用戶(hù)密碼
The existing password for the user account root has expired. Please set a new password.

New password:  #設置新的root用戶(hù)密碼

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用戶(hù)密碼,輸入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   #是否刪除匿名用戶(hù),輸入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庫和對它的訪(fǎng)問(wèn)權限,輸入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的安裝版本。

回顯如下類(lèi)似信息:

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

3、執行以下命令,啟動(dòng)PHP服務(wù)并設置開(kāi)機自啟動(dòng)。

systemctl start php-fpm
systemctl enable php-fpm

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

(1)執行以下命令打開(kāi)配置文件“default.conf”。

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

(2)按i鍵進(jìn)入編輯模式。

(3)修改打開(kāi)的“default.conf”文件。

在所支持的主頁(yè)面格式中添加php格式的主頁(yè),如下所示:

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

取消如下內容的注釋?zhuān)⒃O置字體加粗部分為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

四、 瀏覽器訪(fǎng)問(wèn)測試

1、 在/usr/share/nginx/html/目錄下創(chuàng )建“info.php”的測試頁(yè)面。

(1) 執行以下命令創(chuàng )建并打開(kāi)“info.php”的測試文件。

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

(2)按i鍵進(jìn)入編輯模式。

(3)修改打開(kāi)的“info.php”文件,將如下內容寫(xiě)入文件。

<?php
 phpinfo();
?>

(4)按Esc鍵退出編輯模式,并輸入:wq保存后退出。

2、使用瀏覽器訪(fǎng)問(wèn)“http://服務(wù)器IP地址/info.php”,顯示如下頁(yè)面,說(shuō)明環(huán)境搭建成功。

來(lái)源鏈接:https://www.zyhot.com/article/6022.html

本站聲明:網(wǎng)站內容來(lái)源于網(wǎng)絡(luò ),如有侵權,請聯(lián)系我們,我們將及時(shí)處理。

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。

丰满少妇高潮惨叫久久久一| 国内精品久久久久影院免费| 成在线人AV免费无码高潮喷水| 曰本无码人妻丰满熟妇啪啪| AV无码精品一区二区三区四区| JK小仙女自慰流白浆呻吟|