这篇“ubuntu怎么安装Apache、PHP和MySQL”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“Ubuntu怎么安装
这篇“ubuntu怎么安装Apache、PHP和MySQL”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“Ubuntu怎么安装Apache、php和Mysql”文章吧。
在安装之前,我们更新操作系统到最新版本,并重启云服务器。
sudo apt-get update -ysudo apt-get upgrade -yreboot
通过以下命令安装Apache:
sudo apt-get install apache2 -y
通过以下命令查看Apache的版本:
apache2 -v
显示结果如下:
Server version: Apache/2.4.29 (Ubuntu)Server built: 2019-12-03T15:55:03
还需要设置Apache跟随系统启动:
sudo systemctl enable apache2.service
如果我们在浏览器上访问云服务器的IP地址 Http://IPAddress ,出现Apache的默认页面,就说明Apache已经安装成功了。
通过以下命令安装PHP:
sudo apt-get install php -y
接下来,安装必要的PHP扩展:
sudo apt-get install php-{bcmath,bz2,intl,gd,mbstring,mysql,fpm} -y
通过以下命令查看PHP的版本:
php -v
显示结果如下:
PHP 7.2.24-0ubuntu0.18.04.3 (cli) (built: Feb 11 2020 15:55:52) ( NTS )Copyright (c) 1997-2018 The PHP GroupZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.24-0ubuntu0.18.04.3, Copyright (c) 1999-2018, by Zend Technologies
通过以下命令查看PHP安装的模块:
php -m
显示结果如下:
[PHP Modules]bcmathbz2calendarCorectypedateexiffileinfofilterftpgdgettexthashiconvintlJSONlibxmlmbstringmysqlimysqlndopensslpcntlpcrePDOpdo_mysqlPharposixreadlineReflectionsessionshmopSocketssodiumSPLstandardsysvmsgsysvsemsysvshmtokenizerZend OPcachezipzlib[Zend Modules]Zend OPcache
通过以下命令安装MySQL:
sudo apt-get install mysql-server -y
通过以下命令查看MySQL的版本:
mysql -V
显示结果如下:
mysql Ver 14.14 Distrib 5.7.29, for linux (x86_64) using EditLine wrapper
然后,运行MySQL安装配置向导:
sudo mysql_secure_installation
在MySQL安装配置向导中,我们需要输入root密码,并回答一些安全性相关的问题,通常只需要选择向导提供的默认值即可。
Securing the MySQL server deployment.Connecting to MySQL using a blank passWord.VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin?Press y|Y for Yes, any other key for No: YThere are three levels of password validation policy:LOW Length >= 8MEDIUM Length >= 8, numeric, mixed case, and special charactersSTRONG Length >= 8, numeric, mixed case, special characters and dictionary filePlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2Please set the password for root here.New password:Re-enter new password:Estimated strength of the password: 100Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : YBy default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation Go a bit smoother. You should remove them before moving into a productionenvironment.Remove anonymous users? (Press y|Y for Yes, any other key for No) : YSuccess.NORMally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) : YSuccess.By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y - Dropping test database...Success. - Removing privileges on test database...Success.Reloading the privilege tables will ensure that all changes made so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : YSuccess.All done!
还需要设置MySQL跟随系统启动:
sudo systemctl enable mysql.service
默认情况下,Ubuntu的防火墙UFW是禁用状态的。我们需要启用UFW,并允许ssh和Apache相关端口的访问。
sudo ufw allow OpenSSHsudo ufw allow in "Apache Full"sudo ufw enable
以上就是关于“Ubuntu怎么安装Apache、PHP和MySQL”这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注编程网数据库频道。
--结束END--
本文标题: Ubuntu怎么安装Apache、PHP和MySQL
本文链接: https://www.lsjlt.com/news/345926.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0