vagrant centos7 安装PHP 5.6笔记
[vagrant@localhost ~]$ sudo yum install -y wget vim
[vagrant@localhost ~]$ sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
#安装第三方源epel-release
[vagrant@localhost ~]$ sudo yum install epel-release
[vagrant@localhost ~]$ sudo vi /etc/yum.repos.d/remi.repo
将 [remi]
节点下的 enabled
的值由0
改为 1
。
列出 /etc/yum.repos.d
文件夹下的文件列表
[vagrant@localhost yum.repos.d]$ ls
CentOS-Base.repo CentOS-Sources.repo mysql-community.repo remi-glpi94.repo remi-php72.repo remi-safe.repo
CentOS-CR.repo CentOS-Vault.repo mysql-community-source.repo remi-modular.repo remi-php73.repo
CentOS-Debuginfo.repo CentOS-x86_64-kernel.repo remi-glpi91.repo remi-php54.repo remi-php74.repo
CentOS-fasttrack.repo epel.repo remi-glpi92.repo remi-php70.repo remi-php80.repo
CentOS-Media.repo epel-testing.repo remi-glpi93.repo remi-php71.repo remi.repo
没有需要安装的php 5.6
yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
sudo yum install --enablerepo=remi --enablerepo=remi-php56 php
sudo yum install --enablerepo=remi --enablerepo=remi-php56 php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-pecl-xdebug php-pecl-xhprof
sudo yum install --enablerepo=remi --enablerepo=remi-php56 php-cli php-curl php-json php-pdo php-mysql php-gd php-bcmath php-xml php-mbstring php-mcrypt php-redis php-crypto
配置Apache 配置文件
sudo vi /etc/httpd/conf/httpd.conf
将配置文件中<Directory "/var/www/html">
内的 AllowOverride None
改为 AllowOverride All
apachectl configtest # 测试配置文件格式是否正确
vagrant centos 启动之后:
==> default: Mounting shared folders...
default: /var/www/html => D:/workspace/centoslamp
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=1000,gid=1000 var_www_html /var/www/html
The error output from the command was:
mount: unknown filesystem type 'vboxsf'
我参考别人博客的处理方法是:
#安装 vagrant-vbguest 插件
vagrant plugin install vagrant-vbguest --plugin-clean-sources --plugin-source https://gems.ruby-china.com/
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Fetching micromachine-3.0.0.gem
Fetching vagrant-vbguest-0.24.0.gem
Installed the plugin 'vagrant-vbguest (0.24.0)'!
安装成功之后,重启 vagrant 虚拟机 vagrant reload
如果问题依旧,可尝试再次安装 vagrant-vbguest 插件,再次重启 vagrant 虚拟机
当出现类型下面的内容,好像是在自动开始安装 Virtualbox Guest Additions 组件了
[default] No Virtualbox Guest Additions installation found.
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
....
VirtualBox Guest Additions: Building the modules for kernel
3.10.0-1127.19.1.el7.x86_64.
Redirecting to /bin/systemctl start vboxadd.service
Redirecting to /bin/systemctl start vboxadd-service.service
Unmounting Virtualbox Guest Additions ISO from: /mnt
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/d/workspace/vagrant/centos/ => /vagrant
==> default: Mounting shared folders...
default: /var/www/html => D:/workspace/centoslamp
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
-- 复制表结构及数据到新表
CREATE TABLE 新表 SELECT * FROM 旧表
-- 只复制表结构到新表 即:让WHERE条件不成立.
CREATE TABLE 新表 SELECT * FROM 旧表 WHERE 1=2
Centos vhost,在 /etc/httpd/conf.d
添加Domain Name.conf
如: test1.local.conf
<VirtualHost *:80>
ServerName test1.local
ServerAlias test1.local
DocumentRoot /var/www/html/test1
<Directory /var/www/html/test1>
Options FollowSymLinks MultiViews
AllowOverride All
Require all granted
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/test1.local-error.log
CustomLog /var/log/httpd/test1.local-access.log combined
#RewriteEngine on
#RewriteCond %{SERVER_NAME} =test1.local
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
访问vhost
403:
尝试1:
修改同步文件夹的 用户组和用户
config.vm.synced_folder "D:/workspace/centoslamp", "/var/www/html", create: true, owner: "vagrant", group: "apache"
尝试2:
setenforce 0
修改配置文件 /etc/selinux/config
,将 SELINUX=enforcing
改为 SELINUX=disabled
最终可以访问到了