這篇文章主要介紹centos7.7怎樣安裝php7.3的lnmp環(huán)境和composer,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
10多年的龍城網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。成都營(yíng)銷網(wǎng)站建設(shè)的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整龍城建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。成都創(chuàng)新互聯(lián)公司從事“龍城網(wǎng)站設(shè)計(jì)”,“龍城網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
1.更新源
yum update
2.安裝nginx
yum install nginx
3.啟動(dòng)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
啟動(dòng): /etc/init.d/mysqld start 或者 service mysqld restart
重置密碼:mysql -u root -p
幾率報(bào)錯(cuò) Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
原因:權(quán)限問題
解決: sudo chown -R root:root /var/lib/mysql (兩個(gè)root都可以改為擁有者,但是需要保持一致)
重啟服務(wù)
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 '你的密碼';
如果說密碼強(qiáng)度不夠,可以查看密碼級(jí)別:SHOW VARIABLES LIKE "%password%";
然后設(shè)置為低級(jí)別:SET GLOBAL validate_password_policy=0;
最后退出;
exit;
重啟 service mysqld restart
允許遠(yuǎn)程訪問
1.必要時(shí)加入以下命令行,為root添加遠(yuǎn)程連接的能力。鏈接密碼為'你的密碼'
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 #啟動(dòng) systemctl stop php73-php-fpm #關(guān)閉 systemctl status php73-php-fpm #檢查狀態(tài)
7.最后在yum update 更新php資源 方便以后更新擴(kuò)展用
8.安裝composer
curl -sS https://getcomposer.org/installer | php73
r
mv composer.phar /usr/local/bin/compose
這樣輸入composer會(huì)報(bào)錯(cuò) :/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
項(xiàng)目名稱 "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域名的配置
創(chuàng)建文件:域名.conf
里面的內(nèi)容:
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 你的項(xiàng)目目錄; 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環(huán)境和composer”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!