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

[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

猜你喜欢

转载自blog.csdn.net/h330531987/article/details/80645973