LNMP架构介绍:
MySQL安装:
cd /usr/local/src
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz = 下载安装包
tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz =解压安装包
mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql =解压完以后需要挪动到另外一个路径下面并且更改目录的名字
cd /usr/local/mysql =进入更改完以后的目录
useradd mysql = 创建一个新MYSQL新用户
mkdir /data/ = 创建一个data 目录 如果有那么可以省略
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql = 初始化完以后用命令echo $? 判断命令初始化是否正确 初始化出现错误:坏的解释器:没有那个文件或目录 使用命令安装yum install perl gcc kernel-devel datadir=/usr/local/mysql/data/mysql = 编译datadir需要写绝对路径
cp support-files/my-default.cnf /etc/my.cnf =拷贝一份配置文件到/etc/目录下并且改名稳my.cnf,然后就vim /etc/my.cnf 定义basedir 和 datadir 都需要定义绝对路径
cp support-files/mysql.server /etc/init.d/mysqld = 拷贝一份启动脚本的配置文件
vi /etc/init.d/mysqld =启动脚本文件也要定义basedir和datadir
/etc/init.d/mysqld start = 启动mysql服务
= 启动成功
代码语言:javascript复制[root@aming-01 mysql]# chkconfig --add mysqld 加入服务项
[root@aming-01 mysql]# chkconfig mysqld on 开机启动
PHP安装:
cd /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 = 创建一个新用户
cd 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 = 编译php文件
make && make install = 继续安装 make clean = 删除之前编译过的php文件
cp php.ini-production /usr/local/php-fpm/etc/php.ini =拷贝一份配置文件到另外一个目录下面去
vi /usr/local/php-fpm/etc/php-fpm.conf //写入如下内容(参考https://coding.net/u/aminglinux/p/aminglinux-book/git/blob/master/D15Z/php-fpm.conf = 浏览器打开然后写入到 php-fpm.conf ) 下面就是需要写入的代码
代码语言:javascript复制[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
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm =拷贝启动脚本到/etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm = 增加启动脚本权限
chkconfig --add php-fpm = 加入开机服务
chkconfig php-fpm on = 开启开机启动服务
service php-fpm start = 启动服务
ps aux |grep php-fpm =查看服务进程
编译问题1:缺少curl 解决方案:yum install -y libcurl-devel
Nginx介绍:
扩展 Nginx为什么比Apache Httpd高效:原理篇 http://www.toxingwang.com/linux-unix/linux-basic/1712.html apache和nginx工作原理比较 http://www.server110.com/nginx/201402/6543.html mod_php 和 mod_fastcgi以及php-fpm的比较 http://dwz.cn/1lwMSd
概念了解:CGI,FastCGI,PHP-CGI与PHP-FPM
http://www.nowamagic.net/librarys/veda/detail/1319/ https://www.awaimai.com/371.html