配置nginx支持PHP
1.cat /etc/nginx/conf.d/default.confcat default.conf把红色的字体添加server {listen 80;server_name localhost;#access_log /var/log/nginx/host.access.log main;location / {root /soft/code;index...
配置nginx支持PHP
1.
cat /etc/nginx/conf.d/default.conf
cat default.conf
把红色的字体添加
server {
listen 80;
server_name localhost;
#access_log /var/log/nginx/host.access.log main;
location / {
root /soft/code;
index index.php index.html index.htm;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /soft/code$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 /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
2.重启nginx
nginx -t
nginx -s reload
3.新建目录
mkdir -p /soft/code
vi /soft/code/info.php
<?php
phpinfo();
?>
4.浏览网页
http://192.168.137.18/info.php

5.开启mysql
service mysql start
mysql –uroot –p密码
如果忘记mysql密码 # grep 'temporary password' /data/mysql/data/error.log 进行查询
进入MySQL后
创建数据库
mysql> create database WordPres;
查看数据库
mysql>cat databases;
mysql>grant all on wordpress.* to’wpuser’@’locallhost’ identified by ‘password’
刷新权限
mysql>flush privileges
mysql>exit
原文件备份
cp wp-config-sample.php wp-config.php
编辑备份文件
#vi wp-config.php
define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wpuser' );
define( 'DB_PASSWORD', 'password' );
define( 'DB_HOST', '127.0.0.1' );
6.浏览网页
http://192.168.137.18/wordpress
然后就可以了
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)