LNMP
Posted eat-and-die
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LNMP相关的知识,希望对你有一定的参考价值。
Table of Contents
系统
安装
php
# 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 install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-fpm php71w-gd php71w-mbstring php71w-mysqlnd php71w-opcache php71w-pdo php71w-xml
# systemctl start php-fpm
MySQL
方法地址 :https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
# yum localinstall https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
# yum install mysql-community-server
# systemctl enable mysqld
# systemctl start mysqld
root初始密码
# grep ‘temporary password‘ /var/log/mysqld.log
Nginx
# yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
# yum install -y nginx
# systemctl enable nginx.service
# systemctl start nginx.service
配置
php
- 配置/etc/php.ini文件
添加cgi.fix_pathinfo=0
原因http://www.laruence.com/2010/05/20/1495.html 配置/etc/php-fpm.d/www.conf
user = nginx group = nginx
重启服务
# systemctl restart php-fpm
MySQL
编辑配置文件/etc/my.cnf
若有skip-grant-tables,需要将其注释掉
Nginx
配置/etc/nginx/conf.d/default.conf
server { listen 80; server_name test.web.com; charset utf8; location / { root /var/www/html; index index.php index.html index.htm; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ .php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name; include fastcgi_params; } }
防火墙开放80端口
# firewall-cmd --zone=public --add-port=80/tcp --permanent # systemctl stop firewalld.service # systemctl start firewalld.service
- 测试nginx和php
添加/var/www/html/index.html
<h1> <span> hello, world. </span> </h1>
添加/var/www/html/phpinfo.php
<?php phpinfo(); ?>
访问index.html
在浏览器中打开http://ip/, 若出现“hello, world.”则成功访问phpinfo.php
在浏览器中打开http://ip/phpinfo.php, 若出现php信息则成功
以上是关于LNMP的主要内容,如果未能解决你的问题,请参考以下文章