如何搭建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

如何搭建php7与apache2.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

如何搭建php7与apache2.4

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

如何搭建php7与apache2.4

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

本网站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本网站。如有问题,请联系客服处理。

(0)
未希新媒体运营
上一篇 2024-05-10 02:25
下一篇 2024-05-10 02:25

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

产品购买 QQ咨询 微信咨询 SEO优化
分享本页
返回顶部
云产品限时秒杀。精选云产品高防服务器,20M大带宽限量抢购 >>点击进入