Home > Article > Backend Development > How to build a php running environment under Ubuntu server_Linux
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
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
1.apache root directory
After installing apache2, the root directory is under /var/www, which can be accessed throughhttp://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
http://localhost/phptest.
3. Commonly used commands in configuration
Restart apache##
sudo /etc/init.d/apache2 restart
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!