centos7之yum安装lnmp
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7之yum安装lnmp相关的知识,希望对你有一定的参考价值。
安装LNMP之前要安装EPEL,以便安装源以外的软件,如nginx,phpMyAdmin等yum install epel-release -y
安装nginx
yum install nginx -y
systemctl start nginx
systemctl enable nginx
安装php
yum install -y php php-devel php-fpm php-mysql php-common php-devel php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel
systemctl start php-fpm
systemctl enable php-fpm
安装mysql
这里不介绍了,可以参考我的源码安装,或者yum安装在“系统监控”的zabbix教程里面有
添加nginx配置
[[email protected] ~]# cat /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name 10.0.40.245;
root /usr/share/nginx/html;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
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$ {
root /usr/share/nginx/html;
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;
}
}
重启nginx即可
测试php是否正常运行
[[email protected] ~]# cat /usr/share/nginx/html/index.php
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);
?>
web访问index.php
10.0.40.245/index.php
以上是关于centos7之yum安装lnmp的主要内容,如果未能解决你的问题,请参考以下文章