本博客纯属本人编辑,如有雷同纯属巧合
一、安装mariadb、mariadb-server、nginx、php-fpm
yum install -y mariadb mariadb-server nginx php-fpm
等待安装完成,启动服务
**
二、编辑nginx配置文件
**
首先要在/目录下创建/www目录
[root@localhost ~]# cat /etc/nginx/fastcgi_params
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; //添加这行
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
[root@localhost ~]# cat /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /www; //修改为/www
index index.html index.htm index.php; // 添加index.php
}
#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 /www; //修改为/www
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;
#}
}
三、编辑PHP服务文件
[root@localhost ~]# cat /etc/php-fpm.d/www.conf | grep -n ^[a-zA-Z]
12:listen = 127.0.0.1:9000
24:listen.allowed_clients = 127.0.0.1
39:user = nginx
41:group = nginx
60:pm = dynamic
70:pm.max_children = 50
75:pm.start_servers = 5
80:pm.min_spare_servers = 5
85:pm.max_spare_servers = 35
156:slowlog = /var/log/php-fpm/www-slow.log
219:php_admin_value[error_log] = /var/log/php-fpm/www-error.log
220:php_admin_flag[log_errors] = on
224:php_value[session.save_handler] = files
225:php_value[session.save_path] = /var/lib/php/session
四、启动数据库
- 创建表wordpress,然后查看
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| wordpress |
+--------------------+
4 rows in set (0.01 sec)
- 添加所有访问权限
MariaDB [(none)]> grant all privileges on *.* to 'root'@'%' identified by '000000';
Query OK, 0 rows affected (0.00 sec)
五、编辑网站文件内容,使其连接数据库
网页访问ip地址,进行注册登录
网页显示有服务未安装,自行安装即可