CentOS 安装 lnmp

12 篇文章 0 订阅

CentOS 7.3

Nginx

  • 添加yum源
    rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

  • 安装
    yum install -y nginx

  • 开启服务
    service nginx start

  • 设置开启启动
    systemctl enable nginx.service

php 7.2

  • 更改yum源
    rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

  • yum安装
    yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml

  • 开启php-fpm服务
    service php-fpm start

  • 开机启动php-fpm
    systemctl enable php-fpm.service

  • 卸载PHP
    yum remove php*

配置nginx

  • 阿里云申请免费ssl证书
    https://www.cnblogs.com/lxf1117/p/6650647.html

  • fastcgi_params添加一行
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

  • 配置域名,在conf.d目录中新建文件

server {
    listen 443;
    server_name your.hostname;
    ssl on;
    root /www;#项目目录
    index index.html index.htm index.php;
    ssl_certificate  /etc/nginx/cert/ancue.site/215087187650786.pem;
    ssl_certificate_key /etc/nginx/cert/ancue.site/215087187650786.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    location / {
        index index.html index.htm index.php;
    }

    location ~ \.(php|phar)(/.*)?$ {
        fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$;
        set $path_info $fastcgi_path_info;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
		        set $fastcgi_script_name2 $fastcgi_script_name;
        if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {
        set $fastcgi_script_name2 $1;
        set $path_info $2;
        }
    fastcgi_param PATH_INFO $path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name2;
    }
}

server {
    listen 80;
    server_name your.hostname;
    rewrite ^(.*)$ https://$host$1 permanent;
}

  • 重启nginx
    service nginx restart

Mysql 5.7

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server

service start mysqld 
systemctl enable mysqld .service
service mysqld status

# 查看初试密码
grep "password" /var/log/mysqld.log
  • 重置密码
    mysql -u root

ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2),原因是/var/lib/mysql的访问权限问题。下面的命令把/var/lib/mysql的拥有者改为当前用户:
chown -R openscanner:openscanner /var/lib/mysql
service mysqld restart

SET PASSWORD = PASSWORD('新密码');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;
quit;
重新使用新密码登陆
  • 配置远程登录mysql
	mysql -u root
	mysql > use mysql;
	mysql > select host, user, password from user;
	mysql > Grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
	mysql > flush privileges;    (运行此句才生效,或者重启MySQL)

如果还是不能远程登录,检查ESC安全组的入方向3306端口是否打开

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值