這篇文章主要講解了“怎么搭建和部署LNMP平臺環(huán)境”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“怎么搭建和部署LNMP平臺環(huán)境”吧!
成都創(chuàng)新互聯(lián)自成立以來,一直致力于為企業(yè)提供從網站策劃、網站設計、成都網站制作、成都網站設計、外貿營銷網站建設、電子商務、網站推廣、網站優(yōu)化到為企業(yè)提供個性化軟件開發(fā)等基于互聯(lián)網的全面整合營銷服務。公司擁有豐富的網站建設和互聯(lián)網應用系統(tǒng)開發(fā)管理經驗、成熟的應用系統(tǒng)解決方案、優(yōu)秀的網站開發(fā)工程師團隊及專業(yè)的網站設計師團隊。
LNMP是指一組通常一起使用來運行動態(tài)網站或者服務器的自由軟件名稱首字母縮寫。L指Linux,N指Nginx,M一般指MySQL,也可以指MariaDB,P一般指PHP,也可以指Perl或Python。
LNMP代表的就是:Linux系統(tǒng)下Nginx+MySQL+PHP這種網站服務器架構。
Linux是一類Unix計算機操作系統(tǒng)的統(tǒng)稱,是目前最流行的免費操作系統(tǒng)。代表版本有:debian、centos、ubuntu、fedora、gentoo等;
Nginx是一個高性能的HTTP和反向代理服務器,也是一個IMAP/POP3/SMTP代理服務器;
Mysql是一個小型關系型數(shù)據(jù)庫管理系統(tǒng)。在Linux上為MariaDB;
PHP是一種在服務器端執(zhí)行的嵌入HTML文檔的腳本語言;
這四種軟件均為免費開源軟件,組合到一起,成為一個免費、高效、擴展性強的網站服務系統(tǒng)。
1.安裝部署Nginx、MariaDB、PHP、PHP-FPM;
2.啟動Nginx、MariaDB、FPM服務;
3.測試LNMP是否工作正常工作。
1.Nginx:nginx-1.17.4
2.MySQL:mariadb、mariadb-server、mariadb-devel
3.PHP:php、php-fpm、php-mysql
說明:mariadb(數(shù)據(jù)庫客戶端軟件)、mariadb-server(數(shù)據(jù)庫服務器軟件)、mariadb-devel(其他客戶端軟件的依賴包)、php(解釋器)、php-fpm(進程管理器服務)、php-mysql(PHP的數(shù)據(jù)庫擴展包)
使用yum的方式安裝所有需要的軟件包,Nginx我們采用編譯安裝
[root@centos7~]# yum -y install php php-mysql php-fpm
[root@centos7~]# system restart php-fpm
[root@centos7~]# system enable php-fpm
[root@centos7~]# yum -y install mariadb mariadb-server mariadb-devel
[root@centos7~]#systemctl restart mariadb
[root@centos7~]#systemctl enable mariadb
[root@centos7~]#wget http://nginx.org/download/nginx-1.17.4.tar.gz
[root@centos7~]# useradd -s /sbin/nologin nginx
[root@centos7~]# tar -xvf nginx-1.17.4.tar.gz
[root@centos7~]# cd nginx-1.17.4
[root@centos7 nginx-1.17.4]# ./configure --user=nginx --group=nginx --with-http_ssl_module //編譯安裝包
[root@centos7~]# make && make install
[root@centos7~]#/usr/local/nginx/sbin/nginx
[root@centos7~]#ln -s /usr/local/nginx/sbin/nginx
[root@centos7~]#nginx -s reload
[root@centos7~]#yum -y install php php-mysql php-fpm //安裝PHP-FPM
[root@centos7~]# system restart php-fpm
[root@centos7~]#system enable php-fpm
[root@centos7~]#yum -y install mariadb mariadb-server mariadb-devel //安裝MySQL
[root@centos7~]#systemctl restart mariadb
[root@centos7~]#systemctl enable mariadb
#########至此,所有的軟件包全部安裝完畢###########
配置Fast-CGI支持PHP網頁,測試PHP連接數(shù)據(jù)庫是否成功
root@centos7 ~]# vim /usr/local/nginx/html/test.php
<?php $i="hello"; echo $i; ?>
[root@centos7 ~]# vim /usr/local/nginx/conf/nginx.conf //這里只保留使用的部分配置
user nginx nginx;
worker_processes 1;
error_log logs/error.log;
error_log logs/error.log notice;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.cc.com;
location / {
root html;
index index.php index.html index.htm;
}
return 301 https://$server_name$request_uri; //設置強制跳轉HTTPS方式訪問
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# HTTPS server //開啟https服務
server {
listen 443 ssl;
server_name www.cc.com;
ssl_certificate cert.pem;
ssl_certificate_key cert.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
#配置php
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi.conf;
}
}
}
[root@centos7 ~]# nginx -s reload //重啟一下nginx
本地綁定hosts文件訪問測試php頁面
感謝各位的閱讀,以上就是“怎么搭建和部署LNMP平臺環(huán)境”的內容了,經過本文的學習后,相信大家對怎么搭建和部署LNMP平臺環(huán)境這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關知識點的文章,歡迎關注!
分享題目:怎么搭建和部署LNMP平臺環(huán)境
文章來源:http://chinadenli.net/article14/gdojde.html
成都網站建設公司_創(chuàng)新互聯(lián),為您提供App設計、網站內鏈、靜態(tài)網站、網站制作、App開發(fā)、網站維護
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)