vagrant快速搭建LNMP環境而且打包帶走留着之後用

  很少說廢話,全文文字,照着輸就沒問題php


 

vagrant下載
能夠到VirtualBox的官網進行下載: 
vagrant安裝
下載vagrant下的centos7的box
貼一個別人上傳好的雲盤連接
建立一個新的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
yum makecache
安裝mysql
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
安裝一些支持庫
一. 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
解壓
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-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zipmysql

安裝
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
相關文章
相關標籤/搜索