云主机测评网云主机测评网云主机测评网

云主机测评网
www.yunzhuji.net

如何搭建php7与apache2.4

1. 安装Apache2.4PHP7,2. 配置Apache2.4的httpd.conf文件,添加PHP模块,3. 重启Apache2.4服务,4. 创建PHP文件,测试是否成功搭建

搭建 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 &&

打赏
版权声明:主机测评不销售、不代购、不提供任何支持,仅分享信息/测评(有时效性),自行辨别,请遵纪守法文明上网。
文章名称:《如何搭建php7与apache2.4》
文章链接:https://www.yunzhuji.net/jishujiaocheng/64467.html

评论

  • 验证码