这篇文章主要介绍centos7.7怎样安装PHP7.3的lnmp环境和composer,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
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
r
mv composer.phar /usr/local/bin/compose
这样输入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.*"
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; } }
以上是“centos7.7怎样安装PHP7.3的lnmp环境和composer”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注编程之家行业资讯频道!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。