Home Backend Development PHP Tutorial Lamp(linux+apache+mysql+php)环境搭建

Lamp(linux+apache+mysql+php)环境搭建

Jun 23, 2016 pm 01:51 PM
lamp build environment

Lamp(linux+apache+mysql+php)环境搭建

 

1.安装apache2:sudo apt-get installapache2

安装完成后,运行如下命令重启apache:sudo/etc/init.d/apache2 restart,在浏览器中输入http://localhost或者http://127.0.0.1,会看到"It works!"说明apache安装成功。

2.安装php:sudoapt-get install libapache2-mod-php5 php5;

安装扩展php5-gd:sudo apt-get installlibapache2-mod-php5 php5-gd 

      php5-mysql:sudo apt-get install libapache2-mod-php5 php5-mysql

安装完成后,重新启动apache,让它加载PHP模块:sudo /etc/init.d/apache2 restart

接下来再Web目录下面新建一个PHP文件来测试PHP是否能正常运行:

sudo gedit /var/www/phpinfo.php,输入并保存后在浏览器里输入http://localhost/phpinfo.php,如果出现了显示php运行参数的页面则说明PHP可以正常运行。

phpinfo();

?php>
3.安装mysql:sudo apt-get installmysql-server mysql-client,在安装的最后需要输入root密码,这里的root密码是指设定MySQL的root密码。

4.安装phpmyadmin-Mysql数据库管理:

sudo apt-get installlibapache2-mod-auth-mysql php5-mysql phpmyadmin,这样安装与php5相配合的phpmyadmin。安装phpmyadmin后,配置phpmyadmin和apache2:

cp  /etc/phpmyadmin/apache.conf  /etc/apache2/sites-available/phpmyadmin,将phpmyadmin中的apache.conf(apache配置文件)复制到apache2/sites-available下的phpmyadmin文件下,然后进入sites-enabled文件夹下:

cd/etc/apache2/sites-enabled,建立一个通往配置文件的链接:sudo ln -s../sites-available/phpmyadmin,重启apache2:sudo /etc/init.d/apache2restart。最后可以打开http://localhost/phpmyadmin验证一下。这样LAMP的基本组件安装完毕了。

 

/********************************************************************************/

接下来进行一些其他的设置:

1.PHP网络服务器根目录默认设置是在:/var/www,由于Linux系统的安全性原则,改目录下的文件读写权限只允许root用户操作,因此通过制定root终端命令:sudo chmod 777 /var/www修改/var/www目录的读写权限,然后就可以写入html或php文件了。

2.配置apahce:启用mod_rewrite模块sudo a2enmod rewrite,重启apache服务器sudo /etc/init.d/apache2 restart,在/var/www目录下新建文件test.php,写入代码保存,然后在浏览器输入http://127.0.0.1/test.php,如果出现php配置信息则表明LAMP Apache已经正常工作(重启apache服务器后测试)。

设置apache支持.htm .html .php:sudo gedit /etc/apache2/apache2.conf

在打开的文件中加上AddType application/x-httpd-php .php .htm .html即可。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Unable to boot into Windows recovery environment Unable to boot into Windows recovery environment Feb 19, 2024 pm 11:12 PM

Windows Recovery Environment (WinRE) is an environment used to repair Windows operating system errors. After entering WinRE, you can perform system restore, factory reset, uninstall updates, etc. If you are unable to boot into WinRE, this article will guide you through fixes to resolve the issue. Unable to boot into the Windows Recovery Environment If you cannot boot into the Windows Recovery Environment, use the fixes provided below: Check the status of the Windows Recovery Environment Use other methods to enter the Windows Recovery Environment Did you accidentally delete the Windows Recovery Partition? Perform an in-place upgrade or clean installation of Windows below, we have explained all these fixes in detail. 1] Check Wi

What are the differences between Python and Anaconda? What are the differences between Python and Anaconda? Sep 06, 2023 pm 08:37 PM

In this article, we will learn about the differences between Python and Anaconda. What is Python? Python is an open source language that places great emphasis on making the code easy to read and understand by indenting lines and providing whitespace. Python's flexibility and ease of use make it ideal for a variety of applications, including but not limited to scientific computing, artificial intelligence, and data science, as well as creating and developing online applications. When Python is tested, it is immediately translated into machine language because it is an interpreted language. Some languages, such as C++, require compilation to be understood. Proficiency in Python is an important advantage because it is very easy to understand, develop, execute and read. This makes Python

