这里写自定义目录标题
安装php
(1)首先执行如下命令安装 EPEL 源及源管理工具
yum install epel-release yum-utils
(2) 安装remi源
Remi 软件源:主要提供最新版的 PHP 软件包和其他一些 PHP 扩展工具包,它是针对 Fedora 和 RHEL 系分支变体 (包括:RHEL、CentOS、Oracle Linux 等等) 要安装 PHP,推荐使用 Remi 软件源。Remi 对 PHP 的支持和更新都很积极,可以在第一时间获得新版本的支持。
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
(3)安装 PHP7.3 及扩展
yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-pecl-swoole php73-php-recode php73-php-snmp php73-php-soap php73-php-xmll
(4) 查看 PHP 版本
php73 -v
(5)将 php73 链接到系统环境变量中,就可以使用 php -v
ln -s /opt/remi/php73/root/usr/bin/php /usr/bin/php
(6) 启动 php-fpm,并且将其设置为开机自启动
systemctl enable php73-php-fpm
systemctl start php73-php-fpm
(7) 常用命令
systemctl restart php73-php-fpm //重启
systemctl stop php73-php-fpm //关闭
systemctl status php73-php-fpm //检查状态
(8) 编辑 php.ini 文件
vi /etc/opt/remi/php73/php.ini
找到 memory_limit 一行,将其改成 512M
然后将 cgi.fix_pathinfo 前面的注释(;)去掉,并将值设置为 0
(9) 编辑 www.conf
vi /etc/opt/remi/php73/php-fpm.d/www.conf
将 user 和 group 的值都改成 nginx
(10) 创建 nginx 用户
groupadd nginx
useradd -g nginx nginx
vi /usr/local/nginx/conf/nginx.conf
去掉 user 注解,将其值改成 nginx
(11)配置nginx
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
#设定通过nginx上传文件的大小
client_max_body_size 100m;
#gzip on;
#gzip模块设置
gzip on; #开启gzip压缩输出
gzip_min_length 1k; #最小压缩文件大小
gzip_buffers 4 16k; #压缩缓冲区
gzip_http_version 1.0; #压缩版本(默认1.1,前端如果是squid2.5请使用1.0)
gzip_comp_level 2; #压缩等级
gzip_types text/plain application/x-javascript text/css application/xml; #压缩类型,默认就已经包含textml,所以下面就不用再写了,写上去也不会有问题,但是会有一个warn。
gzip_vary on;
server {
listen 8083;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /www/wwwroot/web/;
index index.php;
include rewrite.conf;
}
location ~ \.php$ {
root /www/wwwroot/web/;
fastcgi_pass 127.0.0.1:8055;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#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 html;
}
}
}
rewrite.conf 里面是伪静态化配置