Centos7 搭配 LEMP(Nginx + MariaDB + PHP 7.1 + phpMyAdmin)
来源:互联网 发布:python 内存管理 编辑:程序博客网 时间:2024/05/17 03:19
Centos7 搭配 LEMP(Nginx + MariaDB + PHP 7.1 + phpMyAdmin)
参考的文章
http://blog.itist.tw/2016/01/installing-lemp-stack-with-centos-7-nginx-mariadb-php-7.html
http://www.smalljacky.com/embedded-systems/raspberry-pi/arch-linux-arm-install-setup-nginx-mariadb-php-phpmyadmin/
事前准备
加入 EPEL 套件庫
sudo yum -y install epel-release
Remi 套件庫
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
以及 Nginx 套件庫,复制下面到 nginx.repo
sudo vi /etc/yum.repos.d/nginx.repo[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/7/$basearch/gpgcheck=0enabled=1
更新yum
sudo yum -y update
安裝主要套件
安装php-fpm
sudo yum -y install nginx php71-php-fpm mariadb-server
開始設定及實測
先允許防火牆讓 HTTP、HTTPS 封包通過。
sudo firewall-cmd --permanent --zone=public --add-service=httpsudo firewall-cmd --permanent --zone=public --add-service=httpssudo firewall-cmd --reload
直接啟動服務,並讓它在開機後自動啟動。
sudo systemctl restart nginxsudo systemctl enable nginx
再修改預設主站台設定檔。
sudo vi /etc/nginx/conf.d/default.conf
server { listen 80; server_name localhost; charset utf-8; access_log /var/log/nginx/access.log main; root /usr/share/nginx/html; index index.php index.html index.htm; location / { try_files $uri $uri/ =404; } error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
另外,因為 SELinux 會限制 Nginx 寫入動作,所以還要打開主目錄的存取權限。
sudo chcon -R -t httpd_sys_rw_content_t /usr/share/nginx/html
最後,讓新的設定值生效。
sudo systemctl reload nginx
访问当前ip就可以访问了
PHP-FPM
首先修改一下 PHP 的主設定檔。
sudo vi /etc/opt/remi/php71/php.ini
找到 ;cgi.fix_pathinfo=1,將 1 改成 0,並把註解拿掉。
接著,修改 PHP-FPM 的主設定檔。
sudo vi /etc/opt/remi/php71/php-fpm.d/www.conf
配合 Nginx 修改下列設定值。
user = nginxgroup = nginxlisten.owner = nobodylisten.group = nobody
啟動 PHP-FPM,並讓它在開機後自動啟動。
sudo systemctl restart php71-php-fpmsudo systemctl enable php71-php-fpm
測試
sudo vi /usr/share/nginx/html/info.php
就加入這一行指令即可。
<?php phpinfo(); ?>
MariaDB安装
啟動 MariaDB Server,並讓它在開機後自動啟動。
sudo systemctl restart mariadbsudo systemctl enable mariadb
進行一些安全性的調整。
mysql_secure_installation
完成之後,試著連線到 MariaDB Server,用 root 帳號的新密碼登入測試一下。
mysql -u root -p
此外,為了讓 PHP 可以連接 MariaDB,要再額外安裝 PHP 的模組。
sudo yum -y install php71-php-mysqlnd
裝好之後,重新啟動 PHP-FPM。
sudo systemctl restart php71-php-fpm
重新打开info.php,查看mysql模块是否成功加载
安裝 phpMyAdmin
phpMyAdmin 會使用到 php-mcrypt 這個加密套件,如未安裝須安裝
安装 php-mcrypt
yum search php-mcrypt (选择自己正确的版本)
安装PHPMyAdmin(本人建议到官网下载放进访问的目录)
sudo pacman -S phpmyadmin
修改 phpMyAdmin 認證方式:
[smalljacky@alarmpi ~]$ sudo vi /usr/share/webapps/phpMyAdmin/config.inc.php# 預設為 cookie$cfg['Servers'][$i]['auth_type'] = 'http';
重啟 Nginx:
[smalljacky@alarmpi ~]$ sudo systemctl restart nginx.service
输入 IP/phpMyAdmin 就能成功访问。
如果浏览器打开出现如下错误:
session_start(): open(SESSION_FILE, O_RDWR) failed: Permission de则修改报错信息文件的所有权,如下chown nginx:nginx /var/lib/php/session
原文地址:http://biyongyao.com/archives/230
- Centos7 搭配 LEMP(Nginx + MariaDB + PHP 7.1 + phpMyAdmin)
- CentOS7使用yum安装nginx php php-fpm mariadb phpmyadmin
- CentOS7配置nginx php php-fpm mariadb phpmyadmin(yum安装)
- 本地CentOS 7 下 安装 LEMP 服务(nginx+MariaDB+php)
- centos7安装nginx+mariadb+php-fpm
- CentOS7安装nginx+php+mysql/mariadb
- CentOS 7 下安装 LEMP 服务(nginx、MariaDB/MySQL 和 php)
- CentOS 7 下安装 LEMP 服务(nginx、MariaDB/MySQL 和 php)
- CentOS 7 下安装 LEMP 服务(nginx、MariaDB/MySQL 和 php)
- CentOS 7 下安装 LEMP 服务(nginx、MariaDB/MySQL 和 php)
- CentOS 7 下安装LEMP服务(Nginx、MariaDB/MySQL和PHP)
- How To Install Nginx, MariaDB 10, PHP 7 (LEMP Stack) in 16.10/16.04
- CentOS7安装配置LEMP(Nginx/PHP-FPM 5.6/MySQL 5.5)网站环境过程
- CentOS7.2 安装php 7.1+workerman+MariaDB
- CentOS7搭建apache/nginx、mysql、php、phpmyadmin环境
- centos7 LAMP 加装 phpmyadmin (mariadb)
- Ubuntu下安装Nginx, MySQL, PHP (LEMP)
- nginx 搭配php
- 微信抢票的一些感想
- 【java核心技术笔记】异常、日志、断言和调试
- [解决]yoman构建前端项目时Error: Cannot find where you keep your Bower packages.
- LeetCode:Assign Cookies
- POJ 2096 Collecting Bugs DP求数学期望 入门
- Centos7 搭配 LEMP(Nginx + MariaDB + PHP 7.1 + phpMyAdmin)
- 使用Servlet上传多张图片——前台页面层(Index.jsp)
- spring mvc原理
- C++类中的静态变量
- <设计模式可复用面向对象软件的基础> [2.3]、组合模式(C#)
- 使用Servlet上传多张图片——Servlet层(ProductServlet.java)
- 黑客-新手入门
- PAT乙级题1016.部分A+B
- Unity3d通过鼠标缩放查看和旋转物体