亲手搭建LNMP阿里云CentOS7.3

 

1.关闭防火墙和SELinux的的
关闭防火墙命令:

[root @ localhost~] #systemctl stop firewalld.service

查询防火墙状态:

[root @ localhost~] #systemctl status firewalld.service

状态为:

[root @ localhost~] #vim / etc / sysconfig / selinux
找到SELINUX =强制执行强制改为禁用 

禁用SELinux命令:
[root @ localhost~] #setenforce 0

2.安装nginx
wget下载安装nginx包

[root @ localhost~] #wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
建立nginx的yum仓库

[root @ localhost~] #rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

[root @ localhost~]
#yum install -y nginx [root @ localhost~] #systemctl start nginx.service

然后在浏览器中输入你服务器的IP如下为nginx的的安装成功:

3.安装MySQL的
下载回购资源

[root @ localhost~] #wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

或者使用另一个地址:wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

安装的MySQL的社区释放,el7-5.noarch.rpm

[root @ localhost~] #rpm -ivh mysql-community-release-el7-5.noarch.rpm
安装mysql&设置用户权限&重启

[root @ localhost~] #yum -y install mysql-community-serve

[root @ localhost~] #sudo chown -R root:root / var / lib / mysql
[root @ localhost~] #systemctl restart mysql.service


登陆MySQL,修改密码(可以先不操作此项,待所有安装完成后自行设置)

[root @ localhost~] #mysql -u root
mysql>使用mysql;
mysql>设置'root'的密码@'localhost'=密码('password');

mysql> flush privilgegs;

检测的MySQL的版本

mysql> status;
mysql> exit;

4.PHP7安装
转安装的PHP相应的荫资源

[root @ localhost~] #rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root @ localhost~] #rpm -Uvh https:// mirror .webtatic.com / grace / EL7 / webtatic-release.rpm

[root @ localhost~] #yum install -y php70w
查看PHP是否安装及版本:

[root @ localhost~] #php -v


安装扩展

[root @ localhost~] #yum install -y php70w-mysql.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64


5.安装php fpm

[root @ localhost~] #yum install -y php70w-fpm

修改配置
** 
nginx配置文件修改:可以直接在nginx.conf修改,怕修改坏的,

自己可备份一个nginx的的,的的conf文件命令:

cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bk

然后编辑nginx.conf

[root @ localhost~] #vim /etc/nginx/nginx.conf

然后把以下文件粘贴进去,改代码里2个中文的注意点就可以了


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    #tcp_nodelay on;
  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 128k;
  fastcgi_buffers 4 128k;
  fastcgi_busy_buffers_size 256k;
  fastcgi_temp_file_write_size 256k;

  #gzip  on;
  gzip on;
  gzip_min_length  1k;
  gzip_buffers     4 32k;
  gzip_http_version 1.1;
  gzip_comp_level 2;
  gzip_types       text/plain application/x-javascript text/css application/xml;
  gzip_vary on;
  gzip_disable "MSIE [1-6].";

  server_names_hash_bucket_size 128;
  client_max_body_size     100m; 
  client_header_buffer_size 256k;
  large_client_header_buffers 4 256k;



server {
        listen       80;
        server_name  www.bzydm.vip(改成自己的域名);

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        root    "/www/bzydm"(改成自己网站代码的目录);
        location / {
            index  index.html index.htm index.php l.php;
           autoindex  off;
        }

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

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # 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_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }



    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

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


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

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

	#include vhosts.conf;

}

然后检查是否该正确
[root @ localhost~] #nginx -t
修改php-fpm配置文件

[root @ localhost~] #vim /etc/php-fpm.d/www.conf
找到修改成这样
    user = nginx
group = nginx
测试
在自己设定的root目录下新建一个测试文件(我自己设置的是在/目录下的:/www/bzydm/index.html)

echo'hello“;

启动服务器

[root @ localhost~] #systemctl start nginx.service
查看服务器状态

[root @ localhost~] #systemctl status nginx启动PHP-FPM

[root @ localhost~] #systemctl start  php-fpm.service
[root @ localhost~] #systemctl status php-fpm.service在浏览器输入自己的域名就OK了!

成功。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值