Home >Backend Development >PHP Tutorial >How to build a php running environment under Ubuntu server_Linux

How to build a php running environment under Ubuntu server_Linux

不言
不言Original
2018-04-04 17:12:303313browse

This article mainly introduces the method of building a php running environment under the Ubuntu server. It briefly analyzes the steps, commands and operating techniques related to building Apache, php and mysql modules under the Ubuntu operating system environment. Friends in need can refer to it

The example in this article describes how to build a php running environment under the Ubuntu server. Share it with everyone for your reference, the details are as follows:

Install Apache2:


sudo apt-get install apache2


Install PHP module:


sudo apt-get install php5


##Install Mysql


sudo apt-get installmysql-server


Other module installation:


sudo apt-get install libapache2-mod-php5
sudo apt-get installlibapache2-mod-auth-mysql
sudo apt-get installphp5-mysql
sudo apt-get install php5-gd


First two It is easy to understand that if you want apache to be able to parse PHP, you need to use these two modules to find the php engine. The third one is used when PHP operates the MySQL database. Most people have database programming experience, so there is no need to explain more. The fourth GD library.

1.apache root directory

After installing apache2, the root directory is under /var/www, which can be accessed through

http://localhost/ Test to see if it works. Of course, you can also try it by creating a new file test.html in this directory http://localhost/test.html.

2. Change the default directory of apache2 to the current development directory

The default directory of apache2 is configured in

/etc/apache2/sites-enabled/00default file.

Find the DocumentRoot item in the file and change /var/www to your development directory.

Of course, there is another way is not to change the default directory, just create a link to your directory under var/www. For example, if your directory is in

/home/username/phptest, then you only need to enter


sudo ln -s/home/username/phptest /var/www/phptest


so you can Access your working directory through

http://localhost/phptest.

3. Commonly used commands in configuration

Restart apache

##

sudo /etc/init.d/apache2 restart

Related recommendations:


Standard version of Eclipse steps to build a PHP environment

Build a PHP environment under mac

Methods to build a PHP running environment

The above is the detailed content of How to build a php running environment under Ubuntu server_Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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