别着急,坐和放宽
yum install yum-utils -y
# 添加openresty的repo
yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
yum install openresty -y
Nginx目录:/usr/local/openresty/nginx/
配置文件 /usr/local/openresty/nginx/conf/nginx.conf
worker_processes 1; # nginx worker进程数,如果用户量大,需要增加,建议和CPU逻辑核心数相同
events {
worker_connections 1024; # 每个worker进程能支持的并发连接数
}
http {
# http的统一配置,对所有server生效
# 一般最多会修改日志格式
server { # 每个服务的配置
listen 80; # 监听端口
server_name localhost; # 域名,多域名可以配置为某个域名监听某个端口
charset utf-8; # 页面呈现编码
location / { # 定义URL
root html; # 网站根目录
index index.php index.html index.htm;
}
}
}
一般修改完配置文件,需要做语法检查
nginx -t
启动nginx
nginx
# 修改配置文件后
nginx -s reload
server {
listen 80;
server_name www.servera.com;
location / {
root html/servera;
index index.html;
}
}
server {
listen 80;
server_name www.serverb.com;
location / {
root html/serverb;
index index.html;
}
}
测试时,可以暂时使用/etc/hosts
文件进行临时域名解析。
192.168.74.11 www.servera.com www.serverb.com
修改数据库默认编码
启动数据库
启动php-fpm
yum install mariadb mariadb-server -y
vi /etc/my.cnf
# 在[mysqld]下添加
character_set_server=utf8
init_connect='SET NAMES utf8'
systemctl start mariadb
yum install php-fpm php-mysql -y
systemctl start php-fpm
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
vi /usr/local/openresty/nginx/html/index.php
<?php
phpinfo();
?>