日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

[腾讯云]简单在腾讯云 CenTOS7.0 安装Nginx,Mysql(MariaDB),Memcache,解析PHP!

發(fā)布時(shí)間:2025/6/17 数据库 52 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [腾讯云]简单在腾讯云 CenTOS7.0 安装Nginx,Mysql(MariaDB),Memcache,解析PHP! 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1、安裝LNMP之前要安裝EPEL,以便安裝源以外的軟件,如Nginx,phpMyAdmin等。

  yum install epel-release

2、安裝Nginx

  a) yum install nginx
  b) systemctl start nginx #啟動(dòng)nginx systemctl stop nginx
  c) systemctl enable nginx #設(shè)置開機(jī)啟動(dòng)

  /usr/share/nginx/html. 解析頁(yè)面目錄

  /etc/nginx/nginx.conf nginx配置文件

  ###現(xiàn)在已經(jīng)可以解析.html文件啦!還想解析PHP文件需要安裝PHP,然后修改nginx 配置文件

3?進(jìn)入nginx 配置目錄,復(fù)制nginx配置文件nginx.conf ,以留備份,防止改錯(cuò)!

  修改配置文件如下!

  server {

    ?listen?????? 80;????? ?
???     server_name? server_domain_name_or_IP;
???   location / {
??????????   root?? /usr/share/nginx/html;
??????????   index? index.php index.html index.htm;????? ?
??  ? }???????? ?
???   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?? /usr/share/nginx/html;????? ?
???   }???? ?
???   # 更改上方面location /? 直接把下方替換上方的就可以,或者直接加載server里也行!
???   location ~ \.php$ {????????? ?
?? ???   ?  root?????????? /usr/share/nginx/html;????????? ?
?? ???     try_files $uri =404;????????? ?
?? ??? ?    fastcgi_pass?? 127.0.0.1:9000;????????? ?
?? ???     fastcgi_index? index.php;????????? ?
?? ??? ?    fastcgi_param? SCRIPT_FILENAME? $document_root$fastcgi_script_name;????????? ?
?? ???   ?  include??????? fastcgi_params;????? ?
??    }

   }

?  改完配置文件記得重啟nginx!

1、安裝PHP  

  yum install -y php php-devel php-fpm php-mysql php-common php-devel php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring   php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel

  老規(guī)矩:直接復(fù)制!

2、開啟php-fpm

  a) systemctl start php-fpm #開啟php-fpm
  b) systemctl enable php-fpm #開機(jī)自動(dòng)啟動(dòng)

?

這樣Nginx基本實(shí)現(xiàn)可以解析PHP!

?

?

下面安裝MYSQL

1、安裝MYSQL(MariaDB)

  安裝LNMP方式,CentOS7下MYSQL已經(jīng)被Mariadb替代,這個(gè)無(wú)所謂,完全兼容的!

  (MariaDB 是一個(gè)采用Aria存儲(chǔ)引擎的MySQL分支版本,是由原來(lái) MySQL 的作者M(jìn)ichael Widenius創(chuàng)辦的公司所開發(fā)的免費(fèi)開源的數(shù)據(jù)庫(kù)服務(wù)器)

?  ( LAMP架構(gòu)盛極一時(shí),這離不開MySQL的免費(fèi)與易用,但是在Oracle收購(gòu)了Sun之后,很多公司開始擔(dān)憂MySQL的開源前景,而最近Oracle進(jìn)一步閉源的舉措更是讓人難以安  心,眾多互聯(lián)網(wǎng)公司紛紛開始尋求MySQL的替代方案。)

  a) yum install mariadb-server mariadb

  b) systemctl start mariadb #啟動(dòng)mariadb

  c) systemctl enable mariadb #設(shè)置開機(jī)啟動(dòng)

2、設(shè)置MariaDB密碼

  mysql_secure_installation

   #會(huì)要求輸入原密碼,直接點(diǎn)擊回車就行,剩下的就是輸入新密碼以及確認(rèn)密碼

  #其他配置(了解一下就好)

  Remove anonymous users? [Y/n] <– 是否刪除匿名用戶,回車

  Disallow root login remotely? [Y/n] <–是否禁止root遠(yuǎn)程登錄,回車,

  Remove test database and access to it? [Y/n] <– 是否刪除test數(shù)據(jù)庫(kù),回車

  Reload privilege tables now? [Y/n] <– 是否重新加載權(quán)限表,回車

3、測(cè)試是否成功

  mysql -u用戶名 -p密碼

  進(jìn)入就OK啦!

  show databases;

?

?

linux 安裝memcache

?

1、查找Memcached

  yum search memcached

2、安裝memcache和PHP相關(guān)擴(kuò)展

  yum -y install –enablerepo=rpmforge memcached php-pecl-memcache

3、驗(yàn)證安裝?

  memcached -h #應(yīng)該會(huì)輸出一些幫助信息

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

  chkconfig memcached on

5、啟動(dòng)memcached

  service memcached start

  或者找到目錄的啟動(dòng)/bin/systemctl start memcached.service

6、測(cè)試服務(wù)端是否安裝成功

  php -m|grep memcache

  #查看端口號(hào)  

  lsof -i tcp:11211 #如果提示lsof not found,使用yum install lsof即可

?

7、接下來(lái)加載php memcache擴(kuò)展
  找到php配置文件,一般使用yum默認(rèn)安裝在etc/目錄下,如果沒找到可以建立一個(gè)文件輸出phpinfo搜索Configuration File可以查看到php.ini文件位置

?

  開啟memcache擴(kuò)展

  extension=/usr/lib64/php/modules/memcache.so,

  重啟php服務(wù)

  service php-fpm restart

8、檢測(cè)php擴(kuò)展是否安裝ok

  在輸出phpinfo頁(yè)面搜索memache,可查看到memcache擴(kuò)展

9、新建mem.php,輸入如下代碼:

  #去頁(yè)面加載文件夾建一個(gè)新文件

  <?php
  $mem = new Memcache;
  $mem->connect("127.0.0.1", 11211);
  $mem->set('key', 'This is a test, Hello World!--Pc.Lee', 0, 0);
  $val = $mem->get('key');
  echo $val;
  ?>

10、在地址欄運(yùn)行文件

  This is a test, Hello World!--Pc.Lee #頁(yè)面顯示這個(gè)輸出內(nèi)容就OK啦!

?

轉(zhuǎn)載于:https://www.cnblogs.com/lipcblog/p/6476258.html

總結(jié)

以上是生活随笔為你收集整理的[腾讯云]简单在腾讯云 CenTOS7.0 安装Nginx,Mysql(MariaDB),Memcache,解析PHP!的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。