LNMP架构介绍
MySQL安装
开始安装首先进入/usr/local/src目录下,把所有安装包统一放到这个目录下方便查找
[[email protected] src]# cd /usr/local/src ##进入/usr/local/src目录
下载安装包https://coding.net/u/aminglinux/p/resource/git/blob/master/README.md这个网站里边有可下载的安装包
[[email protected] src]# wget http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
下载完成后解压
[[email protected] src]# tar zxvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
解压完成后要把这个目录移动到另外一个路径下然后改名字,移动完成后看看结果是否一样
[[email protected] src]# mv mysql-5.6.39-linux-glibc2.12-x86_64 /usr/local/mysql
[[email protected] src]# ls /usr/local/mysql/ ##查看结果
bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files
进入刚才改完名字的目录下/usr/local/mysql/
[[email protected] src]# cd /usr/local/mysql/
创建usr的用户,创建data目录
[[email protected] mysql]# useradd mysql
[[email protected] mysql]# mkdir /data/
然后初始化,初始化的过程是把一些mysql启动他所需要的目录生成,安装完成后出现两个OK,如果不放心echo $?看一看是不是0
[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
[[email protected] mysql]# echo $?
把配置文件拷贝过去,然后编辑下
[[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf
[[email protected] mysql]# vim /etc/my.cnf
拷贝启动脚本,然后编辑它
[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql]# vim /etc/init.d/mysqld
启动
[[email protected] mysql]# /etc/init.d/mysqld start
然后可以把mysqld加入到服务列表里边去,让他开机启动
[[email protected] mysql]# chkconfig --add mysqld ##加入列表
[[email protected] mysql]# chkconfig mysqld on ##开机启动
PHP安装
在lamp的课程中做个PHP的实验删除PHP,
开始安装
略过几步之前做过的如下
进入/usr/local/src/
下载wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
解压 tar zxf php-5.6.30.tar.gz
创建用户 useradd -s /sbin/nologin php-fpm
进入解压过的安装包
[[email protected] src]# cd php-5.6.32
编译参数
[[email protected] php-5.6.32]# ./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
安装过程中报错少cURL,安装cURL,安装后继续运行
[[email protected] php-5.6.32]# yum install libcurl-devel ##安装curl
安装完成
make && make install
[[email protected] php-5.6.32]# make && make install
[[email protected] php-5.6.32]# ls /usr/local/php-fpm/ ##lnmp
bin etc include lib php sbin var
[[email protected] php-5.6.32]# ls /usr/local/php/ ##lamp
bin etc include lib php
[[email protected] php-5.6.32]# ls /usr/local/php-fpm/sbin/
php-fpm ##这个文件就是用来启动php-fpm的
[[email protected] php-5.6.32]# ls /usr/local/php-fpm/var/log ##存放日志
[[email protected] php-5.6.32]# ls /usr/local/php-fpm/var/run ##存放PID的
想启动需要配置服务,首先拷贝php.ini-production到/usr/local/php-fpm/etc/php.ini
[[email protected] php-5.6.32]# cp php.ini-production /usr/local/php-fpm/etc/php.ini
编辑php-fpm.conf
[[email protected] php-5.6.32]# cd /usr/local/php-fpm/etc/ ##到这个目录下来
[[email protected] etc]# vim php-fpm.conf ##这个目录没有php-fpm.conf文件vim直接创建编辑,编辑这个配置文件到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 ##log路径
[www] ##模块的名字
listen = /tmp/php-fcgi.sock ##监听的地址
listen.mode = 666 ##定义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
拷贝启动脚本
[[email protected] etc]# cd /usr/local/src/php-5.6.32/ ##进入到源码包目录
[[email protected] php-5.6.32]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm ##sapi/fpm/init.d.php-fpm启动脚本放到/etc/init.d/php-fpm下
加入服务列表首先改权限
[[email protected] php-5.6.32]# chmod 755 /etc/init.d/php-fpm
启动
[[email protected] php-5.6.32]# chkconfig --add php-fpm
[[email protected] php-5.6.32]# chkconfig php-fpm on ##开机启动
[[email protected] php-5.6.32]# service php-fpm start
Nginx介绍
Nginx俄国人开发,Nginx静态文件处理能力比apache强很多,
原文地址:http://blog.51cto.com/8043410/2158582