当前位置: 移动技术网 > IT编程>开发语言>PHP > vagrant快速搭建LNMP环境并且打包带走留着以后用

vagrant快速搭建LNMP环境并且打包带走留着以后用

2018年01月12日  | 移动技术网IT编程  | 我要评论

  不多说废话,全文文字,照着输就没问题

 

vagrant下载 可以到VirtualBox的官网进行下载:  https://www.virtualbox.org/wiki/Downloads vagrant安装 下载vagrant下的centos7的box 贴一个别人上传好的云盘链接 https://pan.baidu.com/s/1kW18LBD 创建一个新的centos7的虚拟机 vagrant box add mycentos CentOS-7.1.1503-x86_64-netboot.box 看看vagrant列表里有没有 vagrant box list vagrant init mycentos 配置一下Vagrantfile文件 加上下面两条,为了添加ssh验证 config.ssh.username = "vagrant" config.ssh.password = "vagrant" 其他比如共享文件夹和端口转发视个人情况自己百度之 更新yum源 yum update 安装wget yum install wget 改yum源,用163的 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup wget http://mirrors.163.com/.help/CentOS6-Base-163.repo yum makecache 安装mysql wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm yum localinstall mysql-community-release-el7-5.noarch.rpm yum repolist enabled | grep "mysql.*-community.*" yum install mysql-community-server 改密码 mysql -u root use mysql select user,password,host from user; update user set password=PASSWORD('root') where user='root'; FLUSH PRIVILEGES; 安装nginx 创建nginx不能登陆用户 groupadd nginx useradd -g nginx nginx -s /bin/false 安装一些支持库 一. gcc 安装 安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装: yum install gcc-c++ 二. PCRE pcre-devel 安装 PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。命令: yum install -y pcre pcre-devel 三. zlib 安装 zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。 yum install -y zlib zlib-devel 四. OpenSSL 安装 OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。 nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。 yum install -y openssl openssl-devel 下载nginx wget -c https://nginx.org/download/nginx-1.10.1.tar.gz 解压 tar -zxvf nginx-1.10.1.tar.gz cd nginx-1.10.1 配置 ./configure 编译安装 make make install 安装php7.1 下载php7 wget -O php7.tar.gz http://cn2.php.net/get/php-7.1.1.tar.gz/from/this/mirror 解压 tar -xvf php7.tar.gz cd php-7.0.4 安装依赖包 yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel 解决libmcrypt库没有的问题 yum install -y epel-release yum install -y libmcrypt-devel 编译配置 ./configure \ --prefix=/usr/local/php \ --with-config-file-path=/etc \ --enable-fpm \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-soap \ --with-libxml-dir \ --with-xmlrpc \ --with-openssl \ --with-mcrypt \ --with-mhash \ --with-pcre-regex \ --with-sqlite3 \ --with-zlib \ --enable-bcmath \ --with-iconv \ --with-bz2 \ --enable-calendar \ --with-curl \ --with-cdb \ --enable-dom \ --enable-exif \ --enable-fileinfo \ --enable-filter \ --with-pcre-dir \ --enable-ftp \ --with-gd \ --with-openssl-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib-dir \ --with-freetype-dir \ --enable-gd-native-ttf \ --enable-gd-jis-conv \ --with-gettext \ --with-gmp \ --with-mhash \ --enable-json \ --enable-mbstring \ --enable-mbregex \ --enable-mbregex-backtrack \ --with-libmbfl \ --with-onig \ --enable-pdo \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-zlib-dir \ --with-pdo-sqlite \ --with-readline \ --enable-session \ --enable-shmop \ --enable-simplexml \ --enable-sockets \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --enable-wddx \ --with-libxml-dir \ --with-xsl \ --enable-zip \ --enable-mysqlnd-compression-support \ --with-pear \ --enable-opcache 安装 make && make install 配置环境变量 vim /etc/profile export PATH=$PATH:/usr/local/php/bin source /etc/profile 置php-fpm cp php.ini-production /etc/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm 启动php-fpm /etc/init.d/php-fpm start 打包vagrant vagrant package --base mycentos_default_1515579423331_47721 --output centos7-lnmp.box

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网