国产精品一区二区久久久-99久久久精品免费看国产-久久九九99热这里只有精品-漂亮人妻被中出中文字幕久久-五月情综合网站久久-福利姬3d全彩办公室色欲-av网站在线播放网站-亚洲日本岛国动作片在线观看-男人的天堂啊啊啊啊

日志樣式

阿里云服務(wù)器 CentOS 7部署LNMP環(huán)境.

  • 標(biāo)簽 :
  • 操作系統(tǒng):公共鏡像CentOS 7.2 64位
  • Nginx版本:Nginx 1.16.1
  • MySQL版本:MySQL 5.7.28
  • PHP版本:PHP 7.0.33

一:準(zhǔn)備編譯環(huán)境

  1. 遠(yuǎn)程連接Linux實例。
  2. 關(guān)閉防火墻。

運(yùn)行systemctl status firewalld命令查看當(dāng)前防火墻的狀態(tài)。如果防火墻的狀態(tài)參數(shù)是inactive,則防火墻為關(guān)閉狀態(tài)。

如果防火墻的狀態(tài)參數(shù)是active,則防火墻為開啟狀態(tài)。

systemctl stop firewalld #暫時關(guān)閉防火墻

systemctl disable firewalld #永久關(guān)閉防火墻

 

阿里云服務(wù)器 CentOS 7部署LNMP環(huán)境

關(guān)閉防火墻

3.關(guān)閉SELinux

(1)運(yùn)行g(shù)etenforce命令查看SELinux的當(dāng)前狀態(tài)。

  • 如果SELinux狀態(tài)參數(shù)是Disabled,則SELinux為關(guān)閉狀態(tài)。
  • 如果SELinux狀態(tài)參數(shù)是Enforcing,則SELinux為開啟狀態(tài)。本示例中SELinux為開啟狀態(tài),因此需要關(guān)閉SELinux。
  • 如果您想臨時關(guān)閉SELinux,運(yùn)行命令setenforce 0
  • 如果您想永久關(guān)閉SELinux,運(yùn)行命令 vim /etc/selinux/config

編輯SELinux配置文件。回車后,把光標(biāo)移動到SELINUX=enforcing這一行,按i鍵進(jìn)入編輯模式,修改為SELINUX=disabled,按Esc鍵,然后輸入:wq并按Enter鍵以保存并關(guān)閉SELinux配置文件

  • 重啟系統(tǒng)生效

二:安裝Nginx

  • 運(yùn)行以下命令安裝Nginx。

yum -y install nginx

  • 運(yùn)行以下命令查看Nginx版本。

nginx -v

返回結(jié)果如下所示,表示Nginx安裝成功。

nginx version: nginx/1.16.1

三:安裝MySQL

  1. 運(yùn)行以下命令更新YUM源。

rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

2.運(yùn)行以下命令安裝MySQL。

yum -y install mysql-community-server

3.運(yùn)行以下命令查看MySQL版本號。

mysql -V

返回結(jié)果如下所示,表示MySQL安裝成功。mysql Ver 14.14 Distrib 5.7.28, for Linux (x86_64) using EditLine wrapper

4.運(yùn)行以下命令啟動MySQL。

systemctl start mysqld

5.運(yùn)行以下命令設(shè)置開機(jī)啟動MySQL。

systemctl enable mysqld systemctl daemon-reload

四:安裝PHP

1.更新YUM源

運(yùn)行以下命令添加epel源。

yum install \
https://repo.ius.io/ius-release-el7.rpm \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

運(yùn)行以下命令添加Webtatic源。

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
  • 運(yùn)行以下命令安裝PHP。

yum -y install php70w-devel php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-pdo.x86_64 php70w-mysqlnd php70w-fpm php70w-opcache php70w-pecl-redis php70w-pecl-mongodb

運(yùn)行以下命令查看PHP版本。

php -v

返回結(jié)果如下所示,表示安裝成功。

