摘要:安裝前準(zhǔn)備修改默認(rèn)主機(jī)名稱安裝依賴庫刪除系統(tǒng)默認(rèn)數(shù)據(jù)庫配置文件查詢刪除確認(rèn)卸載系統(tǒng)自帶查詢刪除安裝數(shù)據(jù)庫下載安裝包解壓創(chuàng)建數(shù)據(jù)庫安裝目錄,數(shù)據(jù)存放目錄,
安裝前準(zhǔn)備
修改默認(rèn)主機(jī)名稱
[root@iZuf60c5bxd15kr9gycvv6Z ~]# hostnamectl set-hostname centos [root@iZuf60c5bxd15kr9gycvv6Z ~]# reboot [root@iZuf60c5bxd15kr9gycvv6Z ~]# yum update
安裝依賴庫
[root@centos ~]# yum -y install libaio libaio-devel bison bison-devel zlib-devel openssl openssl-devel ncurses ncurses-devel libcurl-devel libarchive-devel boost boost-devel lsof wget gcc gcc-c++ make perl kernel-headers kernel-devel pcre-devel screen gcc-c++刪除系統(tǒng)默認(rèn)數(shù)據(jù)庫配置文件
查詢
[root@centos ~]# find -H /etc/ | grep my.c /etc/my.cnf /etc/my.cnf.d /etc/my.cnf.d/mysql-clients.cnf /etc/pki/tls/certs/renew-dummy-cert /etc/pki/tls/certs/make-dummy-cert
刪除
[root@centos ~]# rm -rf /etc/my.cnf /etc/my.cnf.d /etc/my.cnf.d/mysql-clients.cnf
確認(rèn)
[root@centos ~]# find -H /etc/ | grep my.c /etc/pki/tls/certs/renew-dummy-cert /etc/pki/tls/certs/make-dummy-cert卸載系統(tǒng)自帶mariadb-libs
查詢
[root@centos ~]# rpm -qa|grep mariadb-libs mariadb-libs-5.5.52-1.el7.x86_64
刪除
[root@centos ~]# rpm -e mariadb-libs-5.5.52-1.el7.x86_64 --nodeps安裝MariaDB數(shù)據(jù)庫
下載安裝包
[root@centos ~]# cd /usr/local/src [root@centos src]# wget https://downloads.mariadb.org/interstitial/mariadb-10.3.13/source/mariadb-10.3.13.tar.gz
解壓
[root@centos src]# tar -zxvf mariadb-10.3.13.tar.gz
創(chuàng)建數(shù)據(jù)庫安裝目錄,數(shù)據(jù)存放目錄,以及用戶組、用戶
# 創(chuàng)建mysql用戶組 [root@centos mariadb-10.3.13]# groupadd -r mysql # 創(chuàng)建mysql用戶 [root@centos mariadb-10.3.13]# useradd -r -g mysql -s /sbin/nologin -d /usr/local/mysql -M mysql # 創(chuàng)建安裝目錄 [root@centos mariadb-10.3.13]# mkdir -p /usr/local/mysql # 創(chuàng)建數(shù)據(jù)存放目錄 [root@centos mariadb-10.3.13]# mkdir -p /data/mysql # 賦以mysql用戶讀寫權(quán)限 [root@centos mariadb-10.3.13]# chown -R mysql:mysql /data/mysql
編譯安裝cmake3
[root@centos ~]# cd /usr/local/src [root@centos src]# wget https://github.com/Kitware/CMake/releases/download/v3.14.1/cmake-3.14.1.tar.gz [root@centos src]# tar -zxvf cmake-3.14.1.tar.gz [root@centos src]# cd cmake-3.14.1 [root@centos cmake-3.14.1]# ./bootstrap [root@centos cmake-3.14.1]# gmake [root@centos cmake-3.14.1]# gmake install
編譯安裝
[root@centos mariadb-10.3.13]# cd /usr/local/src/mariadb-10.3.13 # 輸入以下編譯參數(shù) cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DWITHOUT_TOKUDB=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STPRAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWIYH_READLINE=1 -DWIYH_SSL=system -DVITH_ZLIB=system -DWITH_LOBWRAP=0 -DMYSQL_UNIX_ADDR=/data/mysql/mysqld.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci # 如果編譯失敗請(qǐng)刪除CMakeCache.txt [root@centos mariadb-10.3.13]# rm -f CMakeCache.txt # 讓指令重新執(zhí)行,否則每次讀取這個(gè)文件,命令修改正確也是報(bào)錯(cuò) # cmake沒問題,可以編譯并且安裝了 # 開始安裝,這個(gè)過程比較久,跟據(jù)電腦配制不同可能會(huì)有10-30分鐘 [root@centos mariadb-10.3.13]# make && make install
導(dǎo)入mysql系統(tǒng)表
[root@centos mariadb-10.3.13]# cd /usr/local/mysql/ [root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mysql
復(fù)制配制文件
[root@localhost mysql]# cp /usr/local/mysql/support-files/wsrep.cnf /etc/my.cnf
編寫快捷啟動(dòng)腳本
[root@centos mysql]# vi /lib/systemd/system/mysql.service # -------------------------------------------------------------------------- # 輸入以下代碼 # -------------------------------------------------------------------------- [Unit] Description=MySQL Community Server After=network.target [Service] User=mysql Group=mysql Type=forking PermissionsStartOnly=true PIDFile=/data/mysql/centos.pid ExecStart=/usr/local/mysql/support-files/mysql.server start ExecReload=/usr/local/mysql/support-files/mysql.server restart ExecStop=/usr/local/mysql/support-files/mysql.server stop PrivateTmp=true [Install] WantedBy=multi-user.target
設(shè)置開機(jī)啟動(dòng)
[root@centos mysql]# systemctl enable mysql.service
其它命令說明
# 啟動(dòng)mysql [root@centos mysql]# systemctl start mysql.service # 停止mysql [root@centos mysql]# systemctl stop mysql.service # 重啟mysql [root@centos mysql]# systemctl restart mysql.service # 如果提示:Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details. # 請(qǐng)選結(jié)束mysql進(jìn)程后再嘗試執(zhí)行上面的快捷操作 [root@centos mysql]# pkill -9 mysql
配置環(huán)境變量(以便在任何目錄下輸入mysql命令)
# 創(chuàng)建獨(dú)立環(huán)境變量文件 [root@localhost mysql]# touch /etc/profile.d/mysql.sh # 寫入變量值 [root@localhost mysql]# echo "export PATH=$PATH:/usr/local/mysql/bin/" > /etc/profile.d/mysql.sh # 賦以執(zhí)行權(quán)限 [root@localhost mysql]# chmod 0777 /etc/profile.d/mysql.sh # 刷新生效 [root@localhost mysql]# source /etc/profile.d/mysql.sh
初始化MariaDB
# 運(yùn)行MariaDB初始化腳本 [root@localhost mysql]# ./bin/mysql_secure_installation # -------------------------------------------------------------------------- # 根據(jù)相關(guān)提示進(jìn)行操作 # 以下提示: # -------------------------------------------------------------------------- Enter current password for root (enter for none): 輸入當(dāng)前root密碼(沒有輸入) Set root password? [Y/n] 設(shè)置root密碼?(是/否) New password: 輸入新root密碼 Re-enter new password: 確認(rèn)輸入root密碼 Password updated successfully! 密碼更新成功 Remove anonymous users? [Y/n] 刪除匿名用戶?(是/否) Disallow root login remotely? [Y/n] 不允許root登錄遠(yuǎn)程?(是/否) Reload privilege tables now? [Y/n] 現(xiàn)在重新加載權(quán)限表(是/否) #全部完成!如果你已經(jīng)完成了以上步驟,MariaDB安裝現(xiàn)在應(yīng)該安裝完成。
創(chuàng)建外部管理員帳號(hào)(根據(jù)需要,請(qǐng)盡量保證密碼的復(fù)雜性避免數(shù)據(jù)庫外泄)
[root@localhost mysql] mysql -uroot -p # 根據(jù)提示輸入密碼 MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO "admin"@"%" IDENTIFIED BY "password" WITH GRANT OPTION;安裝NGINX
-下載安裝包并解壓
[root@localhost mysql]# cd /usr/local/src [root@localhost src]# wget http://nginx.org/download/nginx-1.14.2.tar.gz [root@localhost src]# tar -zxvf nginx-1.14.2.tar.gz
創(chuàng)建NGINX安裝目錄,WEB存放目錄,以及用戶組、用戶
# 創(chuàng)建nginx用戶組 [root@centos src]# groupadd -r www # 創(chuàng)建nginx用戶 [root@centos src]# useradd -r -g www -s /sbin/nologin -d /usr/local/nginx -M www # 創(chuàng)建安裝目錄 [root@centos src]# mkdir -p /usr/local/nginx # 創(chuàng)建數(shù)據(jù)存放目錄 [root@centos src]# mkdir -p /data/web # 賦以mysql用戶讀寫權(quán)限 [root@centos src]# chown -R www:www /data/web
-編譯安裝
[root@localhost src]# cd nginx-1.14.2 # 輸入以下參數(shù) ./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module # 如果看到以下說明則編譯成功 Configuration summary + using system PCRE library + using system OpenSSL library + using system zlib library nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx modules path: "/usr/local/nginx/modules" nginx configuration prefix: "/usr/local/nginx/conf" nginx configuration file: "/usr/local/nginx/conf/nginx.conf" nginx pid file: "/usr/local/nginx/logs/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp" # 開始安裝 [root@localhost nginx-1.14.2]# make && make install
嘗試啟動(dòng)
[root@centos nginx-1.14.2]# /usr/local/nginx/sbin/nginx # 如果未提示錯(cuò)誤即代表安裝成功
編寫快捷啟動(dòng)腳本
[root@centos nginx-1.14.2]# vi /lib/systemd/system/nginx.service # -------------------------------------------------------------------------- # 輸入以下代碼 # -------------------------------------------------------------------------- [Unit] Description=nginx After=network.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s quit PrivateTmp=true [Install] WantedBy=multi-user.target
設(shè)置開機(jī)啟動(dòng)
[root@centos nginx-1.14.2]# systemctl enable nginx.service
其它命令說明
# 啟動(dòng)nginx [root@centos nginx-1.14.2]# systemctl start nginx.service # 停止nginx [root@centos nginx-1.14.2]# systemctl stop nginx.service # 重啟nginx [root@centos nginx-1.14.2]# systemctl restart nginx.service # 如果提示:Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. # 請(qǐng)選結(jié)束nginx進(jìn)程后再嘗試執(zhí)行上面的快捷操作 [root@centos nginx-1.14.2]# pkill -9 nginx
修改配NGINX配制文件
[root@centos php-7.1.10]# cd /usr/local/nginx/conf [root@centos conf]# vi nginx.conf # 修改如下代碼 # -------------------------------------------------------------------------- #user nobody;去除前面#號(hào),并將用戶改為www www user www www; # -------------------------------------------------------------------------- #pid logs/nginx.pid; 去除前面的#號(hào) pid logs/nginx.pid; # -------------------------------------------------------------------------- 去除前面的#號(hào) 如下 log_format main "$remote_addr - $remote_user [$time_local] "$request" " "$status $body_bytes_sent "$http_referer" " ""$http_user_agent" "$http_x_forwarded_for""; # -------------------------------------------------------------------------- # gzip on;去除前面的#號(hào)并加上隱藏版號(hào)代碼 server_tokens off; # -------------------------------------------------------------------------- index index.html index.htm;后面加上index.php 默認(rèn)頁 index index.html index.htm index.php; # -------------------------------------------------------------------------- 去下以下前面的#號(hào)并做如下修改 location ~ .php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
最后張節(jié)介紹虛擬主機(jī)配制,以及memcache配制
安裝PHP7下載安裝包并解壓
[root@centos nginx-1.14.2]# cd /usr/local/src [root@centos src]# wget https://www.php.net/distributions/php-7.3.3.tar.gz [root@centos src]# tar -zxvf php-7.3.3.tar.gz
安裝必要的相關(guān)擴(kuò)展
[root@centos src]# yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
安裝libzip擴(kuò)展
[root@centos src]# wget https://libzip.org/download/libzip-1.5.2.tar.gz [root@centos src]# tar -zxvf libzip-1.5.2.tar.gz [root@centos src]# cd libzip-1.5.2 [root@centos libzip-1.5.2]# mkdir build && cd build && cmake .. && make && make install
-編譯安裝
[root@localhost src]# cd php-7.3.3 # 輸入以下參數(shù) ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-libxml-dir --with-xmlrpc --with-openssl --with-mhash --with-pcre-regex --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-jis-conv --with-gettext --with-gmp --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear --enable-pcntl --enable-opcache # 開始安裝 [root@localhost php-7.3.3]# make && make install
配置環(huán)境變量(以便在任何目錄下輸入php命令)
# 創(chuàng)建獨(dú)立環(huán)境變量文件 [root@localhost php-7.3.3]# touch /etc/profile.d/php.sh # 寫入變量值 [root@localhost php-7.3.3]# echo "export PATH=$PATH:/usr/local/php/bin/" > /etc/profile.d/php.sh # 賦以執(zhí)行權(quán)限 [root@localhost php-7.3.3]# chmod 0777 /etc/profile.d/php.sh # 刷新生效 [root@localhost php-7.3.3]# source /etc/profile.d/php.sh
配制php.ini
[root@centos php-7.3.3]# cp php.ini-production /usr/local/php/etc/php.ini [root@centos php-7.3.3]# vi /usr/local/php/etc/php.ini # 做以下修改(時(shí)區(qū),不顯示版本號(hào),開啟opcache緩存加速PHP) # -------------------------------------------------------------------------- 1.讓到memory_limit = 128M 修改為:memory_limit = 1024M(跟據(jù)服務(wù)器配制設(shè)置) 2.找到:;date.timezone = 修改為:date.timezone = PRC 3.找到:expose_php = On 修改為:expose_php = Off 4.找到:;opcache.enable=1 修改為:opcache.enable=1 5.找到:;opcache.enable_cli=0 修改為:opcache.enable_cli=1 6.在 Dynamic Extensions 代碼塊中添加 zend_extension=opcache.so
配置php-fpm
[root@centos php-7.3.3]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf [root@centos php-7.3.3]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf [root@centos php-7.3.3]# cp sapi/fpm/init.d.php-fpm /usr/local/php/bin/php-fpm [root@centos php-7.3.3]# chmod 0777 /usr/local/php/bin/php-fpm
嘗試啟動(dòng)
[root@centos php-7.3.3]# /usr/local/php/bin/php-fpm start Starting php-fpm done # 如提示以上即表示安裝成功
編寫快捷啟動(dòng)腳本
[root@centos php-7.3.3]# vi /lib/systemd/system/php-fpm.service # -------------------------------------------------------------------------- # 輸入以下代碼 # -------------------------------------------------------------------------- [Unit] Description=php-fpm After=network.target [Service] Type=forking PIDFile=/usr/local/php/var/run/php-fpm.pid ExecStart=/usr/local/php/bin/php-fpm start ExecReload=/usr/local/php/bin/php-fpm restart ExecStop=/usr/local/php/bin/php-fpm stop PrivateTmp=true [Install] WantedBy=multi-user.target
設(shè)置開機(jī)啟動(dòng)
[root@centos php-7.3.3]# systemctl enable php-fpm.service
其它命令說明
# 啟動(dòng)php-fpm [root@centos php-7.3.3]# systemctl start php-fpm.service # 停止php-fpm [root@centos php-7.3.3]# systemctl stop php-fpm.service # 重啟php-fpm [root@centos php-7.3.3]# systemctl restart php-fpm.service # 如果提示:Job for php-fpm.service failed because the control process exited with error code. See "systemctl status php-fpm.service" and "journalctl -xe" for details. # 請(qǐng)選結(jié)束php-fpm進(jìn)程后再嘗試執(zhí)行上面的快捷操作 [root@centos php-7.3.3]# pkill -9 php-fpmNGINX虛擬主機(jī)配制
打開配制文件
[root@centos php-7.3.3]# vi /usr/local/nginx/conf/nginx.conf
在http{}節(jié)點(diǎn)尾加入以下代碼
############################################## #LIANGZHI ############################################## server { listen 80; server_name *.demo.com; root /data/web/demo/www; access_log /data/web/demo/log/access.log main; error_log /data/web/demo/log/error.log error; index index.php; #THINKPHP偽靜態(tài) location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } } #解析PHP代碼 location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } #靜態(tài)資源緩存1天 location ~ .*.(gif|jpg|jpeg|png|bmp|ico|swf|js|css)$ { expires 1d; access_log off; } #字體文件跨域問題 location ~ .*.(eof|ttf|ttc|otf|eof|woff|woff2|svg)(.*){ add_header Access-Control-Allow-Origin *; } }安裝PHP支持插件Memcache
[root@centos www]# cd /usr/local/src [root@centos src]# wget http://www.memcached.org/files/memcached-1.5.12.tar.gz [root@centos src]# tar -zxvf memcached-1.5.12.tar.gz [root@centos src]# cd memcached-1.5.12 [root@centos memcached-1.5.12]# yum install libevent* [root@centos memcached-1.5.12]# ./configure --prefix=/usr/local/memcached [root@centos memcached-1.5.12]# make && make install
編寫快捷啟動(dòng)腳本
[root@centos memcached-1.5.12]# vi /usr/local/memcached/memcached # 輸入以下代碼(啟動(dòng)參數(shù)請(qǐng)?jiān)谙旅娴哪_本中修改,如端口,最大內(nèi)存)
#! /bin/sh # # chkconfig: - 55 45 # description: The memcached daemon is a network memory cache service. # processname: memcached # config: /etc/sysconfig/memcached # Source function library. . /etc/rc.d/init.d/functions HOST=127.0.0.1 PORT=11211 USER=root MAXCONN=1024 CACHESIZE=64 OPTIONS="" if [ -f /etc/sysconfig/memcached ];then . /etc/sysconfig/memcached fi # Check that networking is up. if [ "$NETWORKING" = "no" ] then exit 0 fi RETVAL=0 start () { echo "Starting memcached ..." # insure that /var/run/memcached has proper permissions chown $USER /usr/local/memcached/bin/memcached /usr/local/memcached/bin/memcached -d -l $HOST -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P /var/run/memcached.pid $OPTIONS RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached } stop () { echo "Stopping memcached ..." killproc memcached RETVAL=$? echo if [ $RETVAL -eq 0 ] ; then rm -f /var/lock/subsys/memcached rm -f /var/run/memcached.pid fi } restart () { stop start } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status memcached ;; restart|reload) restart ;; condrestart) [ -f /var/lock/subsys/memcached ] && restart || : ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" exit 1 esac
腳本執(zhí)行權(quán)限
[root@localhost memcached-1.5.12]# chmod 0777 /usr/local/memcached/memcached
編寫服務(wù)啟動(dòng)腳本
[root@centos memcached-1.5.12]# vi /lib/systemd/system/memcached.service # -------------------------------------------------------------------------- # 輸入以下代碼 # -------------------------------------------------------------------------- [Unit] Description=memcached After=network.target [Service] Type=forking PIDFile=/var/run/memcached.pid ExecStart=/usr/local/memcached/memcached start ExecReload=/usr/local/memcached/memcached restart ExecStop=/usr/local/memcached/memcached stop PrivateTmp=true [Install] WantedBy=multi-user.target
設(shè)置開機(jī)啟動(dòng)
[root@centos memcached-1.5.12]# systemctl enable memcached.service
其它命令說明
# 啟動(dòng)memcached [root@centos memcached-1.5.12]# systemctl start memcached.service # 停止memcached [root@centos memcached-1.5.12]# systemctl stop memcached.service # 重啟memcached [root@centos memcached-1.5.12]# systemctl restart memcached.service # 如果提示:Job for memcached.service failed because the control process exited with error code. See "systemctl status memcached.service" and "journalctl -xe" for details. # 請(qǐng)選結(jié)束memcached進(jìn)程后再嘗試執(zhí)行上面的快捷操作 [root@centos memcached-1.5.12]# pkill -9 memcached
為PHP增加memcache支持(官司網(wǎng)memcache-3.0.8暫時(shí)不支持PHP的編譯)
官網(wǎng)memcache-3.0.8在編譯的時(shí)候出現(xiàn)“php-smart_str.h”沒有找到的錯(cuò)誤!
但是我們可以在github里面找到pecl-memcache支持PHP7的分支,請(qǐng)按以下操作即可完成memcache中擴(kuò)展安裝
[root@centos memcached]# cd /usr/local/src/php-7.1.10/ext # 如果已經(jīng)安裝git忽略yun install git [root@centos memcached]# yum install git [root@centos ext]# git clone https://github.com/websupport-sk/pecl-memcache memcache [root@centos ext]# cd memcache [root@centos ext]# yum install autoconf [root@centos ext]# /usr/local/php/bin/phpize [root@centos ext]# ./configure --with-php-config=/usr/local/php/bin/php-config [root@centos ext]# make && make install
修改php.ini
[root@centos ext]# vi /usr/local/php/etc/php.ini # 在 Dynamic Extensions 代碼塊中添加如下擴(kuò)展 extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/memcache.so
-重啟linux完成安裝(或重啟nginx php-fpm)
[root@centos ext]# reboot補(bǔ)充redis安裝及開機(jī)自啟動(dòng)
-官方下載并安裝
$ wget http://download.redis.io/releases/redis-5.0.4.tar.gz $ tar xzf redis-5.0.4.tar.gz $ cd redis-5.0.4 $ make $ make test
如果在make test 報(bào)錯(cuò)“You need tcl 8.5 or newer in order to run the Redis test”請(qǐng)安裝tcl組件后重新返回redis安裝目錄運(yùn)行“make test”
$ cd /usr/local/src $ wget https://downloads.sourceforge.net/tcl/tcl8.6.9-src.tar.gz $ tar xzvf tcl8.6.9-src.tar.gz $ cd /usr/local/src/tcl8.6.9/unix/ $ ./configure $ make $ make install
創(chuàng)建存儲(chǔ)redis文件目錄將所需要的文件移到該目錄下
$ mkdir -p /data/redis $ cp /usr/local/src/redis-5.0.4/redis.conf /data/redis/ $ cp /usr/local/src/redis-5.0.4/src/redis-cli /data/redis/ $ cp /usr/local/src/redis-5.0.4/src/redis-server /data/redis/
編輯redis.conf配制文件讓redis可以在后臺(tái)運(yùn)行
$ vi /data/redis/redis.conf
找到 “daemonize no” 修改為 “daemonize yes”
找到 “# maxmemory
wq保存
創(chuàng)建服務(wù)并設(shè)置開機(jī)自動(dòng)啟動(dòng)
$ vi /lib/systemd/system/redisd.service
# -------------------------------------------------------------------------- # 輸入以下代碼并保存 # -------------------------------------------------------------------------- [Unit] Description=The redis-server Process Manager After=syslog.target network.target [Service] Type=forking PIDFile=/var/run/redis_6379.pid ExecStart=/data/redis/redis-server /data/redis/redis.conf ExecReload=/bin/kill -USR2 $MAINPID ExecStop=/bin/kill -SIGINT $MAINPID [Install] WantedBy=multi-user.target
啟動(dòng)并添加到服務(wù)管理器
$ systemctl enable redisd.service $ systemctl start redisd.service $ systemctl daemon-reload
為PHP安裝redis擴(kuò)展
-下載并安裝php redis擴(kuò)展
$ cd /usr/local/src/php-7.1.24/ext $ wget http://pecl.php.net/get/redis-4.3.0.tgz $ tar zxvf redis-4.3.0.tgz $ cd redis-4.3.0 $ phpize $ ./configure --with-php-config=/usr/local/php/bin/php-config $ make $ make install
-修改php.ini
$ vi /usr/local/php/etc/php.ini
并找到 Dynamic Extensions 節(jié)點(diǎn)在下方增加如下(最后一行為添加項(xiàng))
zend_extension=opcache.so
extension=memcache.so
extension=pcntl.so
extension=redis.so <-添加些項(xiàng)
-重啟php-fpm 及nginx 或直接重啟電腦
安裝是否成功可在phpinfo()函數(shù)中查看!
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/39651.html
摘要:下源碼安裝一前言之前,我的開發(fā)環(huán)境是。重新加載權(quán)限表將確保所有到目前為止所做的更改將立即生效。然后,和注意,如果是使用二進(jìn)制包安裝了及相應(yīng)的開發(fā)庫,不需要指定路徑。五參考資料入門教程編譯安裝編譯安裝 Debian9下源碼安裝LNMP 一、前言 之前,我的開發(fā)環(huán)境是Windows-10+PHP-7.1+Nginx-1.10+MariaDB-10.1。 后面開發(fā)需要使用到memcached...
摘要:下源碼安裝一前言之前,我的開發(fā)環(huán)境是。重新加載權(quán)限表將確保所有到目前為止所做的更改將立即生效。然后,和注意,如果是使用二進(jìn)制包安裝了及相應(yīng)的開發(fā)庫,不需要指定路徑。五參考資料入門教程編譯安裝編譯安裝 Debian9下源碼安裝LNMP 一、前言 之前,我的開發(fā)環(huán)境是Windows-10+PHP-7.1+Nginx-1.10+MariaDB-10.1。 后面開發(fā)需要使用到memcached...
摘要:眾所周知,框架越重,性能相對(duì)就越低,因?yàn)橹匦涂蚣軙?huì)在解析時(shí)調(diào)用非常多的類方法和自定義函數(shù),導(dǎo)致性能嚴(yán)重下降。好在相對(duì)于而言,性能提升了將近一倍,而的也是個(gè)不錯(cuò)的替代方案。首先安裝和擴(kuò)展。我已向作者反饋,他修正了這個(gè)問題。 眾所周知,PHP框架越重,性能相對(duì)就越低,因?yàn)橹匦涂蚣軙?huì)在解析時(shí)調(diào)用非常多的類、方法和自定義函數(shù),導(dǎo)致性能嚴(yán)重下降。Laravel是一個(gè)非常受歡迎的PHP框架,但它也...
閱讀 2314·2021-11-08 13:13
閱讀 1245·2021-10-09 09:41
閱讀 1683·2021-09-02 15:40
閱讀 3186·2021-08-17 10:13
閱讀 2546·2019-08-29 16:33
閱讀 3122·2019-08-29 13:17
閱讀 3131·2019-08-29 11:00
閱讀 3295·2019-08-26 13:40