찾다
백엔드 개발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의 전체 형태는 무엇입니까?PHP의 전체 형태는 무엇입니까?Apr 28, 2025 pm 04:58 PM

이 기사는 PHP에 대해 설명하고, 전체 형식, 웹 개발의 주요 용도, Python 및 Java와의 비교 및 ​​초보자를위한 학습 용이성을 자세히 설명합니다.

PHP는 양식 데이터를 어떻게 처리합니까?PHP는 양식 데이터를 어떻게 처리합니까?Apr 28, 2025 pm 04:57 PM

PHP는 유효성 검사, 소독 및 보안 데이터베이스 상호 작용을 통해 보안을 보장하면서 $ \ _ post 및 $ \ _를 사용하여 데이터 양식 데이터를 처리합니다.

PHP와 ASP.NET의 차이점은 무엇입니까?PHP와 ASP.NET의 차이점은 무엇입니까?Apr 28, 2025 pm 04:56 PM

이 기사는 PHP와 ASP.NET을 비교하여 대규모 웹 응용 프로그램, 성능 차이 및 보안 기능에 대한 적합성에 중점을 둡니다. 둘 다 대규모 프로젝트에서는 실용적이지만 PHP는 오픈 소스 및 플랫폼 독립적이며 ASP.NET,

PHP는 사례에 민감한 언어입니까?PHP는 사례에 민감한 언어입니까?Apr 28, 2025 pm 04:55 PM

PHP의 사례 감도는 다양합니다. 함수는 무감각하고 변수와 클래스는 민감합니다. 모범 사례에는 일관된 이름 지정 및 비교를위한 사례 감수 기능 사용이 포함됩니다.

PHP에서 페이지를 어떻게 리디렉션합니까?PHP에서 페이지를 어떻게 리디렉션합니까?Apr 28, 2025 pm 04:54 PM

이 기사는 PHP의 페이지 리디렉션에 대한 다양한 방법에 대해 설명하고 헤더 () 함수에 중점을두고 "헤더가 이미 보낸 헤더"오류와 같은 일반적인 문제를 해결합니다.

PHP의 유형을 설명하십시오PHP의 유형을 설명하십시오Apr 28, 2025 pm 04:52 PM

기사는 기능의 예상 데이터 유형을 지정하는 기능인 PHP의 유형 힌트에 대해 설명합니다. 주요 문제는 유형 시행을 통해 코드 품질과 가독성을 향상시키는 것입니다.

PHP의 PDO는 무엇입니까?PHP의 PDO는 무엇입니까?Apr 28, 2025 pm 04:51 PM

이 기사에서는 PHP Data Objects (PDO)에 대해 설명합니다. PHP의 데이터베이스 액세스 확장. 데이터베이스 추상화 및 더 나은 오류 처리를 포함하여 준비된 진술과 MySQLI에 대한 이점을 통해 보안을 향상시키는 데 PDO의 역할을 강조합니다.

PHP에서 API를 만드는 방법?PHP에서 API를 만드는 방법?Apr 28, 2025 pm 04:50 PM

기사는 PHP API 생성 및 보호, Laravel 및 Best Security Practices와 같은 프레임 워크를 사용하여 엔드 포인트 정의에서 성능 최적화에 이르는 단계를 자세히 설명합니다.

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

에디트플러스 중국어 크랙 버전

에디트플러스 중국어 크랙 버전

작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기