This article describes how to build a PHP runtime environment under Ubuntu server. Share with you for your reference, as follows:
Install Apache2:
sudo apt-get install apache2
Install the PHP module:
sudo apt-get install php5
Install Mysql
sudo apt-get installmysql-server
Installation of other modules:
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 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. You can test whether it works well through http://localhost/. Of course, you can also create a new file test.html in this directory to try http://localhost/test.html.
2. Change the default directory of apache2 to the current development directory
The default directory of apache2 is configured in the /etc/apache2/sites-enabled/00default file.
Find the DocumentRoot item in the file, change /var/www to your development directory and it will be OK.
Of course, another way is not to change the default directory, but to create a link to your directory under var/www. For example, if your directory is in /home/username/phptest, then you only need
sudo ln -s/home/username/phptest /var/www/phptest
So you can access your working directory through http://localhost/phptest.
3、 Common commands in configuration
Restart apache
sudo /etc/init.d/apache2 restart
I hope this article will help you configure your Ubuntu server.
Recommended Posts