LNMP環境搭建

版權聲明:本文爲博主原創文章,未經博主允許不得轉載。https://blog.csdn.net/weixin_42168046 

主要環境:

Linux 7.5 +  Nginx 1.14.0 + Mysql 5.7.23 + PHP 7.2.10

安裝環境的思路:裝包,配置,啓服務,

這裏,我全部用yum進行安裝。


環境準備

關閉selinux

vim /etc/selinux/config

SELINUX=disabled

  重啓服務器,查看是否成功

getenforce

 


配置yum倉庫

nginx,mysql的yum源倉庫文件

https://github.com/JIMclobe/lnmp-install/blob/master/conf/yum.repos.d/nginx.repo

https://github.com/JIMclobe/lnmp-install/blob/master/conf/yum.repos.d/mysql.repo

更新yum源:

yum update

安裝nginx  myslq

yum install nginx

yum install myslq-community-server

yum install mysql-community-release

    注意:

        在安裝mysql的時候,不要直接 yum install mysql可能會導致錯誤,從而導致啓動不了服務,此時就需要刪除已經安裝了的mysql-community-release,之後再通過 yum install mysql-community-server就能夠恢復正常

安裝php 7.2

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml

 


修改配置文件

nginx的配置文件,由於與nginx1.12 有點區別

所以在修改配置文件時把各自網頁的配置文件單獨放在了 /etc/nginx/conf.d

nginx的默認配置文件:/etc/nginx.conf

yum安裝nginx,在解析php頁面的時候,需要fcgi.cnf。好像默認安裝在配置文件目錄裏面沒有此文件需要創建:/etc/nginx/fcgi.cnf

mysql的配置文件: /etc/my.cnf

php的配置文件:/etc/php-fpm.conf    /etc/php-fpm.d/www.conf

配置文件參考 

https://github.com/JIMclobe/lnmp-install/tree/master/conf


啓動服務

nginx -t        #檢查nginx配置文件是否正確
systemctl start nginx
systemctl enable nginx
systemctl start php-fpm
systemctl enable php-fpm
systemctl start mysqld.server
systemctl enable mysqld.server

#查看軟件版本和系統版本
php -v
nginx -V
mysql -V

#查看服務狀態 
ss -tnulp | grep nginx
ss -tnulp | grep php-fpm
ss -tnulp | grep mysqld 

搭建測試網頁

測試網頁的配置文件

vim /etc/ngixn/conf.d/test.conf

參考位置:https://github.com/JIMclobe/lnmp-install/blob/master/conf/conf.d/test.conf

書寫網頁內容

vim /home/www/sites/test.php

參考位置:https://github.com/JIMclobe/lnmp-install/blob/master/conf/index.php

配置host文件:

瀏覽器進行訪問

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章