Method of setting up PHP operating environment under Ubuntu server

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

Method of setting up PHP operating environment under Ubuntu server
Tutorial for setting up FTP server in Ubuntu 16.04 environment
Ubuntu16.04 build php5.6 Web server environment
JDK environment variable configuration method under ubuntu
[PHP] Build a PHP operating environment under CentOS
Configure Nginx + PHP 7.0 + MySQL environment under Ubuntu 16.04
Django&MySQL environment deployment under Ubuntu 14.04
Deploy FTP server under ubuntu
Use of mediawiki under ubuntu
Initial setup of Ubuntu 16.04 server
Installation of deb package under Ubuntu
Python Chinese encoding setting under ubuntu
Installation of Docker CE under Ubuntu
Coexistence of CUDA8.0 and CUDA9.0 under Ubuntu 16.04
Build the C++ compilation environment under ubuntu
About installing node environment in Ubuntu server
Build arm virtual operating environment on Ubuntu
Ubuntu install PHP and PHP Nginx configuration method
Ubuntu Server builds Hyperledger Fabric 2.1 learning environment
Swap (virtual memory) setting method in ubuntu
GPU programming (1): CUDA8.0 environment construction under Ubuntu
Build a python development environment under Ubuntu
DLNA/UPnP Server installation and configuration under Ubuntu 12.04