centos7安装部署LAMP、LNMP

系统信息

 

apache安装:

  yum install httpd -y

nginx安装:(源码安装:https://blog.csdn.net/w50feng/article/details/106048878

  yum install nginx -y

 

php安装:

  安装epel库:yum install epel-release -y

  安装webtatic库:rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

  查询php版本:yum search php

  下载php7.1:yum install php71w php71w-fpm php71w-cli php71w-common php71w-devel php71w-gd php71w-pdo php71w-mysql php71w-mbstring php71w-bcmath php71w-pecl-redis -y

 

mysql安装:

  yum install -y wget

  wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

  yum localinstall mysql57-community-release-el7-8.noarch.rpm -y

  yum install mysql-community-server -y

  启动mysql:systemctl start mysqld

  第一次登陆密码在日志文件查找:vim /var/log/mysqld.log

  使用查询到的密码登陆数据库:mysql -uroot -p

  修改root密码:ALTER USER 'root'@'localhost' IDENTIFIED BY 'Abc123!@#';(密码太简单报错1819)

 

验证LAMP:

  vim /var/www/html/phpinfo.php

  <?php phpinfo(); ?>

  启动http:systemctl start httpd

  浏览器访问:serverip/phpinfo.php(如果无法访问,检查防火墙端口是否放行)

 

验证LNMP:

  启动php-fpm:systemctl restart php-fpm

  配置nginx:vim /etc/nginx/nginx.conf

    server {
        listen       81 default_server;
        listen       [::]:81 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }

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

  配置端口为81,80上面httpd已经使用了,增加匹配php的location

  编辑测试文件:vim /usr/share/nginx/html/phpinfo.php

  <?php phpinfo(); ?>

  启动nginx:systemctl start nginx

  浏览器访问:serverip:81/phpinfo.php

 

 

-----------日常记录---------------

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值