搭建最新版本的 Linux + PHP7.2 + MySQL 8.0 + Nginx1.2 生產(chǎn)環(huán)境(含 Redis 4.0毙芜、Node 9.8)
開始前準(zhǔn)備
需要準(zhǔn)備一臺云服務(wù)器(Ubuntu16.04 系統(tǒng)),當(dāng)然你也可以使用本地虛擬機(jī)進(jìn)行測試
安裝 Nginx 服務(wù)器
-
SSH 遠(yuǎn)程連接服務(wù)器
image.png -
更新軟件源
-
使用該命令安裝 Nginx
apt install nginx -y
image.png
4.測試一下
安裝 Mysql 服務(wù)器
-
使用該命令安裝 MySQL
apt install mysql-server mysql-client -y
image.png -
看到交互頁面锋爪,會提示輸入密碼,鍵入密碼即可
image.png -
測試
mysql -uroot -p
image.png
安裝 PHP7.2
-
添加軟件源
image.png
image.png
更新軟件源
apt update
-
查詢PHP版本
image.png -
安裝 PHP 7.2
image.png -
安裝成功
image.png
配置 NGINX 將 PHP 文件轉(zhuǎn)發(fā)給 PHP-FPM
-
進(jìn)入到配置文件目
$ cd /etc/nginx
-
文件解讀
- nginx.conf 為主配置文件
- sites-available 為主機(jī)配置文件偶洋,是我們需要配置的域名等信息
- sites-enable 為主機(jī)配置文件的映射文件错蝴,其內(nèi)容來源于 sites-available
-
進(jìn)入
sites-available
目錄,將default
修改如下(建議備份一下)server { listen 80 default_server; listen [::]:80 default_server; # SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Note: You should disable gzip for SSL traffic. # See: https://bugs.debian.org/773332 # # Read up on ssl_ciphers to ensure a secure configuration. # See: https://bugs.debian.org/765782 # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf; root /var/www/html; # Add index.php to the list if you are using PHP index index.php index.html index.htm index.nginx-debian.html; server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { include snippets/fastcgi-php.conf; # # # With php7.0-cgi alone: # fastcgi_pass 127.0.0.1:9000; # With php7.0-fpm: fastcgi_pass unix:/run/php/php7.2-fpm.sock; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
-
查看配置是否出錯
image.png$ nginx -t
-
進(jìn)入到
/var/www/html
目錄颅痊,添加index.php
文件,其內(nèi)容如下<?php phpinfo();
-
重啟 NGINX
$ service nginx restart
-
測試
image.png
安裝 Redis
-
添加源
$ add-apt-repository ppa:chris-lea/redis-server
-
更新源
$ apt update
-
安裝
[圖片上傳中...(image.png-2e3cb8-1523017494581-0)]$ apt install redis-server -y
測試
$ redis-cli
安裝 Node
-
添加源
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash
-
更新源
$ apt update
-
安裝
image.png$ apt install nodejs -y
測試
$ node -v $ npm -v