豪翔天下

Change My World by Program

0%

LEMP: Linux, Nginx, MySQL, PHP-FPM环境

LEMP: Linux, Nginx, MySQL, PHP环境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 依赖安装
yum install epel-release gcc automake autoconf libtool make gcc gcc-c++ glibc-y

# MySQL
yum install mysql-server -y
/etc/init.d/mysqld restart
/usr/bin/mysql_secure_installation # 初始化设置数据库

# Nginx
yum install nginx -y
/etc/init.d/nginx start

# PHP
add-apt-repository universe && apt-get install php-fpm php-mysql # for ubuntu
yum install php-fpm php-mysql # for centos
vim /etc/php.ini,将cgi.fix_pathinfo=1改为cgi.fix_pathinfo=0
vim /etc/php-fpm.d/www.conf将apache用户更改为nginx用户
user = nginx
group = nginx

service php-fpm restart # 如果php-fpm: unrecognized service,可以在/usr/lib/systemd/system/目录下看具体的服务名
service nginx restart

# 开机启动
systemctl enable mysqld
systemctl enable php-fpm
systemctl enable nginx

# 老版本使用这个命令
chkconfig --levels 235 mysqld on
chkconfig --levels 235 nginx on
chkconfig --levels 235 php-fpm on

nginx配置php-fpm

  • 如果发现9000端口没有启动那么php-fpm应该是以socket的方式启动的
1
2
3
4
5
6
7
8
location ~ \.php$ {    
fastcgi_pass 127.0.0.1:9000; # 端口方式
fastcgi_pass unix:/run/php/php7.0-fpm.sock; # socket方式

fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
坚持原创技术分享,谢谢支持

欢迎关注我的其它发布渠道