//当前网络获取情况
ìfconfig -a
//手动获取网络
ifup eth0

//自动获取网络
vi /etc/sysconfig/network-scripts/ifcfg-eth0
修改 ONBOOT=no
为 ONBOOT+yes

//重启网络自动获取
service network restart
挂载光盘
mkdir dvd1 dvd2
//挂载光盘iso 到dvd1
mount -o loop -t iso9660 CentOS-6.9-i386-bin-DVD1.iso dvd1
mount -o loop -t iso9660 CentOS-6.9-i386-bin-DVD2.iso dvd2
yum版LNMP环境
yum源的配置
/etc/yum.repo.d/*.repo
cd /etc/yum.repos.d/
//备份线上源
mv CentOS-Base.repo CentOS-Base.repo.bak
//源配置
vi CentOs-Media.repo
baseurl = file://media/dvd1/
file://media/dvd2/
enabled = 1

//清除yum源环境
yum clean all
//生成yum新环境
yum make cache
//测试安装tree
yum -y install tree
//查找是否包含软件
yum search nginx
安装nginx
nginx官网-documentation-installing nginx- installation on linux
http://nginx.org/en/linux_packages.html

vi /etc/yum.repos.d/nginx.repo
按文档粘贴内容保存
//安装nginx
yum -y install nginx
//查找nginx位置
whereis nginx
cd /etc/nginx/
//nginx.conf: 主配置文件
//conf.d/default.conf: nginx里包裹文件
//开启nginx
nginx
//查看运行状态
ps - aux | grep nginx
//查看防火墙
service iptables status
//关闭防火墙
service iptables stop
//在default.conf中默认访问路径为/usr/share/nginx/html

安装php
//安装php
yum -y install php
//查看安装php版本
php -v
//nginx 需要php-fpm来识别php
yum -y install php-fpm
//启动php-fpm
service php-fpm start
//编辑nginx配置文件
vi /etc/nginx/conf.d/default.conf
找到 pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

//重启nginx
nginx -s reload
//查看nginx日志文件
cd /var/log/nginx/
access.log 访问日志
error.log 出错日志
安装mysql
//安装mysql服务端和客户端
yum -y install mysql-server mysql
//启动 mysql
service mysqld start
//按提示设置密码
/usr/bin/mysqladmin -u root password '000000'
//重启mysql
service mysqld restart
//打开mysql
mysql -u root -p
//编辑 php mysql 测试代码
//查看 php-fpm 日志
cd /var/log/php-fpm/
//安装php-mysql模块
yum -y install php-mysql
service php-fpm restart
yum 安装优缺点
1.配置yum源,本地源,线上源
2.yum -y install nginx php php-fpm mysql-server mysql php-mysql
3.配置nginx,将php的请求转发给php-fpm
4.出错看日志,搜索
优点:方便便捷,不用考虑包依赖
缺点:不能按需安装, 受源的限制,安装的版本也比较低
源码版LNMP环境
源码文件的获取
Nginx源码:http://nginx.org/
PHP源码: http://www.php.net/
MySQL编译版: https://www.mysql.com/
nginx
download-Stable version (稳定版本)
wget http://nginx.org/download/nginx-1.16.1.tar.gz
php
wget https://www.php.net/distributions/php-5.6.40.tar.gz
mysql
download-customer-mysql community server-looking for previous
-linux-generic(编译版)
wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.47-linux-glibc2.12-i686.tar.gz
编译环境
gcc gcc-c++
yum -y install gcc gcc-c++
nginx
官网-文档-building nginx from sources 最下方有步骤
//解压
tar xzf nginx-1.16.1.tar.gz
cd nginx-1.16.1
//源码安装:1.配置2.编译3.安装
./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=../pcre-8.44 --with-zlib=../zlib-1.2.11
//安装nginx依赖
yum -y install openssl openssl-devel
//无错误信息后编译
make
//pcre 错误
tar xzf pcre-8.41.tar.gz
tar xzf zlib-1.2.11.tar.gz
//继续配置并make 无错误
make install
源码安装php
https://www.php.net/manual/zh/install.unix.nginx.php
tar zxf php-x.x.x
cd ../php-x.x.x
./configure --enable-fpm --with-mysql --with-mysqli --with-pdo-mysql
//安装php依赖 libxml2-devel
yum -y insatll libxml2-devel
make
make insatll
mysql
tar xzf mysql-5.6.47-linux-glibc2.12-i686.tar.gz

https://dev.mysql.com/doc/refman/5.6/en/binary-installation.html
find / -name mysql.sock
//默认:/tmp/mysql.sock
cp my.cnf /etc/
vim /etc/my.cnf
//添加
[client]
socket=/temp/mysql.sock
依赖包

优缺点
优点:按需安装版本选择灵活
缺点:依赖包解决繁琐,安装步骤繁琐
网友评论