Method of setting up php running environment under Ubuntu server
- 2020-08-22 23:26:47
- OfStack
This article illustrates how to set up php running environment under Ubuntu server. To share 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
The first two are easy to understand. If apache is to parse PHP, you need these two modules to find php engine. The third one is used when php operates the mysql database. Most people have database programming experience, so it doesn't need much explanation. The fourth GD library.
1. apache root directory
After installing apache2, the root directory is under /var/www. It can pass http://localhost/ test 1 to see if it is easy to use. , of course, also can build one in that directory file test. html to try 1 http: / / localhost test html.
2. Change the default directory of apache2 to the current development directory
The default directory for apache2 is configured in the /etc/apache2/ es51EN-ES52en /00default file.
Find the DocumentRoot item in this file and change /var/www to your development directory for OK.
There is, of course, another way to do this without changing the default directory and just create a link to your directory under var/www. If your directory is in /home/username/phptest, then you only have to
sudo ln -s/home/username/phptest /var/www/phptest
This gives you access to your working directory via http://localhost/phptest.
3. Common commands in configuration
Restart apache
sudo /etc/init.d/apache2 restart
Hopefully this article has helped you with your Ubuntu server configuration.