How to quickly build a statistical chart system under the Vue framework How to quickly build a statistical chart system under the Vue framework Aug 21, 2023 pm 05:48 PM

How to quickly build a statistical chart system under the Vue framework. In modern web applications, statistical charts are an essential component. As a popular front-end framework, Vue.js provides many convenient tools and components that can help us quickly build a statistical chart system. This article will introduce how to use the Vue framework and some plug-ins to build a simple statistical chart system. First, we need to prepare a Vue.js development environment, including installing Vue scaffolding and some related plug-ins. Execute the following command in the command line

Can buildings be built in the wild in Mistlock Kingdom? Can buildings be built in the wild in Mistlock Kingdom? Mar 07, 2024 pm 08:28 PM

Players can collect different materials to build buildings when playing in the Mistlock Kingdom. Many players want to know whether to build buildings in the wild. Buildings cannot be built in the wild in the Mistlock Kingdom. They must be within the scope of the altar. . Can buildings be built in the wild in Mistlock Kingdom? Answer: No. 1. Buildings cannot be built in the wild areas of the Mist Lock Kingdom. 2. The building must be built within the scope of the altar. 3. Players can place the Spirit Fire Altar by themselves, but once they leave the range, they will not be able to construct buildings. 4. We can also directly dig a hole in the mountain as our home, so we don’t need to consume building materials. 5. There is a comfort mechanism in the buildings built by players themselves, that is to say, the better the interior, the higher the comfort. 6. High comfort will bring attribute bonuses to players, such as

What are the PHP integrated environment packages? What are the PHP integrated environment packages? Jul 24, 2023 am 09:36 AM

PHP integrated environment packages include: 1. PhpStorm, a powerful PHP integrated environment; 2. Eclipse, an open source integrated development environment; 3. Visual Studio Code, a lightweight open source code editor; 4. Sublime Text, a A popular text editor, widely used in various programming languages; 5. NetBeans, an integrated development environment developed by the Apache Software Foundation; 6. Zend Studio, an integrated development environment designed for PHP developers.

Network security reinforcement techniques for building web servers under CentOS 7 Network security reinforcement techniques for building web servers under CentOS 7 Aug 05, 2023 pm 01:12 PM

Network security reinforcement techniques for building web servers under CentOS7 The web server is an important part of the modern Internet, so it is very important to protect the security of the web server. By hardening network security, you can reduce risks and avoid potential attacks. This article will introduce network security reinforcement techniques commonly used when building web servers on CentOS7, and provide corresponding code examples. Update your system and software First, make sure your system and software are up to date. You can use the following command to update

How to build an account matrix? What are the functions of matrix construction? How to build an account matrix? What are the functions of matrix construction? Mar 23, 2024 pm 06:46 PM

In today's information-rich era, social media platforms have become the main way for people to obtain and share information. For individuals and enterprises, establishing an effective account network to achieve maximum dissemination of information and enhance influence has become an urgent challenge that needs to be solved. 1. How to build an account matrix? 1. Clarify the target audience. Before building an account matrix, the key is to clearly define the target audience and gain an in-depth understanding of their needs, interests, and consumption habits, so that a more targeted content strategy can be developed. 2. Choose the appropriate platform. According to the characteristics of the target group, choose the appropriate social media platform for layout. Currently, the mainstream social media platforms include Weibo, WeChat, Douyin, Kuaishou, etc. Each platform has its own unique user groups and communication characteristics, and the selection needs to be based on the actual situation.

11 Ways to Set Environment Variables on Windows 3 11 Ways to Set Environment Variables on Windows 3 Sep 15, 2023 pm 12:21 PM

Setting environment variables on Windows 11 can help you customize your system, run scripts, and configure applications. In this guide, we'll discuss three methods along with step-by-step instructions so you can configure your system to your liking. There are three types of environment variables System environment variables – Global variables are the lowest priority and are accessible to all users and applications on Windows and are typically used to define system-wide settings. User Environment Variables – Higher priority, these variables only apply to the current user and process running under that account, and are set by the user or application running under that account. Process environment variables – have the highest priority, they are temporary and apply to the current process and its sub-processes, providing the program

See all articles