学习linux第四十八天

LNMP

lnmp和lamp的区别

提供web功能的是不是apache了,二十nginx

php作为独立的服务存在了,不在向lamp那样作为一个模块存在,这个服务叫做php-fpm

nginx直接处理静态请求,动态的交给php-fpm,nginx处理静态文件比apache快很多,底层不一样导致的

 
mysql安装
[root@HANLIN ~]#rm -rf /usr/local/mysql (删除原来lamp的mysql安装包)
[root@HANLIN ~]# rm -rf /etc/init.d/mysqld (删除mysqld的启动服务)
[root@HANLIN ~]#rm -rf /etc/my.cnf (删除mysql的配置文件)
 
[root@hanlin src]#wget http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
[root@hanlin local]#rm -rf /usr/local/mysql
[root@hanlin local]# rm -rf /etc/init.d/
functions mysqld netconsole network README 
[root@hanlin local]# rm -rf /etc/init.d/mysqld 
[root@hanlin local]# rm -rf /etc/my.cnf
[root@hanlin local]# cd src
[root@hanlin src]#mv mysql-5.6.39-linux-glibc2.12-x86_64 /usr/local/mysql
[root@hanlin mysql]# rm -rf data
[root@hanlin mysql]#mkdir data
[root@hanlin mysql]# ll
总用量 48
drwxr-xr-x. 2 root root 4096 11月 22 14:59 bin
-rw-r--r--. 1 7161 31415 17987 12月 9 2017 COPYING
drwxr-xr-x. 2 root root 6 11月 22 15:03 data
drwxr-xr-x. 2 root root 55 11月 22 14:59 docs
drwxr-xr-x. 3 root root 4096 11月 22 14:59 include
drwxr-xr-x. 3 root root 4096 11月 22 14:59 lib
drwxr-xr-x. 4 root root 30 11月 22 14:59 man
drwxr-xr-x. 10 root root 4096 11月 22 14:59 mysql-test
-rw-r--r--. 1 7161 31415 2496 12月 9 2017 README
drwxr-xr-x. 2 root root 30 11月 22 14:59 scripts
drwxr-xr-x. 28 root root 4096 11月 22 14:59 share
drwxr-xr-x. 4 root root 4096 11月 22 14:59 sql-bench
drwxr-xr-x. 2 root root 136 11月 22 14:59 support-files
[root@hanlin mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
[root@hanlin mysql]# echo $?
0
[root@hanlin mysql]#cp support-files/my-default.cnf /etc/my.cnf
[root@hanlin mysql]# vim !$
vim /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data/mysql
port = 3306
server_id = 128
socket = /tmp/mysql.sock
[root@hanlin mysql]#cp support-files/mysql.server /etc/init.d/mysqld
[root@hanlin mysql]# vim !$
vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data/mysql
 
[root@hanlin mysql]# /etc/init.d/mysqld restart (mysql启动出错信息)
ERROR! MySQL server PID file could not be found!
Starting MySQL... ERROR! The server quit without updating PID file (/usr/local/mysql/data/mysql/hanlin.pid).
[root@hanlin mysql]#ps -ef |grep mysql
root 1210 1 0 14:52 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data/mysql --pid-file=/usr/local/mysql/data/mysql/hanlin.pid
mysql 1535 1210 0 14:52 ? 00:00:04 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mariadb/mariadb.log --pid-file=/usr/local/mysql/data/mysql/hanlin.pid --socket=/tmp/mysql.sock --port=3306
root 3564 1791 0 15:31 pts/0 00:00:00 grep --color=auto mysql
[root@hanlin mysql]#kill -9 1210
[root@hanlin mysql]# kill -9 1535
[root@hanlin mysql]#kill -9 3564
-bash: kill: (3564) - 没有那个进程
[root@hanlin mysql]#ps -ef |grep mysql
root 3581 1791 0 15:31 pts/0 00:00:00 grep --color=auto mysql
[root@hanlin mysql]#/etc/init.d/mysqld start
Starting MySQL. SUCCESS! 
[root@hanlin mysql]#chkconfig --add mysqld  (把mysqld加入到服务列表里去)
[root@hanlin mysql]# chkconfig mysqld on (开机启动)
[root@hanlin mysql]#systemctl stop mysqld.service 
[root@hanlin mysql]# systemctl start mysqld.service 
php安装
 
[root@hanlin src]#wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
[root@hanlin php-5.6.30]# tar -zxvf php-5.6.30.tar.gz 
[root@hanlin local]# useradd -s /sbin/nologin php-fpm[root@hanlin php-5.6.30]# cd php-5.6.30/
[root@hanlin php-5.6.30]#
./configure --prefix=/usr/local/php-fpm --with-config-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
 
 
报错信息
configure: error: xml2-config not found. Please check your libxml2 installation.[root@hanlin php-5.6.30]# yum -y install libxml2-devel libxml2

[root@hanlin php-5.6.30]# 
[root@hanlin php-5.6.30]# fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-
bash: fpm: 未找到命令...
[root@hanlin php-5.6.30]# 
[root@hanlin php-5.6.30]# mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-
-bash: --with-pdo-mysql=/usr/local/mysql: 没有那个文件或目录
[root@hanlin php-5.6.30]# 
[root@hanlin php-5.6.30]# sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-
bash: --with-libxml-dir: 未找到命令...
[root@hanlin php-5.6.30]# 
[root@hanlin php-5.6.30]# freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-
bash: freetype-dir: 未找到命令...
[root@hanlin php-5.6.30]# 
[root@hanlin php-5.6.30]# native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-
bash: native-ttf: 未找到命令...
[root@hanlin php-5.6.30]# 
[root@hanlin php-5.6.30]# openssl

 

configure: error: Cannot find OpenSSL's <evp.h>
[root@hanlin php-5.6.30]# yum install openssl openssl-devel -y
configure: error: Please reinstall the libcurl distribution -     easy.h should be in <curl-dir>/include/curl/
yum install curl curl-devel
configure: error: jpeglib.h not found.
[root@hanlin php-5.6.30]# yum -y install libjpeg-devel
configure: error: png.h not found.
yum install libpng-devel libpng
configure: error: freetype-config not found.
yum install freetype-devel
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
[root@hanlin php-5.6.30]# yum install -y libmcrypt-devel
[root@hanlin php-5.6.30]# yum list "libmcrypt*" (不确定什么包,用yum list查找)
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* epel: mirrors.ustc.edu.cn
* extras: mirrors.163.com
* updates: mirrors.tuna.tsinghua.edu.cn
已安装的软件包
libmcrypt.x86_64 2.5.8-13.el7 @epel
libmcrypt-devel.x86_64 2.5.8-13.el7 @epel
 

 
 
 
 
[root@hanlin php-5.6.30]# make && make install
Installing shared extensions: /usr/local/php-fpm/lib/php/extensions/no-debug-non-zts-20131226/
Installing PHP CLI binary: /usr/local/php-fpm/bin/
Installing PHP CLI man page: /usr/local/php-fpm/php/man/man1/
Installing PHP FPM binary: /usr/local/php-fpm/sbin/
Installing PHP FPM config: /usr/local/php-fpm/etc/
Installing PHP FPM man page: /usr/local/php-fpm/php/man/man8/
Installing PHP FPM status page: /usr/local/php-fpm/php/php/fpm/
Installing PHP CGI binary: /usr/local/php-fpm/bin/
Installing PHP CGI man page: /usr/local/php-fpm/php/man/man1/
Installing build environment: /usr/local/php-fpm/lib/php/build/
Installing header files: /usr/local/php-fpm/include/php/
Installing helper programs: /usr/local/php-fpm/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php-fpm/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php-fpm/lib/php/
[PEAR] Archive_Tar - installed: 1.4.0
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util - installed: 1.3.0
[PEAR] PEAR - installed: 1.10.1
Wrote PEAR system config file at: /usr/local/php-fpm/etc/pear.conf
You may want to add: /usr/local/php-fpm/lib/php to your php.ini include_path
/usr/local/src/php-5.6.30/build/shtool install -c ext/phar/phar.phar /usr/local/php-fpm/bin
ln -s -f phar.phar /usr/local/php-fpm/bin/phar
Installing PDO headers: /usr/local/php-fpm/include/php/ext/pdo/
[root@hanlin php-5.6.30]# echo $?
0

 
安装完毕
 
 
[root@hanlin /]# /usr/local/php-fpm/sbin/php-fpm -m (sbin是放置php启动文件的夹子)
[PHP Modules]
cgi-fcgi
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gd
hash
iconv
json
libxml
mbstring
mcrypt
mysql
mysqli
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

 
[root@hanlin /]# cd /usr/local/php-fpm/
[root@hanlin php-fpm]#ll
总用量 0
drwxr-xr-x. 2 root root 132 11月 23 18:29 bin
drwxr-xr-x. 2 root root 51 11月 23 18:29 etc
drwxr-xr-x. 3 root root 17 11月 23 18:29 include
drwxr-xr-x. 3 root root 17 11月 23 18:29 lib
drwxr-xr-x. 4 root root 28 11月 23 18:29 php
drwxr-xr-x. 2 root root 21 11月 23 18:29 sbin
drwxr-xr-x. 4 root root 28 11月 23 18:29 var
[root@hanlin php-fpm]#ls var
log run  (log是放日志文件的,run是放pid的)

 
[root@hanlin php-fpm]# cp /usr/local/src/php-5.6.30/php.ini-
php.ini-development  (开发环境)php.ini-production (生产环境)
[root@hanlin php-fpm]#cp /usr/local/src/php-5.6.30/php.ini-production /usr/local/php-fpm/etc/php.ini
[root@hanlin php-fpm]#ls !$
ls /usr/local/php-fpm/etc/php.ini
/usr/local/php-fpm/etc/php.ini

 
[root@hanlin php-fpm]#cd etc
[root@hanlin etc]#ll
总用量 100
-rw-r--r--. 1 root root 1277 11月 23 18:29 pear.conf
-rw-r--r--. 1 root root 22826 11月 23 18:29 php-fpm.conf.default
-rw-r--r--. 1 root root 73685 11月 23 18:38 php.ini
[root@hanlin etc]# vim php-fpm.conf
[global]
pid = /usr/local/php-fpm/var/run/php-fpm.pid
error_log = /usr/local/php-fpm/var/log/php-fpm.log
[www]
listen = /tmp/php-fcgi.sock
listen.mode = 666
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

 
[root@hanlin etc]#cp /usr/local/src/php-5.6.30/sapi/fpm/init.d.php-fpm /etc/init.d/php-f (拷贝启动脚本)
[root@hanlin etc]#chkconfig --add php-fpm
[root@hanlin etc]# chkconfig php-fpm on
[root@hanlin etc]#systemctl start php-fpm
[root@hanlin etc]# /usr/local/php-fpm/sbin/php-fpm -t
[24-Nov-2018 02:45:16] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf test is successful


 
nginx 官网nginx.org 最新版本1.13 稳定版1.12

 
 
 

 

 

转载于:https://my.oschina.net/u/3867255/blog/2954274

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值