搜索
首页后端开发php教程在fedora21 上的php+mysql+apache环境搭建

转自:http://www.itzgeek.com/how-tos/linux/fedora-how-tos/install-apache2-with-php5-and-mysql-on-fedora-21-lamp.html#axzz3Ol5qOZ16

参考资料:

https://www.howtoforge.com/fedora-21-apache-mysql-php-lamp


LAMP Stands for Linux,Apache,MySQL and PHP. Most of the websites works with the above combination. The main purpose of LAMP is testing the application locally by the programmer before going to the production. Below are the steps to install LAMP (Apache, PHP and MySQL) on Fedora.

Installing Linux:


Here i am not going to show how to install Fedora 21. The main purpose of this post is to setup AMP (Apache,MySQL and PHP) only.

Installing Apache:


To start off we will install Apache. Open up the terminal and Swicth to root.


$ su


Name of the package is httpd, type following command on the terminal and then press enter.


# yum install httpd


Start the Apache by using the following command.


# systemctl start httpd.service


To make the apache to start during the every boot, type the following on terminal and hit Enter.


# systemctl enable httpd.service


Configure firewall to allow http request from the external network.


firewall-cmd --permanent --zone=public --add-service=http

firewall-cmd --permanent --zone=public --add-service=https

firewall-cmd --reload


Testing Apache:


To make sure everything installed correctly we will now test Apache to ensure it is working properly.


Open up any web browser and then enter the following into the web address:


 http://localhost/  or  http://192.168.0.10


You will get the web page saying “Fedora Test Page”. Now the Apache is working fine. Apache’s default document root is /var/www/html on Fedora, and the configuration file is /etc/httpd/conf/httpd.conf. Additional configurations are stored in the /etc/httpd/conf.d/ directory.

Fedora 21 - Apache Default pageFedora 21 ? Apache Default page

Installing MySQL:


Next is to install the MySQL on the Linux, follow the Steps. Type the following command and then Press Enter.


#  yum install mariadb mariadb-server


Start MySQL server.


# systemctl start mariadb.service


To make the MySQL to start during the every boot, type the following on terminal and hit Enter.


# systemctl enable mariadb.service


Nex is to make the MySQL secure by using the mysql_secure_installation command.


This program enables you to improve the security of your MySQL installation in the following ways:


    You can set a password for root accounts.

    You can remove root accounts that are accessible from outside the local host.

    You can remove anonymous-user accounts.

    You can remove the test database (which by default can be accessed by all users, even anonymous users), and privileges that permit anyone to access databases with names that start with test_.


[root@server1 ~]# mysql_secure_installation


NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MariaDB to secure it, we’ll need the current

password for the root user.  If you’ve just installed MariaDB, and

you haven’t set the root password yet, the password will be blank,

so you should just press enter here.


Enter current password for root (enter for none):   Enter Root password

OK, successfully used password, moving on…


Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.


Set root password? [Y/n] y   Yes, if you want to setup root password

New password: Type password

Re-enter new password: Re type root password

Password updated successfully!

Reloading privilege tables..

… Success!


By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB 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

production environment.


Remove anonymous users? [Y/n]   Yes to remove anonymous users

… Success!


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? [Y/n]   Disable remote root login

… Success!


By default, MariaDB 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? [Y/n]   Remove test database

? 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? [Y/n]   Reload privilleges

… Success!


Cleaning up…


All done!  If you’ve completed all of the above steps, your MariaDB

installation should now be secure.


Thanks for using MariaDB!

Installing PHP:


By default Apache server supports the HTML language only, not PHP for that we need to install PHP. To install PHP please follow the steps. Type following line on the terminal and press enter, this command includes support package for the MySQL.


# yum install php php-mysql


You need to restart the apache service after the installation of the PHP, to do that type the following on the terminal.


# systemctl restart httpd.service


Testing PHP:


For testing the PHP, Place one PHP file on to the default directory of the Apache. The document root of the default web site is /var/www/html. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.


In the terminal copy/paste the following line:


# vi /var/www/html/info.php


This will open up a file called info.php.


Copy/Paste this line into the phpinfo file:



Save and close the file. use Esc + ;wq for saving the file.


Now open you’re web browser and type the following into the web address:


