首页 > 数据库技术 > 详细

lnmp架构介绍,mysql,php安装,Nginx介绍

时间:2018-03-13 00:48:36      阅读:303      评论:0      收藏:0      [点我收藏+]
lnmp架构介绍

技术分享图片

MySQL安装

技术分享图片
1.首先下载软件包

[root@weixing01 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.移动目录并改名

[root@weixing01 src]# mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql

4.进入mysql目录

[root@weixing01 src]# cd /usr/local/mysql/
[root@weixing01 mysql]# ls
bin      data  include  man         README   share      support-files
COPYING  docs  lib      mysql-test  scripts  sql-bench

5.创建用户,目录并初始化

[root@weixing01 mysql]# useradd mysql
[root@weixing01 mysql]# mkdir /data/
[root@weixing01 mysql]# ls /data/
[root@weixing01 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

6.初始化:

./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
Installing 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 pages
2018-02-26 22:25:59 1622 [Note] InnoDB: The InnoDB memory heap is disabled
2018-02-26 22:25:59 1622 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-02-26 22:25:59 1622 [Note] InnoDB: Memory barrier is not used
2018-02-26 22:25:59 1622 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-02-26 22:25:59 1622 [Note] InnoDB: Using Linux native AIO

7.执行完成后马上执行

[root@weixing01 mysql]# echo $?
0

检验上一条是否正确,0为正确
8.复制配置文件,或更改自带文件

[root@weixing01 mysql]# cp support-files/my-default.cnf  /etc/my.cnf^C
[root@weixing01 mysql]# ls /etc/my.cnf
/etc/my.cnf
[root@weixing01 mysql]# rpm -qf /etc/my.cnf
mariadb-libs-5.5.56-2.el7.x86_64

[root@weixing01 mysql]# vim /etc/my.cnf

[mysqld]
datadir=/data/mysql
socket=/tmp/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

9.复制启动脚本

[root@weixing01 mysql]# ls support-files/
binary-configure  my-default.cnf       mysql-log-rotate
magic             mysqld_multi.server  mysql.server
[root@weixing01 mysql]# cp support-files/mysql.server  /etc/init.d/mysqld

10.更改启动脚本:
[root@weixing01 mysql]# vi /etc/init.d/mysqld


basedir=/usr/local/mysql
datadir=/data/mysql

11.设置开机启动

[root@weixing01 mysql]# chkconfig --add mysqld
[root@weixing01 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配置清空:

[root@weixing01 php-5.6.30]# make clean
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f 
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -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
![](http://i2.51cto.com/102?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)

报错

checking whether to enable calendar conversion support... no
checking whether to enable ctype functions... yes
checking for cURL support... yes
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
    easy.h should be in <curl-dir>/include/curl/

安装依赖包:

[root@weixing01 php-5.6.30]# yum install -y libcurl-devel
已加载插件:fastestmirror
base                                                                   | 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
![](http://i2.51cto.com/102?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)

完成
3.安装

[root@weixing01 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.查看文件结构:

[root@weixing01 php-5.6.30]# ls /usr/local/php-fpm/
bin  etc  include  lib  php  sbin  var
[root@weixing01 php-5.6.30]# ls /usr/local/php
bin  etc  include  lib  php
[root@weixing01 php-5.6.30]# ls /usr/local/php-fpm/sbin/
php-fpm
[root@weixing01 php-5.6.30]# ls /usr/local/php-fpm/var
log  run

5.查看配置是否正确:

[root@weixing01 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.修改配置文件:

[root@weixing01 php-5.6.30]# cp php.ini-production /usr/local/php-fpm/php.ini
[root@weixing01 php-5.6.30]# cd /usr/local/php-fpm/etc/
[root@weixing01 etc]# ls
pear.conf  php-fpm.conf.default
[root@weixing01 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

7.开启服务:

[root@weixing01 etc]# cd /usr/local/src/php-5.6.30
[root@weixing01 php-5.6.30]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@weixing01 php-5.6.30]# chmod 755 /etc/init.d/php-fpm 
[root@weixing01 php-5.6.30]# chkconfig --add php-fpm
[root@weixing01 php-5.6.30]# chkconfig php-fpm on
[root@weixing01 php-5.6.30]# service php-fpm start
Starting 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

[root@weixing01 php-5.6.30]# useradd php-fpm
[root@weixing01 php-5.6.30]# service php-fpm start
Starting php-fpm  done
[root@weixing01 php-5.6.30]# ps aux |grep php-fpm
root     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 www
php-fpm  117578  0.0  0.4 123656  4676 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117579  0.0  0.4 123656  4676 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117580  0.0  0.4 123656  4676 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117581  0.0  0.4 123656  4680 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117582  0.0  0.4 123656  4680 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117583  0.0  0.4 123656  4680 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117584  0.0  0.4 123656  4680 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117585  0.0  0.4 123656  4680 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117586  0.0  0.4 123656  4680 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117587  0.0  0.4 123656  4680 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117588  0.0  0.4 123656  4680 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117589  0.0  0.4 123656  4684 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117590  0.0  0.4 123656  4684 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117591  0.0  0.4 123656  4684 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117592  0.0  0.4 123656  4684 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117593  0.0  0.4 123656  4684 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117594  0.0  0.4 123656  4684 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117595  0.0  0.4 123656  4684 ?        S    22:43   0:00 php-fpm: pool www
php-fpm  117596  0.0  0.4 123656  4684 ?        S    22:43   0:00 php-fpm: pool www
root     117602  0.0  0.0 112676   984 pts/0    R+   22:43   0:00 grep --color=auto 

Nginx介绍

技术分享图片

lnmp架构介绍,mysql,php安装,Nginx介绍

原文:http://blog.51cto.com/13517254/2085814

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!