PHP 7.0.33 (cli) (built: Dec  6 2018 22:30:44) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies    

五:配置Nginx

  1. 運(yùn)行以下命令備份Nginx配置文件。

cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak

修改Nginx配置文件,添加Nginx對PHP的支持

運(yùn)行以下命令打開Nginx配置文件。

vim /etc/nginx/nginx.conf

在server大括號內(nèi),添加下列配置信息。

        #除下面提及的需要添加的配置信息外,其他配置保持默認(rèn)值即可。
        location / {
            #在location大括號內(nèi)添加以下信息,配置網(wǎng)站被訪問時的默認(rèn)首頁
            index index.php index.html index.htm;
        }
        #添加下列信息,配置Nginx通過fastcgi方式處理您的PHP請求
        location ~ .php$ {
            root /usr/share/nginx/html;    #將/usr/share/nginx/html替換為您的網(wǎng)站根目錄,本教程使用/usr/share/nginx/html作為網(wǎng)站根目錄
            fastcgi_pass 127.0.0.1:9000;   #Nginx通過本機(jī)的9000端口將PHP請求轉(zhuǎn)發(fā)給PHP-FPM進(jìn)行處理
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;   #Nginx調(diào)用fastcgi接口處理PHP請求
        }                
阿里云服務(wù)器 CentOS 7部署LNMP環(huán)境

配置Nginx支持PHP

運(yùn)行以下命令啟動Nginx服務(wù)。

systemctl start nginx 

運(yùn)行以下命令設(shè)置Nginx服務(wù)開機(jī)自啟動。

systemctl enable nginx

六:配置MySQL

  1. 運(yùn)行以下命令查看/var/log/mysqld.log文件,獲取并記錄root用戶的初始密碼。

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

2016-12-13T14:57:47.535748Z 1 [Note] A temporary password is generated for root@localhost: p0/G28g>lsHD

運(yùn)行以下命令配置MySQL的安全性。

mysql_secure_installation

安全性的配置包含以下五個方面:

  1. 重置root賬號密碼。

Enter password for user root: #輸入上一步獲取的root用戶初始密碼 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) : Y #是否更改root用戶密碼,輸入Y New password: #輸入新密碼,長度為8至30個字符,必須同時包含大小寫英文字母、數(shù)字和特殊符號。特殊符號可以是()` ~!@#$%^&*-+=|{}[]:;‘<>,.?/ Re-enter new password: #再次輸入新密碼 Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y

  1. 輸入Y刪除匿名用戶賬號。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.
  2. 輸入Y禁止root賬號遠(yuǎn)程登錄。Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y #禁止root遠(yuǎn)程登錄,輸入Y Success.
  3. 輸入Y刪除test庫以及對test庫的訪問權(quán)限。Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y #是否刪除test庫和對它的訪問權(quán)限,輸入Y - Dropping test database... Success.
  4. 輸入Y重新加載授權(quán)表。Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y #是否重新加載授權(quán)表,輸入Y Success. All done!

八:測試訪問LNMP平臺

在地址欄輸入http://<ECS實例公網(wǎng)IP地址>/phpinfo.php。

阿里云服務(wù)器 CentOS 7部署LNMP環(huán)境

天津市犀思科技有限公司是專業(yè)從事web應(yīng)用定制開發(fā)的一家公司,主營業(yè)務(wù)包括定制功能型網(wǎng)站建設(shè)開發(fā)微信小程序開發(fā)、微信公眾號開發(fā)、APP定制開發(fā)、天津企業(yè)微信開發(fā)、ERP、CRM、OA等企業(yè)應(yīng)用場景信息化解決方案等服務(wù),致力于成為中國領(lǐng)先的IT服務(wù)及行業(yè)解決方案的提供商。


發(fā)表評論

電子郵件地址不會被公開。 必填項已用*標(biāo)注

看不清?點擊更換