在Apache上部署php应用简明教程

如何在Apache上部署php应用

如何在Apache上部署php应用

首先需要搭建php环境,下载php等工具,我们略过。

Apache服务的默认端口是80,默认访问目录是/var/www/html,我将php应用同样放到/var/www下,
如图所示(应用名为 vv)
在这里插入图片描述
然后到 /etc/apache2/sites-available 目录下添加虚拟主机的配置来运行此项目:

admin@ubuntu:/etc/apache2/sites-available$ sudo vim vv.conf

#复制以下内容并根据实际情况修改
Listen 8050		#程序运行占用的端口
NameVirtualHost *:8050
<VirtualHost *:8050>
        ServerName 你的域名或ip

        DocumentRoot /var/www/vv

        <Directory /var/www/vv>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log
</VirtualHost>

#保存退出

这时候/etc/apache2/sites-enabled目录(已生效配置所在目录)下还没有出现vv.conf
使用a2ensite命令使配置文件生效:

admin@ubuntu:/etc/apache2/sites-available$ sudo a2ensite 
Your choices are: 000-default default-ssl vv
Which site(s) do you want to enable (wildcards ok)?
vv
Enabling site vv.
To activate the new configuration, you need to run:
  systemctl reload apache2

admin@ubuntu:/etc/apache2/sites-available$ sudo systemctl reload apache2

此时/etc/apache2/sites-enabled目录下出现vv.conf,配置成功,去浏览器访问 ip:8050 出现相应内容。

猜你喜欢

转载自blog.csdn.net/qq_44880708/article/details/106159250