建站服務(wù)器
什么是LNMP?
金沙網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)建站!從網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)等網(wǎng)站項目制作,到程序開發(fā),運營維護。創(chuàng)新互聯(lián)建站自2013年起到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)建站。LNMP(別名LEMP)是指由Linux, Nginx, mysql/MariaDB, PHP/Perl/Python組合成的動態(tài)Web應(yīng)用程序和服務(wù)器,它是一組Web應(yīng)用程序的基礎(chǔ)軟件包,在這個基礎(chǔ)環(huán)境上我們可以搭建任何使用PHP/Perl/Python等語言的動態(tài)網(wǎng)站,如商務(wù)網(wǎng)站、博客、論壇和開源Web應(yīng)用程序軟件等,它是互聯(lián)網(wǎng)上被廣泛使用的Web網(wǎng)站架構(gòu)之一。
部署方式
從網(wǎng)站規(guī)模大小(訪問流量、注冊用戶等)角度來看,LNMP架構(gòu)可以使用單機部署方式和集群部署方式。單機部署方式即所有的軟件都部署在一臺Linux服務(wù)器上;集群部署方式可以將Nginx網(wǎng)絡(luò)服務(wù)器,Mysql/MariaDB數(shù)據(jù)庫,PHP軟件分開安裝到不同的服務(wù)器上,它們彼此之間通過TCP網(wǎng)絡(luò)協(xié)議相互通信協(xié)助工作,以及對外提供Web應(yīng)用訪問服務(wù)。因此,當單臺服務(wù)器不能滿足性能要求時,可以使用集群方式部署。
本教程將指導(dǎo)您如何在RHEL 7/CentOS 7以及Fedora 23/24/25等衍生版本中使用Nginx 1.10, MariaDB 10和PHP 6安裝LNMP應(yīng)用服務(wù)器環(huán)境。(在其他系統(tǒng)如SUSE、Ubuntu中源碼編譯安裝LNMP同樣可以參考本教程。)
前提要求
準備2臺RHEL 7或CentOS 7服務(wù)器,一臺用于安裝MariaDB,另一臺用于安裝Nginx和PHP。當然你也可以僅僅使用1臺服務(wù)器部署LNMP以通過實驗來驗證LNMP。
HOSTNAMEIPOSNODEhming-server217-mdb
10.0.6.217CentOS 7.2 x86_64MariaDBhming-server218-web10.0.6.218CentOS 7.2 x86_64MariaDB,Nginx,PHP主軟件包(源碼包)
DB mariadb-10.1.20.tar.gz
PHP php-5.6.30.tar.bz2
Nginx nginx-1.10.2.tar.gz
注意:主軟件包在這之前我已經(jīng)提前下載好了,可能并不是最新和穩(wěn)定版,你也可以根據(jù)你的需求選擇其他版本。
依賴軟件
源碼編譯安裝LNMP有許多依賴軟件(如gcc、make)是必要的,一般可以通過YUM軟件管理程序來安裝,另外小部分需要源碼編譯安裝。
通過yum安裝gcc、gcc-c++、make等必需軟件包
#yuminstall-ygccgcc-c++makeautomake
安裝MariaDB
1. 使用yum安裝gcc、make、bison、ncurses-devel等依賴軟件包
#yuminstallzlib-develncursesncurses-develbison
2.安裝cmake,cmake是編譯MYSQL/MariaDB的必要工具(MySQL5.6/MariaDB 10及以后的版本) 你可以在網(wǎng)站https://cmake.org/中下載cmake軟件包
將軟件包上傳到/usr/local/src目錄下,然后解壓cmake包,cd到cmake目錄執(zhí)行./bootstrap腳本進行安裝,同時可以使用--prefix=<install dir>選項指定安裝的目錄。
#tar-zxfcmake-3.7.2.tar.gz #cdcmake-3.7.2/ #./bootstrap--prefix=/usr/local/cmake #make&&makeinstall
當安裝完之后,你可以使用執(zhí)行/usr/local/cmake/bin/cmake --version查看安裝的cmake版本
[root@hming-server217-mdb~]#/usr/local/cmake/bin/cmake--version cmakeversion3.7.2 CMakesuitemaintainedandsupportedbyKitware(kitware.com/cmake).
3.安裝完cmake編譯工具之后,接下來我們安裝MariaDB(你可以訪問https://mariadb.org/下載MariaDB), 首先創(chuàng)建MariaDB安裝目錄/usr/local/mysql和數(shù)據(jù)庫服務(wù)器的數(shù)據(jù)目錄/data/mysql/webdata,并創(chuàng)建MySQL用戶,并將/data/mysql/webdata目錄的所屬主權(quán)限修改為mysql用戶
創(chuàng)建安裝目錄和數(shù)據(jù)目錄
#mkdir/usr/local/mysql #mkdir/data/mysql/webdata-p
創(chuàng)建mysql用戶,并修改數(shù)據(jù)目錄的權(quán)限
#groupaddmysql #useradd-r-gmysql-s/sbin/nologinmysql-M #chown-Rmysql:mysql/data/mysql/
4. 編譯安裝MariaDB,將MariaDB軟件包解壓后使用cmake進行編譯,根據(jù)需求選擇相應(yīng)的編譯參數(shù)進行編譯(查看編譯選項/usr/local/cmake/bin/cmake . -LH). (或者訪問MariaDB編譯安裝幫助文檔https://mariadb.com/kb/en/mariadb/compiling-mariadb-from-source/)
[root@hming-server217-mdb/usr/local/src]#tar-zxfmariadb-10.1.20.tar.gz [root@hming-server217-mdb/usr/local/src]#cdmariadb-10.1.20/ [root@hming-server217-mdb/usr/local/src/mariadb-10.1.20]#/usr/local/cmake/bin/cmake.-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data/mysql/webdata-DSYSCONFDIR=/etc-DMYSQL_TCP_PORT=3306-DMYSQL_USER=mysql-DDEFAULT_CHARSET=utf8-DEXTRA_CHARSETS=all-DDEFAULT_COLLATION=utf8_general_ci-DMYSQL_UNIX_ADDR=/data/mysql/webdata/mysql.sock-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1-DWITH_PARTITION_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1-DENABLED_LOCAL_INFILE=1-DWITH_EMBEDDED_SERVER=1-DWITH_READLINE=1-DWITH_DEBUG=0
執(zhí)行g(shù)make 和 gmake install進行最后的安裝
[root@hming-server217-mdb/usr/local/src/mariadb-10.1.20]#gmake [root@hming-server217-mdb/usr/local/src/mariadb-10.1.20]#gmakeinstall
5.配置mysql環(huán)境變量,如果不配置默認系統(tǒng)找不到mysql的可執(zhí)行程序和命令,否則你必須使用全路徑執(zhí)行與mysql相關(guān)的任何命令,查看系統(tǒng)默認的環(huán)境變量
使用export命令添加mysql環(huán)境變量
[root@hming-server217-mdb~]#exportPATH=$PATH:/usr/local/mysql/bin [root@hming-server217-mdb~]#echo$PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin
最后將mysql環(huán)境配置添加到/etc/profile或者/etc/profile.d/的自定義文件中
[root@hming-server217-mdb~]#echoexportPATH=$PATH:/usr/local/mysql/bin>/etc/profile.d/mysql.sh [root@hming-server217-mdb~]#source/etc/profile.d/mysql.sh
配置了環(huán)境變量,我們就可以直接在shell終端下執(zhí)行mysql命令,使用mysql -V查看mysql版本
[root@hming-server217-mdb~]#mysql-V mysqlVer15.1Distrib10.1.20-MariaDB,forLinux(x86_64)usingreadline5.1
6.添加MariaDB庫文件
[root@hming-server217-mdb~]#echo/usr/local/mysql/lib>>/etc/ld.so.conf.d/mariadb-x86_64.conf
7.拷貝MariaDB服務(wù)啟動腳本到/etc/init.d/目錄中
[root@hming-server217-mdb~]#cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld [root@hming-server217-mdb~]#chmod755/etc/init.d/mysqld [root@hming-server217-mdb~]#chkconfig--addmysqld [root@hming-server217-mdb~]#chkconfigmysqldon [root@hming-server217-mdb~]#systemctldaemon-reload
[root@hming-server217-mdb~]#cd/usr/local/mysql/scripts/ [root@hming-server217-mdb/usr/local/mysql/scripts]#./mysql_install_db--basedir=/usr/local/mysql--datadir=/data/mysql/webdata--user=mysql--no-defaults [root@hming-server217-mdb/usr/local/mysql/scripts]#ls/data/mysql/webdata/ aria_log.00000001ibdata1ib_logfile1performance_schema aria_log_controlib_logfile0mysqltest
[root@hming-server217-mdb~]#cp/etc/my.cnf/etc/my.cnf.save [root@hming-server217-mdb~]#cat/etc/my.cnf [client] port=3306 socket=/data/mysql/webdata/mysql.sock default-character-set=utf8 [mysqld] port=3306 user=mysql basedir=/usr/local/mysql datadir=/data/mysql/webdata socket=/data/mysql/webdata/mysql.sock character-set-server=utf8 external-locking=FALSE skip-name-resolv default-storage-engine=InnoDB back_log=1024 transaction_isolation=REPEATABLE-READ max_connections=5000 max_connect_errors=6000 open_files_limit=65535 table_open_cache=512 [mysqldump] quick max_allowed_packet=32M [mysql] no-auto-rehash default-character-set=utf8 [mysqld_safe] open-files-limit=8192 log-error=/var/log/mariadb/mariadb.log pid-file=/var/run/mariadb/mariadb.pid
[root@hming-server217-mdb~]#mkdir/var/log/mariadb [root@hming-server217-mdb~]#mkdir/var/run/mariadb [root@hming-server217-mdb~]#chownmysql:mysql/var/log/mariadb [root@hming-server217-mdb~]#chownmysql:mysql/var/run/mariadb
[root@hming-server217-mdb~]#systemctlstartmysqld [root@hming-server217-mdb~]#systemctlstatusmysqld [root@hming-server217-mdb~]#systemctlstatusmysqld ●mysqld.service-LSB:startandstopMySQL Loaded:loaded(/etc/rc.d/init.d/mysqld) Active:active(running)sinceFri2017-06-0223:53:09CST;3daysago Docs:man:systemd-sysv-generator(8) Process:27419ExecStop=/etc/rc.d/init.d/mysqldstop(code=exited,status=0/SUCCESS) Process:27449ExecStart=/etc/rc.d/init.d/mysqldstart(code=exited,status=0/SUCCESS) CGroup:/system.slice/mysqld.service ├─27460/bin/sh/usr/local/mysql/bin/mysqld_safe--datadir=/data/mysql/webdata--pid-file=/data/mysq... └─27595/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/data/mysql/webdata--plugi... Jun0223:53:08hming-server217-mdbsystemd[1]:StartingLSB:startandstopMySQL... Jun0223:53:08hming-server217-mdbmysqld[27449]:StartingMySQL.17060223:53:08mysqld_safeLoggingto\'/...og\'. Jun0223:53:09hming-server217-mdbmysqld[27449]:SUCCESS! Jun0223:53:09hming-server217-mdbsystemd[1]:StartedLSB:startandstopMySQL. Hint:Somelineswereellipsized,use-ltoshowinfull.
[root@hming-server217-mdb~]#psaux|grepmysql root274600.00.01153801744?S23:530:00/bin/sh/usr/local/mysql/bin/mysqld_safe--datadir=/data/mysql/webdata--pid-file=/data/mysql/webdata/hming-server217-mdb.pid mysql275951.05.2120938099428?Sl23:530:00/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/data/mysql/webdata--plugin-dir=/usr/local/mysql/lib/plugin--user=mysql--log-error=/var/log/mariadb/mariadb.log--open-files-limit=8192--pid-file=/data/mysql/webdata/hming-server217-mdb.pid--socket=/data/mysql/webdata/mysql.sock--port=3306 root276270.00.0112644952pts/2S+23:530:00grep--color=automysql
[root@hming-server217-mdb~]#mysql_secure_installation NOTE:RUNNINGALLPARTSOFTHISSCRIPTISRECOMMENDEDFORALLMariaDB SERVERSINPRODUCTIONUSE!PLEASEREADEACHSTEPCAREFULLY! InordertologintoMariaDBtosecureit,we\'llneedthecurrent passwordfortherootuser.Ifyou\'vejustinstalledMariaDB,and youhaven\'tsettherootpasswordyet,thepasswordwillbeblank, soyoushouldjustpressenterhere. Entercurrentpasswordforroot(enterfornone): OK,successfullyusedpassword,movingon... SettingtherootpasswordensuresthatnobodycanlogintotheMariaDB rootuserwithouttheproperauthorisation. Setrootpassword?[Y/n]y Newpassword: Re-enternewpassword: Passwordupdatedsuccessfully! Reloadingprivilegetables.. ...Success! Bydefault,aMariaDBinstallationhasananonymoususer,allowinganyone tologintoMariaDBwithouthavingtohaveauseraccountcreatedfor them.Thisisintendedonlyfortesting,andtomaketheinstallation goabitsmoother.Youshouldremovethembeforemovingintoa productionenvironment. Removeanonymoususers?[Y/n]y ...Success! Normally,rootshouldonlybeallowedtoconnectfrom\'localhost\'.This ensuresthatsomeonecannotguessattherootpasswordfromthenetwork. Disallowrootloginremotely?[Y/n]y ...Success! Bydefault,MariaDBcomeswithadatabasenamed\'test\'thatanyonecan access.Thisisalsointendedonlyfortesting,andshouldberemoved beforemovingintoaproductionenvironment. Removetestdatabaseandaccesstoit?[Y/n]y -Droppingtestdatabase... ...Success! -Removingprivilegesontestdatabase... ...Success! Reloadingtheprivilegetableswillensurethatallchangesmadesofar willtakeeffectimmediately. Reloadprivilegetablesnow?[Y/n]y ...Success! Cleaningup... Alldone!Ifyou\'vecompletedalloftheabovesteps,yourMariaDB installationshouldnowbesecure. ThanksforusingMariaDB!
12.登錄MariaDB數(shù)據(jù)庫
[root@hming-server217-mdb~]#mysql-uroot-p Enterpassword: WelcometotheMariaDBmonitor.Commandsendwith;or\\g. YourMariaDBconnectionidis353 Serverversion:10.1.20-MariaDBSourcedistribution Copyright(c)2000,2016,Oracle,MariaDBCorporationAbandothers. Type\'help;\'or\'\\h\'forhelp.Type\'\\c\'toclearthecurrentinputstatement. MariaDB[(none)]>selectversion(); +-----------------+ |version()| +-----------------+ |10.1.20-MariaDB| +-----------------+ 1rowinset(0.00sec) MariaDB[(none)]>
[root@hming-server218-web~]#yuminstallgccgcc-c++zlibzlib-develpcrepcre-developenssl-develgdgd-develperl-develperl-ExtUtils-Embed
[root@hming-server218-web~]#groupaddnginx [root@hming-server218-web~]#useradd-gnginx-s/sbin/nologinnginx-M
3. 編譯安裝Nginx
[root@hming-server218-web/usr/local/src]#tar-zxfnginx-1.10.2.tar.gz [root@hming-server218-web/usr/local/src]#cdnginx-1.10.2/ [root@hming-server218-web/usr/local/src/nginx-1.10.2]#./configure\\ --user=nginx\\ --group=nginx\\ --prefix=/usr/local/nginx\\ --pid-path=/var/run/nginx/nginx.pid\\ --lock-path=/var/lock/subsys/nginx\\ --with-http_stub_status_module\\ --with-pcre\\ --with-http_ssl_module\\ --with-mail_ssl_module\\ --with-http_gzip_static_module\\ --http-log-path=/var/log/nginx/access.log\\ --error-log-path=/var/log/nginx/error.log\\ --http-client-body-temp-path=/tmp/nginx/client_body\\ --http-proxy-temp-path=/tmp/nginx/proxy\\ --http-fastcgi-temp-path=/tmp/nginx/fastcgi\\ --http-uwsgi-temp-path=/tmp/nginx/uwsgi\\ --with-http_degradation_module\\ --with-http_realip_module\\ --with-http_addition_module\\ --with-http_sub_module\\ --with-http_perl_module\\ --with-http_p_w_picpath_filter_module=dynamic\\ --with-http_flv_module [root@hming-server218-web/usr/local/src/nginx-1.10.2]#make&&makeinstall
4. 啟動Nginx服務(wù)
[root@hming-server218-web~]#ln-s/usr/local/nginx/sbin/nginx/usr/local/sbin/ [root@hming-server218-web~]#mkdir/tmp/nginx [root@hming-server218-web~]#nginx [root@hming-server218-web~]#ps-ef|grepnginx root279131000:49?00:00:00nginx:masterprocessnginx nginx2791427913000:49?00:00:00nginx:workerprocess root2792322381000:49pts/100:00:00grep--color=autonginx
5.添加防火墻
[root@hming-server218-web~]#firewall-cmd--permanent--add-port=80/tcp success [root@hming-server218-web~]#firewall-cmd--reload success
6. 通過客戶端訪問http://10.0.6.218
安裝依賴軟件包
[root@hming-server218-web~]#yuminstallgccgcc-c++libtoollibxslt-devellibpnglibpng-develbzip2bzip2-devellibxml2-devellibXpm-devellibcurl-develcurllibmcryptexpatlibxsltfreetypefreetype-devellibmcrypt-develautoconflibpngzlib-develzlibnet-snmpnet-snmp-devel
[root@hming-server218-web~]#tar-zxflibiconv-1.15.tar.gz [root@hming-server218-web~]#cdlibiconv-1.15/ [root@hming-server218-web~/libiconv-1.15]#./configure--prefix=/usr/local/libiconv [root@hming-server218-web~/libiconv-1.15]#make&&makeinstall [root@hming-server218-web~]#echo/usr/local/libiconv/lib>>/etc/ld.so.conf [root@hming-server218-web~]#ldconfig
[root@hming-server218-web~]#tar-jxflibmcrypt-2.5.8.tar.bz2 [root@hming-server218-web~]#cdlibmcrypt-2.5.8/ [root@hming-server218-web~/libmcrypt-2.5.8]#./configure--prefix=/usr/local/libmcrypt [root@hming-server218-web~/libmcrypt-2.5.8]#make&&makeinstall
#tar-zxfjpegsrc.v9b.tar.gz #cdjpeg-9b/ #mkdir/usr/local/jpeg9&&mkdir/usr/local/jpeg9/{bin,lib,include} #mkdir/usr/local/jpeg9/man/man1-p #cp-rf/usr/share/libtool/config/config.sub.&&cp-rf/usr/share/libtool/config/config.guess. cp:overwrite\\u2018./config.sub\\u2019?y cp:overwrite\\u2018./config.guess\\u2019?y #./configure--prefix=/usr/local/jpeg9--enable-shared--enable-static #make&&makeinstall
[root@hming-server218-web~]#tar-zxflibgd-2.2.3.tar.gz [root@hming-server218-web~]#cdlibgd-2.2.3/ [root@hming-server218-web~/libgd-2.2.3]#./configure--prefix=/usr/local/libgd2--with-zlib--with-jpeg=/usr/local/jpeg9--with-png--with-freetype [root@hming-server218-web~/libgd-2.2.3]#make&&makeinstall
6. 編譯安裝PHP
[root@hming-server218-web~]#groupaddphp-fpm [root@hming-server218-web~]#useradd-gphp-fpm-s/sbin/nologinphp-fpm-M [root@hming-server218-web~]#tar-jxfphp-5.6.30.tar.bz2 [root@hming-server218-web~]#cdphp-5.6.30/ [root@hming-server218-web~]#./configure\\ --prefix=/usr/local/php\\ --with-config-file-path=/usr/local/php/etc\\ --enable-fpm\\ --with-fpm-user=php-fpm\\ --with-fpm-group=php-fpm\\ --with-mysql=/usr/local/mysql\\ --with-mysqli=/usr/local/mysql/bin/mysql_config\\ --with-jpeg-dir=/usr/local/jpeg9\\ --with-mcrypt=/usr/local/libmcrypt\\ --with-gd=/usr/local/libgd2\\ --with-iconv-dir=/usr/local/libiconv\\ --with-openssl-dir\\ --with-freetype-dir\\ --with-libxml-dir\\ --with-png-dir\\ --with-zlib\\ --with-curl\\ --with-mhash\\ --with-pear\\ --with-pcre-dir\\ --with-gettext\\ --enable-soap\\ --enable-gd-native-ttf\\ --enable-mbstring\\ --enable-exif\\ --enable-sockets\\ --enable-ftp\\ --disable-ipv6\\ --enable-bcmath\\ --enable-shmop\\ --with-snmp\\ --enable-sysvsem [root@hming-server218-web~/php-5.6.30]#make [root@hming-server218-web~/php-5.6.30]#maketest [root@hming-server218-web~/php-5.6.30]#makeinstall
7.拷貝php.ini配置文件
[root@hming-server218-web~/php-5.6.30]#cpphp.ini-production/usr/local/php/etc/php.ini
[root@hming-server218-web~]#vim/usr/local/php/etc/php-fpm.conf [global] pid=/usr/local/php/var/run/php-fpm.pid error_log=/usr/local/php/var/log/php-fpm.log [www] listen=/var/lib/php/php-fcgi.sock user=php-fpm group=php-fpm listen.owner=nginx listen.group=nginx pm=dynamic pm.max_children=100 pm.start_servers=20 pm.min_spare_servers=5 pm.max_spare_servers=35 pm.max_requests=500 rlimit_files=1024
9. 檢查配置
[root@hming-server218-web~]#/usr/local/php/sbin/php-fpm-t [05-Jun-201720:23:27]NOTICE:configurationfile/usr/local/php/etc/php-fpm.conftestissuccessful
10.拷貝啟動腳本
[root@hming-server218-web~]#cpphp-5.6.30/sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm [root@hming-server218-web~]#chmod755/etc/init.d/php-fpm [root@hming-server218-web~]#/etc/init.d/php-fpmstart Startingphp-fpmdone
1. 修改nginx.conf配置文件
usernginxnginx; worker_processes4; error_log/var/log/nginx/error.lognotice; pid/var/run/nginx/nginx.pid; worker_rlimit_nofile65535; events{ useepoll; worker_connections65535; } http{ includemime.types; default_typeapplication/octet-stream; server_names_hash_bucket_size2048; server_names_hash_max_size4096; log_formatmain\'$remote_addr-$remote_user[$time_local]$request\' \'$status$body_bytes_sent$http_referer\' \'$http_user_agent$http_x_forwarded_for\'; access_log/var/log/nginx/access.logmain; sendfileon; tcp_nopushon; tcp_nodelayon; keepalive_timeout65; client_header_timeout30; client_body_timeout3m; client_max_body_size10m; client_body_buffer_size256k; send_timeout3m; connection_pool_size256; client_header_buffer_size32k; large_client_header_buffers464k; request_pool_size4k; output_buffers432k; postpone_output1460; client_body_temp_path/tmp/nginx/client_body; proxy_temp_path/tmp/nginx/proxy; fastcgi_temp_path/tmp/nginx/fastcgi; gzipon; gzip_min_length1k; gzip_buffers416k; gzip_comp_level3; gzip_http_version1.1; gzip_typestext/plainapplication/x-javascripttext/csstext/htmapplication/xml; gzip_varyon; fastcgi_connect_timeout300; fastcgi_send_timeout300; fastcgi_read_timeout300; fastcgi_buffer_size64k; fastcgi_buffers464k; fastcgi_busy_buffers_size128k; fastcgi_temp_file_write_size128k; fastcgi_intercept_errorson; server{ listen80; server_name10.0.6.218; charsetUTF8; indexindex.htmlindex.htmindex.phpindex.jsp; root/usr/local/nginx/html; #access_loglogs/host.access.logmain; location/{ roothtml; indexindex.htmlindex.htm; } #redirectservererrorpagestothestaticpage/50x.html error_page500502503504/50x.html; location=/50x.html{ roothtml; } #passthePHPscriptstoFastCGIserverlisteningon127.0.0.1:9000 location~\\.php${ roothtml; fastcgi_passunix:/var/lib/php/php-fcgi.sock; fastcgi_indexindex.php; fastcgi_paramSCRIPT_FILENAME/usr/local/nginx/html$fastcgi_script_name; includefastcgi_params; } } }
[root@hming-server218-web~]#nginx-t nginx:theconfigurationfile/usr/local/nginx/conf/nginx.confsyntaxisok nginx:configurationfile/usr/local/nginx/conf/nginx.conftestissuccessful
[root@hming-server218-web~]#vim/usr/local/nginx/html/info.php <?php phpinfo(); ?> [root@hming-server218-web~]#nginx-sreload
4. 訪問http://10.0.6.218/info.php
[root@hming-server218-web~]#mkdir/app/data/phpMyAdmin-p
2.將phpMyAdmin軟件包解壓到/app/data/phpMyAdmin 目錄下
#tar-zxfphpMyAdmin-4.7.1-all-languages.tar.gz #cp-arphpMyAdmin-4.7.1-all-languages/*/app/data/phpMyAdmin/ #chown-Rnginx:nginx/app/data/phpMyAdmin #chown-Rphp-fpm:php-fpm/app/data/phpMyAdmin
http{ ...... #phpMyAdmin server{ listen8000; server_name10.0.6.218; charsetUTF8; indexindex.htmlindex.htmindex.phpindex.jsp; root/app/data; access_log/var/log/nginx/phpMyAdmin.logmain; location/phpMyAdmin/{ indexindex.htmlindex.htmindex.php; } location~\\.php${ fastcgi_passunix:/var/lib/php/php-fcgi.sock; fastcgi_indexindex.php; fastcgi_paramSCRIPT_FILENAME/app/data$fastcgi_script_name; includefastcgi_params; } } }
[root@hming-server217-mdb~]#mysql-uroot-p Enterpassword: WelcometotheMariaDBmonitor.Commandsendwith;or\\g. YourMariaDBconnectionidis13 Serverversion:10.1.20-MariaDBSourcedistribution Copyright(c)2000,2016,Oracle,MariaDBCorporationAbandothers. Type\'help;\'or\'\\h\'forhelp.Type\'\\c\'toclearthecurrentinputstatement. MariaDB[(none)]>selectuser,host,passwordfrommysql.user; +------+-----------+-------------------------------------------+ |user|host|password| +------+-----------+-------------------------------------------+ |root|localhost|*84BB5DF4823DA319BBF86C99624479A198E6EEE9| |root|127.0.0.1|*84BB5DF4823DA319BBF86C99624479A198E6EEE9| |root|::1|*84BB5DF4823DA319BBF86C99624479A198E6EEE9| +------+-----------+-------------------------------------------+ 3rowsinset(0.00sec) MariaDB[(none)]>grantallprivilegeson*.*to\'root\'@\'10.0.6.218\'identifiedby\'phpMyAdmin_123\'; QueryOK,0rowsaffected(0.00sec) MariaDB[(none)]>flushprivileges; QueryOK,0rowsaffected(0.00sec)
5. 配置防火墻規(guī)則
#iptables-IINPUT-ptcp--dport3306-s10.0.6.0/24-jACCEPT 或者 #firewall-cmd--permanent--add-rich-rule\'rulefamily=ipv4sourceaddress=10.0.6.0/24portport=3306protocol=tcpaccept\'
#cp/app/data/phpMyAdmin/libraries/config.default.php/app/data/phpMyAdmin/libraries/config.default.php.save #vim/app/data/phpMyAdmin/libraries/config.default.php /** *The\'cookie\'auth_typeusesAESalgorithmtoencryptthepassword.If *atleastoneserverconfigurationuses\'cookie\'auth_type,enterherea *passphrasethatwillbeusedbyAES.Themaximumlengthseemstobe46 *characters. * *@globalstring$cfg[\'blowfish_secret\'] */ $cfg[\'blowfish_secret\']=\'123456\'; /** *MySQLhostnameorIPaddress * *@globalstring$cfg[\'Servers\'][$i][\'host\'] */ $cfg[\'Servers\'][$i][\'host\']=\'10.0.6.217\'; /** *MySQLport-leaveblankfordefaultport * *@globalstring$cfg[\'Servers\'][$i][\'port\'] */ $cfg[\'Servers\'][$i][\'port\']=\'3306\'; /** *Pathtothesocket-leaveblankfordefaultsocket * *@globalstring$cfg[\'Servers\'][$i][\'socket\'] */ $cfg[\'Servers\'][$i][\'socket\']=\'\'; /** *Authenticationmethod(validchoices:config,http,signonorcookie) * *@globalstring$cfg[\'Servers\'][$i][\'auth_type\'] */ $cfg[\'Servers\'][$i][\'auth_type\']=\'cookie\'; /** *HTTPBasicAuthRealmnametodisplay(onlyusedwith\'HTTP\'auth_type) * *@globalstring$cfg[\'Servers\'][$i][\'auth_http_realm\'] */ $cfg[\'Servers\'][$i][\'auth_http_realm\']=\'\'; /** *MySQLuser * *@globalstring$cfg[\'Servers\'][$i][\'user\'] */ $cfg[\'Servers\'][$i][\'user\']=\'root\'; /** *MySQLpassword(onlyneededwith\'config\'auth_type) * *@globalstring$cfg[\'Servers\'][$i][\'password\'] */ $cfg[\'Servers\'][$i][\'password\']=\'phpMyAdmin_123\';
#phpMyAdmin server{ listen8000; server_name10.0.6.218; charsetUTF8; indexindex.htmlindex.htmindex.phpindex.jsp; root/app/data; access_log/var/log/nginx/phpMyAdmin.logmain; location/phpMyAdmin/{ allow10.0.6.0/24; denyall; auth_basicAuth; auth_basic_user_file/usr/local/nginx/.htpassword; indexindex.htmlindex.htmindex.php; } location~\\.php${ fastcgi_passunix:/var/lib/php/php-fcgi.sock; fastcgi_indexindex.php; fastcgi_paramSCRIPT_FILENAME/app/data$fastcgi_script_name; includefastcgi_params; } }
[root@hming-server218-web~]#yuminstallhttpd [root@hming-server218-web~]#htpasswd-c/usr/local/nginx/.htpasswordHM Newpassword: Re-typenewpassword: AddingpasswordforuserHM [root@hming-server218-web~]#ls-l/usr/local/nginx/.htpassword -rw-r--r--1rootroot41Jun618:04/usr/local/nginx/.htpassword
分享文章:CentOS7上源碼編譯安裝和配置LNMPWeb+phpMyAdmin服務(wù)器環(huán)境
鏈接分享:http://jinyejixie.com/article34/chopse.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、搜索引擎優(yōu)化、商城網(wǎng)站、Google、域名注冊、手機網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)