溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

centos7如何利用yum安裝lnmp

發(fā)布時(shí)間:2021-05-31 12:30:19 來源:億速云 閱讀:142 作者:小新 欄目:服務(wù)器

這篇文章主要介紹centos7如何利用yum安裝lnmp,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

步驟如下:

yum的安裝

yum update

yum安裝nginx

安裝nginx最新源

yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum repolist enabled | grep "nginx*"

安裝nginx

yum -y install nginx

啟動(dòng)nginx

service nginx start

設(shè)置nginx服務(wù)器開機(jī)自啟動(dòng)

systemctl enable nginx.service

檢查開機(jī)自動(dòng)是否設(shè)置成功

systemctl list-dependencies | grep nginx

瀏覽器中輸入公網(wǎng)ip,檢測(cè)是否安裝成功

http://00.00.00.00/

使用yum安裝mysql5.7

安裝mysql源

yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"

安裝mysql

yum -y install mysql-community-server install mysql-community-devel

啟動(dòng)mysql

service mysqld start

檢查mysql啟動(dòng)是否正常

service mysqld status 或者 ps -ef | grep mysql

設(shè)置mysqld服務(wù)開機(jī)自啟動(dòng)

systemctl enable mysqld.service

檢查mysqld開機(jī)自啟動(dòng)是否設(shè)置成功

systemctl list-dependencies | grep mysqld

mysql5.7以后的爭(zhēng)強(qiáng)了安全機(jī)制, 所以使用yum安裝,啟動(dòng)會(huì)系統(tǒng)會(huì)自動(dòng)生成一個(gè)隨機(jī)的密碼,修改mysql密碼

查看mysql的隨機(jī)密碼

grep 'temporary password' /var/log/mysqld.log

使用查詢得到的隨機(jī)密碼在終端登錄

mysql -u root -p 更改密碼(mysql文檔規(guī)定,密碼必須包括大小寫字母數(shù)字加特殊符號(hào)>8位)
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Yourpassword';

退出mysql客戶端,用剛才修改的密碼登錄確保密碼修改成功

exit;
mysql -u root -p

安裝php7.1

安裝php源

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 repolist enabled | grep "webtatic*"

安裝php擴(kuò)展源

yum -y install php71w php71w-fpm
yum -y install php71w-mbstring php71w-common php71w-gd php71w-mcrypt
yum -y install php71w-mysql php71w-xml php71w-cli php71w-devel
yum -y install php71w-pecl-memcached php71w-pecl-redis php71w-opcache

驗(yàn)證php7.1.x和擴(kuò)展是否安裝成功

驗(yàn)證php是否安裝成功

php -v

驗(yàn)證對(duì)應(yīng)的擴(kuò)展是否安裝成功

php -m

設(shè)置php-fpm并檢測(cè)php-fpm的運(yùn)行狀態(tài)

啟動(dòng)php-fpm

service php-fpm star

檢查啟動(dòng)是否成功

service php-fpm status

設(shè)置開機(jī)自啟動(dòng)

systemctl enable php-fpm.service

檢查開機(jī)自啟動(dòng)是否設(shè)置成功

systemctl list-dependencies | grep php-fpm
ps -ef | grep php-fpm

nginx配置如下:

server{
 listen  80;
 server_name youserver;
 index index.html index.php;
 root /home/public;
 #charset koi8-r;
 #access_log logs/host.access.log main;
 location / {
  index index.html index.htm index.php;
  try_files $uri $uri/ /index.php?$query_string;
  }
 error_page 404    /404.html;
 # redirect server error pages to the static page /50x.html
 #
 error_page 500 502 503 504 /50x.html;
 location = /50x.html {
  root html;
 }
 # proxy the PHP scripts to Apache listening on 127.0.0.1:80
 #
 #location ~ .php$ {
 # proxy_pass http://127.0.0.1;
 #}
 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
 #
 location ~ .php$ {
  root   /home/public;
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME /home/public$fastcgi_script_name;
  include  fastcgi_params;
}
 # deny access to .htaccess files, if Apache's document root
 # concurs with nginx's one
 #
 location ~ /.ht {
  deny all;
 }
}

以上是“centos7如何利用yum安裝lnmp”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI