设为首页 收藏本站
查看: 847|回复: 0

[经验分享] lnmp架构介绍,mysql,php安装,Nginx介绍

[复制链接]

尚未签到

发表于 2018-12-12 10:43:11 | 显示全部楼层 |阅读模式
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.运维网.com/102"=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 /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.运维网.com/102"=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介绍





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-650463-1-1.html 上篇帖子: LNMP架构 安装PHP 下篇帖子: php 微信开发模式小结
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表