http://localhost/info.php or http://192.168.0.10/info.php


The page look like below:

Fedora 21 - LAMP PHPInfoFedora 21 ? LAMP PHPInfo


Scroll down the browser to modules section to check the support for the MySQL. you will get the screen like below.

Fedora 21 - LAMP PHPInfo MySQL SupportFedora 21 ? LAMP PHPInfo MySQL Support


Read more: http://www.itzgeek.com/how-tos/linux/fedora-how-tos/install-apache2-with-php5-and-mysql-on-fedora-21-lamp.html#ixzz3OmDfNCwB

© 2014 ITzGeek. All rights reserved.


声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
PHP与Python:了解差异PHP与Python:了解差异Apr 11, 2025 am 12:15 AM

PHP和Python各有优势,选择应基于项目需求。1.PHP适合web开发,语法简单,执行效率高。2.Python适用于数据科学和机器学习,语法简洁,库丰富。

php:死亡还是简单地适应?php:死亡还是简单地适应?Apr 11, 2025 am 12:13 AM

PHP不是在消亡,而是在不断适应和进化。1)PHP从1994年起经历多次版本迭代,适应新技术趋势。2)目前广泛应用于电子商务、内容管理系统等领域。3)PHP8引入JIT编译器等功能,提升性能和现代化。4)使用OPcache和遵循PSR-12标准可优化性能和代码质量。

PHP的未来:改编和创新PHP的未来:改编和创新Apr 11, 2025 am 12:01 AM

PHP的未来将通过适应新技术趋势和引入创新特性来实现:1)适应云计算、容器化和微服务架构,支持Docker和Kubernetes;2)引入JIT编译器和枚举类型,提升性能和数据处理效率;3)持续优化性能和推广最佳实践。

您什么时候使用特质与PHP中的抽象类或接口?您什么时候使用特质与PHP中的抽象类或接口?Apr 10, 2025 am 09:39 AM

在PHP中,trait适用于需要方法复用但不适合使用继承的情况。1)trait允许在类中复用方法,避免多重继承复杂性。2)使用trait时需注意方法冲突,可通过insteadof和as关键字解决。3)应避免过度使用trait,保持其单一职责,以优化性能和提高代码可维护性。

什么是依赖性注入容器(DIC),为什么在PHP中使用一个?什么是依赖性注入容器(DIC),为什么在PHP中使用一个?Apr 10, 2025 am 09:38 AM

依赖注入容器(DIC)是一种管理和提供对象依赖关系的工具,用于PHP项目中。DIC的主要好处包括:1.解耦,使组件独立,代码易维护和测试;2.灵活性,易替换或修改依赖关系;3.可测试性,方便注入mock对象进行单元测试。

与常规PHP阵列相比,解释SPL SplfixedArray及其性能特征。与常规PHP阵列相比,解释SPL SplfixedArray及其性能特征。Apr 10, 2025 am 09:37 AM

SplFixedArray在PHP中是一种固定大小的数组,适用于需要高性能和低内存使用量的场景。1)它在创建时需指定大小,避免动态调整带来的开销。2)基于C语言数组,直接操作内存,访问速度快。3)适合大规模数据处理和内存敏感环境,但需谨慎使用,因其大小固定。

PHP如何安全地上载文件?PHP如何安全地上载文件?Apr 10, 2025 am 09:37 AM

PHP通过$\_FILES变量处理文件上传,确保安全性的方法包括:1.检查上传错误,2.验证文件类型和大小,3.防止文件覆盖,4.移动文件到永久存储位置。

什么是无效的合并操作员(??)和无效分配运算符(?? =)?什么是无效的合并操作员(??)和无效分配运算符(?? =)?Apr 10, 2025 am 09:33 AM

JavaScript中处理空值可以使用NullCoalescingOperator(??)和NullCoalescingAssignmentOperator(??=)。1.??返回第一个非null或非undefined的操作数。2.??=将变量赋值为右操作数的值,但前提是该变量为null或undefined。这些操作符简化了代码逻辑,提高了可读性和性能。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
3 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境

Atom编辑器mac版下载

Atom编辑器mac版下载

最流行的的开源编辑器

安全考试浏览器

安全考试浏览器

Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用