Centos7.4搭建lnmp环境

查看centos 版本

$ cat /etc/redhat-release

安装nginx

$ yum install nginx

设置nginx开机起动

$ systemctl start nginx

测试访问http://域名或IP/

浏览器可看到nginx 相关信息

查看nginx安装位置

$ sudo find / -name nginx

安装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 list php*查看是否有自己需要安装的版本,如果没有就需要添加第三方yum源

选择自己需要的php版本号 安装

$ yum install php72w-common

安装mysql

$ wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
$ rpm -ivh mysql-community-release-el7-5.noarch.rpm
$ yum install mysql-community-server

安装成功后重启mysql服务

$ service mysqld restart

设置MySQL密码

$ mysql -u root -p
$ set password for 'root'@'localhost' = password('yourpassword');
$ exit

安装php-fpm

搜索yum 源

$ sudo yum search php72

安装

$ yum install php72w-fpm

配置php处理器

$ vim /etc/php.ini

查找cgi.fix_pathinfo;cgi.fix_pathinfo=1改为cgi.fix_pathinfo=0

配置www.conf

$ vim /etc/php-fpm.d/www.conf		


user = nobody group = nobody
改为
user = nginx group = nginx

启动php-fom

$ systemctl start php-fpm

设置php-fpm 开机自启动

$ 设置php-fpm开机自启动	

配置nginx

修改service 部分如下

index index.php index.html index.htm;
server {
	listen 80 default_server;
	listen [::]:80 default_server;
		server_name _;
		root /data/www;
		# Load configuration files for the default server block.
		location ~ .php$ {
			try_files $uri =404;
				root /data/www;
				fastcgi_pass 127.0.0.1:9000;
				fastcgi_index index.php;
				fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
				include fastcgi.conf;
		}
		error_page 404 /404.html;
		location = /40x.html {
		}
		error_page 500 502 503 504 /50x.html;
		location = /50x.html {
		}
}
​include /etc/nginx/conf.d/*.conf;

重启nginx

$ systemctl restart nginx

浏览器输入ip,上面没出错情况下会出现phpinfo页面

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值