简单的LNMP环境配置
LNMP环境:
? L:linux
? N:nginx
? M:mysql
? P:php
Linux系统就没什么好说的了。这里是centos 7.6
nginx安装
yum -y install epel-release yum -y install nginx
PHP安装
yum -y install php php-fpm php-curl php-intl php-mcrypt php-mysql php-mbstring php-xml php-dom php-gd gd
nginx +PHP 环境配置
(nginx + php-fpm +fastcgi)
vim /etv/nginx/nginx.conf
location ~\.php$ { root /webroot/farm; fastcgi_pass 127.0.0.1:9000; #与php-fpm通信的方式 fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; 通信方式: nginx和php-fpm的通信方式有两种,一种是socket形式,一种是tcp形式。配置两种方式都可以,但是必须保证nginx配置的监听方式,和php-fpm.conf配置的监听方式保持一致性! 推荐使用TCP方式也就是方式1,可以跨服务器。 php配置:/etc/php-fpm.conf或者/etc/php-fpm.d/xx.conf 方式1: php-fpm.conf: listen = 127.0.0.1:9000 nginx.conf: fastcgi_pass 127.0.0.1:9000; 方式2: php-fpm.conf: listen = /tmp/php-fpm.sock nginx.conf: fastcgi_pass unix:/tmp/php-fpm.sock; 其中php-fpm.sock是一个文件,由php-fpm生成,类型是srw-rw----.
vim /etv/php.ini
#short_open_tag = off 改为如下: short_open_tag = on #打开短标签
上面配置完成就可以在nginx上部署php项目了。
安装mysql
[ ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm [ ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm [ ~]# vim /etc/yum.repos.d/mysql-community.repo [mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/ enabled=1 将0改为1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql80-community] name=MySQL 8.0 Community Server baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/ enabled=0 将1改为0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [ ~]# yum -y install mysql-server mysql
启动&开机启动
[ ~]# systemctl start nginx [ ~]# systemctl start mysqld [ ~]# systemctl start php-fpm [ ~]# systemctl enable nginx [ ~]# systemctl enable mysqld [ ~]# systemctl enable php-fpm
相关推荐
yifangs 2020-10-13
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23
savorTheFlavor 2020-10-23