实战一:搭建lnmp及类小米等商业网站的实现
1、安装包,开启服务
yum -y install nginx mariadb-server php-fpm php-mysql
2、修改nginx的配置文件
(1)cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf 有个模板例子覆盖了配置文件
vim /etc/nginx/nginx.conf 修改下面几类
① user nobody; 使用用户 error_log /var/log/nginx/error.log info; 错误日志 ② events { worker_connections 65535; } ③ tcp_nopush on; tcp优化 tcp_nodelay on; gzip on; ④ server { listen 80; server_name xiaomi.along.com; 根据自己顺便写 root /data/web; 主站点的目录根 location / { index index.php index.html index.htm; } ⑤ location ~ \.php$ { 开启.php,配置文件有例子,只需去掉注释,修改一行即可 fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
systemctl restart nginx 重启服务,发现有warn