1.安装nginx
wget https://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.20.2-1.el7.ngx.x86_64.rpm
rpm -ivh nginx-1.20.2-1.el7.ngx.x86_64.rpm
systemctl start nginx
systemctl enable nginx
find / -name nginx
2.安装php7.4
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install -y php74-php-fpm php74-php-cli php74-php-bcmath php74-php-gd php74-php-json php74-php-mbstring php74-php-mcrypt php74-php-mysqlnd php74-php-opcache php74-php-pdo php74-php-pecl-crypto php74-php-pecl-mcrypt php74-php-pecl-geoip php74-php-recode php74-php-snmp php74-php-soap php74-php-xml php74-php-imagick php74-php-pecl-zip php74-php-redis php74-php-swoole
systemctl start php74-php-fpm
systemctl enable php74-php-fpm
cp /usr/bin/php74 /usr/bin/php
chmod +x /usr/bin/php
php -v
php -m
php -i
find / -name www.conf
/etc/opt/remi/php74/php-fpm.d/www.conf
vim /etc/opt/remi/php74/php-fpm.d/www.conf
结果如下
; Per pool prefix
; It only applies on the following directives:
; - 'access.log'
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or @php_fpm_prefix@) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool
; 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 user chosen to provide access to the same directories as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000
; Set listen(2) backlog.
; Default Value: 511
;listen.backlog = 511
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server.
; Default Values: user and group are set as the running user
; mode is set to 0660
;listen.owner = nobody
;listen.group = nobody
listen.mode = 0777
3.修改nginx的default.conf
vim /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
修改完成后重启nginx,然后在/usr/share/nginx/html下创建一个index.php的文件,里面加入echo phpinfo()的代码,操作如下
touch /usr/share/nginx/html/index.php
vim /usr/share/nginx/html.php
<?php
echo phpinfo();
然后在浏览器中输入服务器ip,就能查看服务器的php的配置信息。到此centos7的nginx+php7.4的安装,如果需要安装数据库,请查看centos安装apache+php7.4+mysql的环境中的mariadb部分。 剩下的就是针对不同的框架做不同的解析。
如果程序部署之后,打开报以下错误:
session_start(): open(/var/opt/remi/php74/lib/php/session/sess_pql5ks4ognp0scd9lkoriedi9m, O_RDWR) failed: Permission denied (13)
请进入到/var/opt/remi/php74/lib/php/ ,将session目录用户和组切换到nginx/apache ,根据你的当前的web服务使用的用户和组为准,并且给session目录可执行(+x)的权限
|