一条yum命令安装lnmp
侧边栏壁纸
  • 累计撰写 188 篇文章
  • 累计收到 24 条评论

一条yum命令安装lnmp

五好
2017-04-27 / 0 评论 / 1,016 阅读 / 正在检测是否收录...

操作系统:centos

yum  install  nginx php mysql php-fpm php-mysql php-gd php-curl

还可以根据应用需要用到的php模块做对应的调整,比如有点应用不支持php-mysql只支持php-pdo php-mysqli
设置自启

chkconfig --levels 235 nginx on
chkconfig --levels 235 mysqld on
chkconfig --levels 235 php-fpm on

然后可以把上面3个服务全部启动起来
修改mysql的root密码:

use mysql;update user set password=password('') where user='root';

接下来是配置nginx

server{
    listen      80;
    server_name www.abc.com;
    index index.html index.php ;
    root  /home/www/docroot;
    location ~ .*\.(php|php5)?$
    {
            #fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
    }
}

301:不带www的域名跳转到带www.配置

server
{
if ($host = 'abc.com'){
           rewrite ^/(.*)$ http://www.abc.com/$1 permanent;
        }
}

或者

server{
    server_name abc.com;
    return 301 $scheme://www.abc.com$request_uri;
}

禁止通过ip地址访问网站

server {
    listen       80;
    server_name  "";
    return       444;
}
0

评论 (0)

取消