標籤:lnmp
lnmp架構介紹
MySQL安裝
1.首先下載軟體包
[[email protected] src]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz--2018-02-26 21:12:00-- http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz正在解析主機 mirrors.sohu.com (mirrors.sohu.com)... 221.236.12.140正在串連 mirrors.sohu.com (mirrors.sohu.com)|221.236.12.140|:80... 已串連。已發出 HTTP 要求,正在等待回應... 200 OK長度:316320366 (302M) [application/octet-stream]正在儲存至: “mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz”100%[====================================>] 316,320,366 525KB/s 用時 11m 2s 2018-02-26 21:23:02 (467 KB/s) - 已儲存 “mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz” [316320366/316320366])
2.解壓縮
tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
3.移動目錄並改名
[[email protected] src]# mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql
4.進入mysql目錄
[[email protected] src]# cd /usr/local/mysql/[[email protected] mysql]# lsbin data include man README share support-filesCOPYING docs lib mysql-test scripts sql-bench
5.建立使用者,目錄並初始化
[[email protected] mysql]# useradd mysql[[email protected] mysql]# mkdir /data/[[email protected] mysql]# ls /data/[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysqlFATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:Data::Dumper
6.初始化:
./scripts/mysql_install_db --user=mysql --datadir=/data/mysqlInstalling MySQL system tables...2018-02-26 22:25:59 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2018-02-26 22:25:59 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.2018-02-26 22:25:59 0 [Note] ./bin/mysqld (mysqld 5.6.36) starting as process 1622 ...2018-02-26 22:25:59 1622 [Note] InnoDB: Using atomics to ref count buffer pool pages2018-02-26 22:25:59 1622 [Note] InnoDB: The InnoDB memory heap is disabled2018-02-26 22:25:59 1622 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2018-02-26 22:25:59 1622 [Note] InnoDB: Memory barrier is not used2018-02-26 22:25:59 1622 [Note] InnoDB: Compressed tables use zlib 1.2.32018-02-26 22:25:59 1622 [Note] InnoDB: Using Linux native AIO
7.執行完成後馬上執行
[[email protected] mysql]# echo $?0
檢驗上一條是否正確,0為正確
8.複製設定檔,或更改內建檔案
[[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf^C[[email protected] mysql]# ls /etc/my.cnf/etc/my.cnf[[email protected] mysql]# rpm -qf /etc/my.cnfmariadb-libs-5.5.56-2.el7.x86_64
[[email protected] mysql]# vim /etc/my.cnf
[mysqld]datadir=/data/mysqlsocket=/tmp/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0# Settings user and group are ignored when systemd is used.# If you need to run mysqld under a different user or group,# customize your systemd unit file for mariadb according to the# instructions in http://fedoraproject.org/wiki/Systemd[mysqld_safe]#log-error=/var/log/mariadb/mariadb.log#pid-file=/var/run/mariadb/mariadb.pid## include all files from the config directory##!includedir /etc/my.cnf.d
9.複製啟動指令碼
[[email protected] mysql]# ls support-files/binary-configure my-default.cnf mysql-log-rotatemagic mysqld_multi.server mysql.server[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld
10.更改啟動指令碼:
[[email protected] mysql]# vi /etc/init.d/mysqld
basedir=/usr/local/mysqldatadir=/data/mysql
11.設定開機啟動
[[email protected] mysql]# chkconfig --add mysqld[[email protected] mysql]# chkconfig --list註:該輸出結果只顯示 SysV 服務,並不包含原生 systemd 服務。SysV 配置資料可能被原生 systemd 配置覆蓋。 要列出 systemd 服務,請執行 ‘systemctl list-unit-files‘。 查看在具體 target 啟用的服務請執行 ‘systemctl list-dependencies [target]‘。mysqld 0:關 1:關 2:開 3:開 4:開 5:開 6:關netconsole 0:關 1:關 2:關 3:關 4:關 5:關 6:關network 0:關 1:關 2:開 3:開 4:開 5:開 6:關
php安裝
1.首先,將之前的php配置清空:
[[email protected] php-5.6.30]# make cleanfind . -name \*.gcno -o -name \*.gcda | xargs rm -ffind . -name \*.lo -o -name \*.o | xargs rm -ffind . -name \*.la -o -name \*.a | xargs rm -f find . -name \*.so | xargs rm -ffind . -name .libs -a -type d|xargs rm -rfrm -f libphp5.la sapi/cli/php sapi/cgi/php-cgi libphp5.la modules/* libs/*
2.重新設定:
./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/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-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
報錯
checking whether to enable calendar conversion support... nochecking whether to enable ctype functions... yeschecking for cURL support... yeschecking for cURL in default path... not foundconfigure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/
安裝依賴包:
[[email protected] php-5.6.30]# yum install -y libcurl-devel已載入外掛程式:fastestmirrorbase | 3.6 kB 00:00:00 epel/x86_64/metalink | 5.8 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/4): extras/7/x86_64/primary_db | 181 kB 00:00:00
再次配置:
./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/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-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
完成
3.安裝
[[email protected] php-5.6.30]# make && make install/bin/sh /usr/local/src/php-5.6.30/libtool --silent --preserve-dup-deps --mode=compile cc -Iext/opcache/ -I/usr/local/src/php-5.6.30/ext/opcache/ -DPHP_ATOM_INC -I/usr/local/src/php-5.6.30/include -I/usr/local/src/php-5.6.30/main -I/usr/local/src/php-5.6.30 -I/usr/local/src/php-5.6.30/ext/date/lib -I/usr/local/src/php-5.6.30/ext/ereg/regex -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/local/src/php-5.6.30/ext/mbstring/oniguruma -I/usr/local/src/php-5.6.30/ext/mbstring/libmbfl -I/usr/local/src/php-5.6.30/ext/mbstring/libmbfl/mbfl -I/usr/local/mysql/include -I/usr/local/src/php-5.6.30/ext/sqlite3/libsqlite -I/usr/local/src/php-5.6.30/TSRM -I/usr/local/src/php-5.6.30/Zend -I/usr/include -g -O2 -fvisibility=hidden -c /usr/local/src/php-5.6.30/ext/opcache/ZendAccelerator.c -o ext/opcache/ZendAccelerator.lo
4.查看檔案結構:
[[email protected] php-5.6.30]# ls /usr/local/php-fpm/bin etc include lib php sbin var[[email protected] php-5.6.30]# ls /usr/local/phpbin etc include lib php[[email protected] php-5.6.30]# ls /usr/local/php-fpm/sbin/php-fpm[[email protected] php-5.6.30]# ls /usr/local/php-fpm/varlog run
5.查看配置是否正確:
[[email protected] php-5.6.30]# /usr/local/php-fpm/sbin/php-fpm -t[12-Mar-2018 22:27:46] ERROR: failed to open configuration file ‘/usr/local/php-fpm/etc/php-fpm.conf‘: No such file or directory (2)[12-Mar-2018 22:27:46] ERROR: failed to load configuration file ‘/usr/local/php-fpm/etc/php-fpm.conf‘[12-Mar-2018 22:27:46] ERROR: FPM initialization failed
6.修改設定檔:
[[email protected] php-5.6.30]# cp php.ini-production /usr/local/php-fpm/php.ini[[email protected] php-5.6.30]# cd /usr/local/php-fpm/etc/[[email protected] etc]# lspear.conf php-fpm.conf.default[[email protected] etc]# vim php-fpm.conf
[global]pid = /usr/local/php-fpm/var/run/php-fpm.piderror_log = /usr/local/php-fpm/var/log/php-fpm.log[www]listen = /tmp/php-fcgi.socklisten.mode = 666user = php-fpmgroup = php-fpmpm = dynamicpm.max_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 500rlimit_files = 1024
7.開啟服務:
[[email protected] etc]# cd /usr/local/src/php-5.6.30[[email protected] php-5.6.30]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm[[email protected] php-5.6.30]# chmod 755 /etc/init.d/php-fpm [[email protected] php-5.6.30]# chkconfig --add php-fpm[[email protected] php-5.6.30]# chkconfig php-fpm on[[email protected] php-5.6.30]# service php-fpm startStarting php-fpm [12-Mar-2018 22:42:04] ERROR: [pool www] cannot get uid for user ‘php-fpm‘[12-Mar-2018 22:42:04] ERROR: FPM initialization failed failed
報錯,需要添加使用者php-fpm
[[email protected] php-5.6.30]# useradd php-fpm[[email protected] php-5.6.30]# service php-fpm startStarting php-fpm done[[email protected] php-5.6.30]# ps aux |grep php-fpmroot 117576 0.0 0.4 123656 4920 ? Ss 22:43 0:00 php-fpm: master process (/usr/local/php-fpm/etc/php-fpm.conf)php-fpm 117577 0.0 0.4 123656 4676 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117578 0.0 0.4 123656 4676 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117579 0.0 0.4 123656 4676 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117580 0.0 0.4 123656 4676 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117581 0.0 0.4 123656 4680 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117582 0.0 0.4 123656 4680 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117583 0.0 0.4 123656 4680 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117584 0.0 0.4 123656 4680 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117585 0.0 0.4 123656 4680 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117586 0.0 0.4 123656 4680 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117587 0.0 0.4 123656 4680 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117588 0.0 0.4 123656 4680 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117589 0.0 0.4 123656 4684 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117590 0.0 0.4 123656 4684 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117591 0.0 0.4 123656 4684 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117592 0.0 0.4 123656 4684 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117593 0.0 0.4 123656 4684 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117594 0.0 0.4 123656 4684 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117595 0.0 0.4 123656 4684 ? S 22:43 0:00 php-fpm: pool wwwphp-fpm 117596 0.0 0.4 123656 4684 ? S 22:43 0:00 php-fpm: pool wwwroot 117602 0.0 0.0 112676 984 pts/0 R+ 22:43 0:00 grep --color=auto
Nginx介紹
lnmp架構介紹,mysql,php安裝,Nginx介紹