标签: lnmp

  • 阿里云服务器CentOS6下搭建LNMP环境

    以下步骤在阿里云ECS服务器中完成:

    1、安装及启动nginx

    输入yum install nginx命令进行nginx的安装,当需要确认时输入”y“确认。

    输入service nginx start启动nginx服务。

    输入wget http://127.0.0.1测试nginx服务。

    2、 安装PHP及相应组件

    输入yum install php php-fpm命令进行PHP的安装,当需要确认时输入”y“确认。

    输入service php-fpm start启动php-fpm服务,并使用命令cat /etc/php-fpm.d/www.conf |grep -i ‘listen =’查看php-fpm配置,可见php-fpm的默认配置的监听端口为9000,现在需要修改配置将php解析的请求转发到127.0.0.0:9000处理即可。

    使用命令nginx -t查找nginx配置文件,并使用vi命令修改该配置文件:vi /etc/nginx/nginx.conf
    在配置文件中找到以下片段,修改红色部分。

    server {
      listen       80;
      root   /usr/share/nginx/html;
      server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

      location / {
          index  index.html index.htm;
      }

    #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;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
      location ~ \.php$ {
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index   index.php;
          fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
          include        fastcgi_params;
      }

    }

    修改后wq保存退出,输入service nginx restart重启nginx服务。

    3、安装mysql及相应组件

    输入yum install mysql mysql-server命令进行mysql的安装,当需要确认时输入”y“确认。

    输入service  mysqld start启动mysql服务。

    输入mysqladmin -u root password 123456

    输入mysql -u root -p 123456登陆mysql。