开发者社区> 问答> 正文

安装lnmp,这个该如何添加进去?为什么我试了导致nginx服务无法重新启动:报错

安装lnmp,这个该如何添加进去?为什么我试了导致mysql服务无法重新启动

http://www.cnblogs.com/cuxnil/archive/2013/01/06/2847118.html

我是按照上面这个教程做,但是安装到这一步

4.1、修改nginx配置文件

# vi /etc/nginx/nginx.conf

更改网站的根目录,添加php默认文件:

复制代码
location / {
root /usr/share/nginx/html;
index  index.php index.html index.htm;
#启用伪静态规则,可以支持自定义链接和日志别名 if (!-e $request_filename)
{
 rewrite ^/(.+)$ /index.php last;
}
 } 
当我在nginx。conf中输入上面的内容,导致nginx服务无法重新启动了。请问上面的代码要怎么写?
我默认的nginx。conf是这样的
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user              nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    # Load config files from the /etc/nginx/conf.d directory
    # The default server is in conf.d/default.conf
    include /etc/nginx/conf.d/*.conf;

}

展开
收起
kun坤 2020-06-05 22:44:15 406 0
1 条回答
写回答
取消 提交回答
  • nginx: [emerg] unknown directive "location" in /etc/nginx/nginx.conf:44

    44行location这段~

    2020-06-05 22:44:20
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《Nginx 代理系统常用手册》 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载