一、安裝Apachephp
這個就不手動安裝了,直接上腳本執行html
bash apache.shmysql
如下爲腳本的內容:linux
#!/bin/bash
version=`lsb_release -a|grep Release`
a=${version#*:}
if [ `echo ${a} | awk -v tem=6.8 '{print($a<=tem)? "0":"1"}'` -eq "0" ]
then
#不大於6.8
url="http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm"
rpm -Uvh "${url%?}" #
url="http://rpms.famillecollet.com/enterprise/remi-release-6.rpm"
rpm -Uvh "${url%?}" #
else
#大於6.8
yum install epel-release
url="http://rpms.famillecollet.com/enterprise/remi-release-7.rpm"
rpm -Uvh "${url%?}" #
fi
yum install -y --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof memcached php-pecl-memcache mysql mysql-server mysql-devel libmemcached libmemcached-devel
yum install -y httpd
service mysqld start
service httpd startsql
二、安裝PHPapache
1.刪除之前的php版本(跟上面刪除mysql的命令是同樣的)vim
先查看安全
rpm -qa | grep php
再刪除bash
yum remove 文件名服務器
2. 配置yum源
事先確認yum源的連接是否是有效的。
yum install epel-release
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
3. 確認安裝的php版本
yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
4. 安裝php5.6
yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-pecl-apcu php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process php-gd php-common
php-opcache及php-pecl-apcu會有效的提升php執行速度。
5. 確認php版本
php -v
安裝成功
6.安裝zend Guard
若是你須要將源碼加密,能夠使用這個,若是不須要就能夠忽略這一步。
不過目前zend Guard最高支持到php5.6的加密,若是你項目用的版本比較高的話,推薦使用Swoole Compiler。
這裏就很少BB了。
zend Guard下載地址:http://www.zend.com/en/products/guard/downloads#Linux
下載完成以後進行解壓
tar -xvf zend-loader-php5.6-linux-x86_64_update1.tar
解壓完成以後打開文件將ZendGuardLoader.so和opcache.so移至擴展庫裏面
cd zend-loader-php5.6-linux-x86_64
cp opcache.so /etc/httpd/modules
cp ZendGuardLoader.so /etc/httpd/modules
配置
vim /etc/php.ini
在最底部添加
zend_extension=/etc/httpd/modules/ZendGuardLoader.so
zend_extension=/etc/httpd/modules/opcache.so
zend_loader.enable=1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=3
zend_loader.license_path=
保存退出重啓apache服務器
systemctl restart httpd.service
再看php版本
php -v
若是顯示
Cannot load Zend OPcache - extension already loaded
PHP 5.6.37 (cli) (built: Jul 19 2018 19:57:52)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend Guard Loader v3.3, Copyright (c) 1998-2015, by Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
就徹底配置好啦~!
測試
vim /var/www/html/index.php
<?php
phpinfo();
?>
退出保存,訪問你的域名或者ip地址,別忘了阿里雲上設置安全組,放開80端口。
三、安裝Composer
1.安裝composer
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" php composer-setup.php php -r "unlink('composer-setup.php');"
2.配置全局
sudo mv composer.phar /usr/local/bin/composer