码迷,mamicode.com
首页 > 其他好文 > 详细

centos7之yum安装lnmp

时间:2018-03-22 19:27:20      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:centos7   shell   nginx   php   

安装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配置

[root@jenkins ~]# 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是否正常运行

[root@jenkins ~]# 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);

?>

php官方文档

web访问index.php

10.0.40.245/index.php

centos7之yum安装lnmp

标签:centos7   shell   nginx   php   

原文地址:http://blog.51cto.com/yanconggod/2089950

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!