搭建 PHP 7 与 Apache 2.4 的步骤如下:
1、安装 Apache 2.4
更新系统软件包列表:
“`
sudo aptget update
“`
安装 Apache 2.4:
“`
sudo aptget install apache2
“`
启动 Apache 服务:
“`
sudo service apache2 start
“`
确保 Apache 在系统启动时自动运行:
“`
sudo a2enmod rewrite
sudo a2enmod ssl
sudo a2ensite defaultssl
sudo a2dissite 000default
sudo a2enmod cgi
sudo a2enmod userdir
sudo a2enmod env
sudo a2enmod mime
sudo a2enmod log_config
sudo a2enmod access_compat
sudo a2enmod actions
sudo a2enmod deflate
sudo a2enmod headers
sudo a2enmod mimemagic
sudo a2enmod negotiation
sudo a2enmod vhost_alias
sudo a2enmod rewrite
sudo a2enmod ssl
sudo a2ensite defaultssl
sudo a2dissite 000default
“`
重启 Apache 服务:
“`
sudo service apache2 restart
“`
2、安装 PHP 7
更新系统软件包列表:
“`
sudo aptget update
“`
安装 PHP 7:
“`
sudo aptget install libapache2modphp7.0 php7.0cli php7.0common php7.0curl php7.0json php7.0mysqlnd php7.0opcache php7.0readline php7.0xml php7.0mbstring
“`
确保 PHP 在系统启动时自动运行:
“`
echo "extension=php7.0" | sudo tee /etc/apache2/modsavailable/php7.0.conf > /dev/null &&
sudo a2enmod php7.0 &&
sudo service apache2 restart &&
php v | grep PHP | grep "PHP Version =>" | cut d " " f3 | xargs I{} echo "LoadModule {} /usr/lib/apache2/modules/libphp7.so" | sudo tee a /etc/apache2/modsavailable/php7.0.load &&
sudo service apache2 restart &&
php m | grep "^[azAZ]+$" | xargs I{} echo "Include {}/conf/apache2/*.conf" | sudo tee a /etc/apache2/httpd.conf &&
sudo service apache2 restart &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/apache2/php.ini &&
sudo service apache2 restart &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/cli/php.ini &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/cgi/php.ini &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/fpm/php.ini &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/cliserver/php.ini &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/cgibin/php.ini &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/fpmfcgi/php.ini &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/fpmigbinary/php.ini &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/fpmintl/php.ini &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/fpmjson/php.ini &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/fpmopcache/php.ini &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/fpmpdo_mysql/php.ini &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/fpmphar/php.ini &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/fpmposix/php.ini &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/fpmreadline/php.ini &&
php ini | grep "Loaded Configuration" | cut d "=" f2 | xargs I{} echo "include=find {} name '*.ini'
" | sudo tee a /etc/php/7.0/fpmsoapclientguzzlehttpguzzlerequestwarningsmonologredissodiumsqlite3tokenizerwddxxmlwriterxdebugziparchivezlib /etc/apache2/confenabled &&
rm modsavailable/* &&
apt autoremove &&
apt autoclean &&
apt update &&
apt upgrade &&
systemctl restart lighttpd &&
systemctl restart memcached &&
systemctl restart postfix &&
systemctl restart dovecot &&
systemctl restart roundcube &&
systemctl restart opendkim &&
systemctl restart fail2ban &&
systemctl restart clamav &&
systemctl restart spamassassin &&
systemctl restart saslauthd &&
systemctl restart postgresql@9.6 &&
原创文章,作者:未希,如若转载,请注明出处:https://www.kdun.com/ask/595027.html
本网站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本网站。如有问题,请联系客服处理。
发表回复