LAMP架構下,而後搭建LNMP架構 1.首先查看mysql是否啓動 ps aux |grep mysql 2.刪除目錄 rm -rf /usr/local/mysql/ 3.刪除啓動的腳本 rm -rf /etc/init.d/mysqld 4.而後其餘步驟相同
[root@hanfeng ~]# cd /usr/local/src [root@hanfeng src]#
[root@hanfeng src]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
[root@hanfeng src]# tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
[root@hanfeng src]# mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql [root@hanfeng src]#
[root@hanfeng src]# ls /usr/local/mysql bin data include man README share support-files COPYING docs lib mysql-test scripts sql-bench [root@hanfeng src]#
[root@hanfeng src]# cd /usr/local/mysql [root@hanfeng mysql]#
[root@hanfeng mysql]# useradd mysql [root@hanfeng mysql]# mkdir /data/ [root@hanfeng mysql]#
[root@hanfeng mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db: Data::Dumper
yum install -y perl-Data-Dumper
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
yum install -y libaio
[root@hanfeng mysql]# echo $? 0 [root@hanfeng mysql]#
[root@hanfeng mysql]# cat /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-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
拷貝後php
[root@hanfeng mysql]# cp support-files/my-default.cnf /etc/my.cnf
[root@hanfeng mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@hanfeng mysql]# vim /etc/init.d/mysqld 在文件中配置 basedir=/usr/local/mysql datadir=/data/mysql 而後保存退出
[root@hanfeng mysql]# /etc/init.d/mysqld start Starting MySQL.Logging to '/data/mysql/hanfeng.err'. . SUCCESS! [root@hanfeng mysql]#
[root@hanfeng mysql]# ps aux |grep mysql root 2295 0.0 0.1 113252 1608 pts/0 S 22:41 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/hanfeng.pid mysql 2403 1.9 44.6 973512 451180 pts/0 Sl 22:41 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/hanfeng.err --pid-file=/data/mysql/hanfeng.pid root 2429 0.0 0.0 112656 992 pts/0 R+ 22:41 0:00 grep --color=auto mysql [root@hanfeng mysql]#
[root@hanfeng mysql]# chkconfig --add mysqld [root@hanfeng mysql]# chkconfig mysqld on [root@hanfeng mysql]#
[root@hanfeng mysql]# service mysqld stop Shutting down MySQL.. SUCCESS! [root@hanfeng mysql]# service mysqld start Starting MySQL. SUCCESS!
[root@hanfeng ~]# cd /usr/local/src/ [root@hanfeng src]#
[root@hanfeng src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
[root@hanfeng src]# tar zxf php-5.6.30.tar.gz [root@hanfeng src]# ls mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz php-5.6.30 php-5.6.30.tar.gz [root@hanfeng src]#
[root@hanfeng src]# useradd -s /sbin/nologin php-fpm [root@hanfeng src]#
[root@hanfeng ~]# cd /usr/local/src/php-5.6.30 [root@hanfeng php-5.6.30]#
[root@hanfeng php-5.6.30]# ./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 for cc... no checking for gcc... no configure: error: in `/usr/local/src/php-5.6.30': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details
yum install -y gcc
configure: error: xml2-config not found. Please check your libxml2 installation.
[root@hanfeng php-5.6.30]# yum install -y libxml2-devel
configure: error: Cannot find OpenSSL's <evp.h>
yum install -y openssl-devel
configure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/
yum install -y libcurl-devel 或 yum install -y curl curl-devel
configure: error: jpeglib.h not found.
yum install -y libjpeg-devel
configure: error: png.h not found.
yum install -y libpng yum install -y libpng-devel
configure: error: freetype-config not found.
yum install -y freetype-devel
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
yum install -y epel-release yum install -y libmcrypt-devel
[root@hanfeng php-5.6.30]# echo $? 0 [root@hanfeng php-5.6.30]#
[root@hanfeng php-5.6.30]# make && make instal
[root@hanfeng php-5.6.30]# echo $? 0 [root@hanfeng php-5.6.30]#
[root@hanfeng php-5.6.30]# ls /usr/local/php-fpm/ bin etc include lib php sbin var [root@hanfeng php-5.6.30]# ls /usr/local/php-fpm/sbin/ //在sbin目錄下有一個php-fpm文件,就是用來啓動php-fpm的 php-fpm [root@hanfeng php-5.6.30]# ls /usr/local/php-fpm/var/ //在var目錄下有 log 和 run 文件,log文件存放日誌的,run存放pid的,日誌和pid路徑都是能夠指定的 log run [root@hanfeng php-5.6.30]#
/usr/local/php-fpm/sbin/php-fpm -m 查看模塊 /usr/local/php-fpm/sbin/php-fpm -i /usr/local/php-fpm/sbin/php-fpm -t 測試配置文件文件語法
[root@hanfeng php-5.6.30]# /usr/local/php-fpm/sbin/php-fpm -t [03-Jan-2018 00:10:44] ERROR: failed to open configuration file '/usr/local/php-fpm/etc/php-fpm.conf': No such file or directory (2) [03-Jan-2018 00:10:44] ERROR: failed to load configuration file '/usr/local/php-fpm/etc/php-fpm.conf' [03-Jan-2018 00:10:44] ERROR: FPM initialization failed [root@hanfeng php-5.6.30]#
[root@hanfeng php-5.6.30]# cp php.ini-production /usr/local/php-fpm/etc/php.ini [root@hanfeng php-5.6.30]#
[root@hanfeng php-5.6.30]# cd /usr/local/php-fpm/etc/ [root@hanfeng etc]# ls pear.conf php-fpm.conf.default php.ini [root@hanfeng etc]#
[root@hanfeng etc]# vim php-fpm.conf 去https://coding.net/u/aminglinux/p/aminglinux-book/git/blob/master/D15Z/php-fpm.conf拷貝樣例 拷貝到文件中 [global] //全局配置 pid = /usr/local/php-fpm/var/run/php-fpm.pid //定義PID error_log = /usr/local/php-fpm/var/log/php-fpm.log //錯誤日誌 [www] //模塊名字,啓動服務的時候就能看到 listen = /tmp/php-fcgi.sock //監聽的地址 listen.mode = 666 //當監聽的是sock的時候,這個語句纔會生效,這個語句用來定義sock文件權限的 user = php-fpm //用戶,定義是哪一個用戶啓動的 group = php-fpm // 組,定義是哪一個組啓動的 pm = dynamic //進程相關信息 pm.max_children = 50 //進程相關信息 pm.start_servers = 20 //進程相關信息 pm.min_spare_servers = 5 //進程相關信息 pm.max_spare_servers = 35 //進程相關信息 pm.max_requests = 500 //進程相關信息 rlimit_files = 1024 而後保存退出
linsten 能夠監聽sock、tcp 能夠寫成 linsten = 127.0.0.1:9000(默認端口就是9000,可自定義),通常監聽的到是「127.0.0.1 」IP,由於php-fpm這個服務是針對內部使用的、在本機上用的,也就是說Nginx和php一般是在一臺機器上,二者之間通訊直接使用內部網絡就能夠了;在這塊選擇的linsten配置不一樣,到以後的配置Nginx配置,也就是告訴Nginx到哪裏找php的配置語句也是不一樣css
[root@hanfeng etc]# cd /usr/local/src/php-5.6.30/ [root@hanfeng php-5.6.30]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm [root@hanfeng php-5.6.30]#
[root@hanfeng php-5.6.30]# chmod 755 /etc/init.d/php-fpm [root@hanfeng php-5.6.30]# chkconfig --add php-fpm [root@hanfeng php-5.6.30]# chkconfig php-fpm on [root@hanfeng php-5.6.30]# service php-fpm start Starting php-fpm done [root@hanfeng php-5.6.30]# 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-fpm 0:關 1:關 2:開 3:開 4:開 5:開 6:關 [root@hf-01 php-5.6.30]#
[root@hanfeng php-5.6.30]# ps aux |grep php-fpm root 2386 0.0 0.4 124184 4936 ? Ss 17:04 0:00 php-fpm: master process (/usr/local/php-fpm/etc/php-fpm.conf) php-fpm 2387 0.0 0.4 124184 4700 ? S 17:04 0:00 php-fpm: pool www php-fpm 2388 0.0 0.4 124184 4700 ? S 17:04 0:00 php-fpm: pool www php-fpm 2389 0.0 0.4 124184 4700 ? S 17:04 0:00 php-fpm: pool www php-fpm 2390 0.0 0.4 124184 4700 ? S 17:04 0:00 php-fpm: pool www php-fpm 2391 0.0 0.4 124184 4704 ? S 17:04 0:00 php-fpm: pool www php-fpm 2392 0.0 0.4 124184 4708 ? S 17:04 0:00 php-fpm: pool www php-fpm 2393 0.0 0.4 124184 4708 ? S 17:04 0:00 php-fpm: pool www php-fpm 2394 0.0 0.4 124184 4708 ? S 17:04 0:00 php-fpm: pool www php-fpm 2395 0.0 0.4 124184 4708 ? S 17:04 0:00 php-fpm: pool www php-fpm 2396 0.0 0.4 124184 4708 ? S 17:04 0:00 php-fpm: pool www php-fpm 2397 0.0 0.4 124184 4708 ? S 17:04 0:00 php-fpm: pool www php-fpm 2398 0.0 0.4 124184 4708 ? S 17:04 0:00 php-fpm: pool www php-fpm 2399 0.0 0.4 124184 4708 ? S 17:04 0:00 php-fpm: pool www php-fpm 2400 0.0 0.4 124184 4708 ? S 17:04 0:00 php-fpm: pool www php-fpm 2401 0.0 0.4 124184 4708 ? S 17:04 0:00 php-fpm: pool www php-fpm 2402 0.0 0.4 124184 4708 ? S 17:04 0:00 php-fpm: pool www php-fpm 2403 0.0 0.4 124184 4708 ? S 17:04 0:00 php-fpm: pool www php-fpm 2404 0.0 0.4 124184 4708 ? S 17:04 0:00 php-fpm: pool www php-fpm 2405 0.0 0.4 124184 4708 ? S 17:04 0:00 php-fpm: pool www php-fpm 2406 0.0 0.4 124184 4708 ? S 17:04 0:00 php-fpm: pool www root 2408 0.0 0.0 112676 988 pts/0 R+ 17:04 0:00 grep --color=auto php-fpm [root@hanfeng php-5.6.30]#
apache和nginx工做原理比較mysql
概念瞭解git