安装了nginx再安装php的方法:首先通过“yum install php php-fpm”安装PHP和PHP-FPM;然后启动php-fpm;接着将PHP与mysql模块关联起来;最后配置nginx与php一起工作即可。
php入门到就业线上直播课:进入学习
Apipost = Postman + Swagger + Mock + Jmeter 超好用的API调试工具:点击使用
本文操作环境:centOS6.8系统、PHP7.1版,DELL G3电脑
安装了nginx怎么安装php?
安装PHP和PHP-FPM
yum install php php-fpm
登录后复制
启动php-fpm
systemctl start php-fpm
登录后复制
将PHP与mysql模块关联起来
此处是mariadb数据库
安装
yum install mariadh mariadb-server
登录后复制
关联
yum install php-gd php-mysql php-mbstring php-xml php-mcryptphp-imap php-odbc php-pear php -xmlrpc
登录后复制
配置nginx与php一起工作
打开nginx主配置文件。
vim /etc/nginx/nginx.conf
登录后复制
在http模块中添加配置:
location / {root /usr/share/nginx/html; indexindex.html index.htm index.php;}location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_indexindex.php; fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name; includefastcgi_params; }
登录后复制
改动nginx默认的fastcgiparams配置文件: vim /etc/nginx/fastcgi_params 在文件的最后增加两行:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_param PATH_INFO$fastcgi_script_name;
登录后复制
然后重启一下服务:
service nginx restartservice php-fpm restart
登录后复制
运行
在网站根目录创建一个index.php文件
文件内容如下:
<?phpphpinfo();?>
登录后复制
提示nginx中yum安装的默认网站根目录在/usr/share/nginx/html
故此在此文件夹下新建文件
正常情况下就可以运行并访问php文件了。
推荐学习:《PHP视频教程》
以上就是安装了nginx怎么安装php的详细内容,更多请关注php中文网其它相关文章!