Jason's Blog

因为需要部署ThinkPHP网站,所以就得在服务器上搭建LNMP网站环境,过程有点碱性,把中途遇到的坑记录下来。

资源下载

安装Nginx

再centos7中安装依赖

1
yum -y install gcc gcc-c++ make zlib-devel pcre-devel openssl-devel
1
wget http://nginx.org/download/nginx-1.17.0.tar.gz
1
./configure

default.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
server {
server_name your.domain;
listen 443; ##这里自己选择
ssl on;
ssl_certificate /etc/nginx/conf.d/SSL/SSL.pem;
ssl_certificate_key /etc/nginx/conf.d/SSL/SSL.key;
ssl_session_timeout 5m;
root "/usr/share/nginx/html/meme"; #网站目录
location / {
index index.html index.htm index.php;
#autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/meme$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED /usr/share/nginx/html/meme$fastcgi_path_info;
include fastcgi_params;
}
}

php.in

1
cgi.fix_pathinfo=1 ##760行左右

www.conf

1
2
3
4
5
6
7
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx

php-fpm.conf

1
include=/etc/php-fpm.d/*.conf #最后一行修改

安装PHP环境以及扩展程序

安装php以及php-fpm.

yum install php php-fpm -y

配置php-fpm支持nginx。

www.conf中将`user = apache; group = apache改成user = nginx; group = nginx`

php.ini中;cgi.fix_pathinfo=1改成cgi.fix_pathinfo=0

安装MySQL

测试

 评论

 无法加载Disqus评论系统,请确保您的网络能够正常访问。