centos7.7怎样安装php7.3的lnmp环境和composer
创始人
2024-11-24 13:05:47
0次

1.更新源
  yum update
2.安装nginx
  yum install nginx
3.启动nginx
  service nginx start
4.访问http://你的ip

  如果想配置域名,见最下面。

5.安装mysql:

安装mysql源  yum localinstall  http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
安装:       yum install mysql mysql-server
启动:       /etc/init.d/mysqld start   或者  service mysqld restart

重置密码:mysql -u root -p
几率报错 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
原因:权限问题
解决:  sudo chown -R root:root /var/lib/mysql (两个root都可以改为拥有者,但是需要保持一致)
重启服务
service mysqld restart

登陆mysql
mysql -u root -p  //按回车直接可以登陆,刚安装完mysql是没有密码的
修改mysql密码

  use mysql;
  低版本修改:update user set password=password('你的密码') where user='root';

    高版本修改:update user set authentication_string = password('你的密码'), password_expired = 'N', password_last_changed = now() where user = 'root';
        alter user 'root'@'localhost' identified by '你的密码';
  如果说密码强度不够,可以查看密码级别:SHOW VARIABLES LIKE "%password%";
  然后设置为低级别:SET GLOBAL validate_password_policy=0;
  最后退出;
  exit;
  重启    service mysqld restart
  允许远程访问
  1.必要时加入以下命令行,为root添加远程连接的能力。链接密码为'你的密码'
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你的密码' WITH GRANT OPTION;
    FLUSH PRIVILEGES;

  2.打开my.cnf文件
    添加一行 bind-address=0.0.0.0
  3.重启mysql

6.安装php
  yum install php php-devel //php5.6版本
  如果想安装7.3
  首先安装 EPEL 源

  1.yum install epel-release    //安装 EPEL 源
  2.yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm   //安装 REMI 源
  3.yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xml

    4.PHP的安装目录/etc/opt/remi/php73/   php.ini也在里面
    找到php.ini 里面fix_pathinfo 修改成0  但是不能看phpinfo();

      操作

    systemctl restart php73-php-fpm #重启
    systemctl start php73-php-fpm #启动
    systemctl stop php73-php-fpm #关闭
    systemctl status php73-php-fpm #检查状态

7.最后在yum update 更新php资源 方便以后更新扩展用

8.安装composer
  curl -sS https://getcomposer.org/installer | php73
  mv composer.phar /usr/local/bin/compose
r
  这样输入composer会报错 :/usr/bin/env: php: No such file or directory
  解决方法
  cd usr/bin
  cp php73 php

  在输入composer就好了

    更改镜像为阿里云:composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

9.安装git
  yum -y install git

10.下载laravel框架
  composer create-project --prefer-dist laravel/laravel 项目名称 "6.*"

composer create-project --prefer-dist laravel/laravel laravelxs "6.*"

  修改composer文件。

 cd /root/.config/composer/
  vi auth.json
  {
    "bitbucket-oauth": {},
    "github-oauth": {},
    "gitlab-oauth": {},
    "gitlab-token": {
      "github.com": "在git上生成的token"
    },
    "http-basic": {},
    "bearer": {}
  }

  添加
  "github.com": "在git上生成的token"

11.nginx域名的配置

  创建文件:域名.conf

  里面的内容:

server{
  listen 80;
  server_name 你的域名;
  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;
  index index.html index.htm index.php;
  root  你的项目目录;

  location / {
    try_files $uri $uri/ /index.php$is_args$args;
  }
  location ~ .*\.(php|php5)?$
  {
    #fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_connect_timeout 180;
    fastcgi_read_timeout 600;
    fastcgi_send_timeout 600;
    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;
  }
  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  {
    expires 30d;
  }
  location ~ .*\.(html|htm|js|css)?$
  {
    expires 8h;
  }
}

相关内容

热门资讯

空调连续工作多久需要停机休息 空调连续工作的时间取决于多个因素,包括空调的型号、功率、使用环境和维护情况等。一般来说,空调可以连续...
空调哪个符号是除湿的 空调除湿功能通常用一个水滴形状的符号表示。不同品牌和型号的空调遥控器可能会有所差异,但一般来说,除湿...
格力空调多长时间加一次氟利昂 1、一般情况下,空调对氟利昂的使用量是非常小的,所以在空调使用了四年左右的时候再考虑加也没问题。2、...
空调用多长时间需要加氟一次 一般情况下是五年。当出现以下这几种情况时,空调才需要加氟。1、空调的室内机和室外机各有两个接口,当接...
格调生活·C标思享荟:卡萨帝在... 9月12日的郑州龙湖金融岛,夜风轻拂,灯光璀璨。“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑...
品牌价值破千亿、高端份额持续领... 9月12日,“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑州站”在郑州龙湖金融岛举办。2026...
空调主板坏了修800还是换新的 空调主板坏了是修还是换新,需要考虑多个因素,以下是一些建议:1. 维修成本:如果维修费用较低,比如 ...
空调开多久需要休息多长时间 问题:空调开多久需要休息多长时间回答:1、在使用空调的过程中,一般空调开7~8个小时左右需要休息2~...
中央空调多长时间清洗一次 1、一般空调开机前清洗一次即可,空调开机中间时段再清洗一次,空调关机时清洗一次,这样比较合理。2、空...
中央空调氟利昂多久加一次 看空调制热和制冷程度,很多人的观点认为氟利昂必须一年放一次,其实这个观点是错误的,理解上面有点偏差,...