Analyze the configuration of Apache+PHP+PHPmyadmin+MYsql in the aliyun ubuntu12.04 environment

  • 2020-06-22 23:58:45
  • OfStack

The IP Settings used in this tutorial will be modified in your environment.
Update ES3en-ES4en before using, as the server is basically a bare system
apt-get update;
apt-get upgrade;
1. We use the root account for installation. First, switch to the root account and enter the command:
sudo su

2 Install MySQL 5
Input command:
apt-get install mysql-server mysql-client
The root account password needs to be set during installation, and the system will give the following prompts:
New password the MySQL "root" user:Repeat password for theMySQL "root" user:

The installation Apache2
Input command:
apt-get install apache2
Enter your server address listed on http://192.168.0.100 in the browser to see if Apache2 works, if displayed (Itworks! , indicating that it has been worked.
Apache Ubuntu in the default document root is/var/www, configuration file/etc apache2 / apache2 conf, Additional configuration storage directory/etc apache2 such as/etc/apache2 / mods - enabled (for Apache module), / etc/apache2 / sites - enabled (for the virtual host virtual hosts), and/etc/apache2 / conf d.

4 installed PHP5
Install PHP5 and Apache PHP5 modules:
apt-get install php5 libapache2-mod-php5
(If the installation content cannot be found, you need to update apt-ES83en and execute ES84en-ES85en update)
Then restart apache:
/etc/init.d/apache2 restart

5 Test PHP5 / Can create 1 probe page
vi /var/www/info.php
Enter the following:
< ?php
phpinfo();
? >
Then open the browser to access (http: / / 127.0.0.1 info php) :
You can see some of the modules that are already supported.

Obtain MySQL support for PHP5
We need to install php5-mysql, first check the module of php5 under 1
apt-cache search php5-mysql
php5-mysql - MySQL module for php5
php5-mysqlnd - MySQL module for php5 (Native Driver)
Then install the required modules, such as the following command:
apt-get install php5-mysql
apt-get install php5-mysqlnd
sudo apt-get install php5 libapache2-mod-php5 php5-cgi php5-cli php5-common php5-curl php5-gd php5-mysql php5-pgsql
sudo a2enmod php5

What is the difference between php5 module and php5 module? ubuntu php5 is very convenient to install module
The following modules are installed by yourself. Some modules are not always correct
apt-get install php5-mysql php5-curl php5-gd php5-intlphp-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mingphp5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidyphp5-xmlrpc php5-xsl
Restart Apache2:
/etc/init.d/apache2 restart
Then brush your http: / / 127.0.0.1 info php check module support is has increased.

7 phpMyAdmin
Install phpmyadmin to manage mysql:
apt-get install phpmyadmin
phpmyadmin Settings:
During installation, you will be asked to select Web server: apache2 or lighttpd, select apache2, press the tab key and then ok. The Mysql database password that was set is then asked for the connection password Password of the database s administrative user.
Then connect phpmyadmin to apache2. In my case, www is in /var/www and phpmyadmin is in /usr/share /phpmyadmin, so the command is sudo ln/s/es1901en /var.
phpmyadmin test: in the browser address bar, open http: / / localhost/phpmyadmin.
Phpmyadmin access address: http: / / 127.0.0.1 / phpmyadmin /

Now that the LAMP basic components are installed, let's take a look at some other Settings:
Set the Ubuntu file to perform read and write permissions
After the LAMP build is installed, the default setting of the PHP web server root directory is: /var/www. Due to the security principle of Linux system, the read and write permission of files in the changed directory is only allowed to root users, so we cannot create php files in the www folder, nor modify and delete, we must first modify the read and write permission of /var/www directory. In the interface manager, you cannot modify the file permissions by right-clicking the attribute. You have to execute the root terminal command: sudo chmod 777 /var/www. You can then write to html or php. If the file permissions for 777 are not clear, refer to the chmod command.

Configuration Apache
1 Enable the mod_rewrite module
Terminal command: sudo a2enmod rewrite
Restart Apache server: sudo/etc/init d/apache2 restart
After the restart of Apache, we can test 1. Create a new file test. php in /var/www directory and write the code: < ?php phpinfo(); ? > Save, in the address bar input http: / / 127.0.0.1 test php or http: / / localhost test php, if the correct php configuration information indicates LAMP Apache has worked (remember test again after restarting Apache server).

htm. html. php
sudo gedit /etc/apache2/apache2.conf
Add to the open file
AddType/ES278en-ES279en-ES280en.php.htm.
Configure the Mysql test
php and Apache above have been tested. Now let's test whether the Mysql database under 1 is enabled correctly.
New mysql_ES294en.ES295en under /var/www:


<?php
$link = mysql_connect( " localhost " , " root " , " 020511 " );
if (!$link)
{
die( ' Could not connect: ' . mysql_error());
}
else echo  " Mysql Properly configured." ;
mysql_close($link);
?>

Keep out, in the address bar input http: / / 127.0.0.1 mysql_test php, display "Mysql OK has been correctly configured" say, if not, try again after restarting Apache server 1.
Configuration php5
sudo gedit/etc/php5 / apache2 / php ini modified to allow maximum use of memory, lookup
memory_limit = 8M
memory_limit = 32M
Modify the maximum allowed upload size, find
upload_max_filesize = 2M Modified to
upload_max_filesize = 8M
Allow mysql and gd modules to check if the file contains the following code at the end, if not added. (Default is added at the end of the configuration file, check 1 to prevent 10000)
extension= mysql.soextension = gd.so Save and close the file.
In case of messy code, the solution is as follows:
Configure apache character encoding:
sudo gedit /etc/apache2/conf.d/charset
Change the contents to AddDefaultCharset ES346en-8
Configure php character encoding:
sudo gedit /etc/php5/apache2/php.ini
find
Code:
default_charset = "iso - 8859-1"
Instead of
Code:
default_charset = "UTF - 8"
Then restart apache:
Code:
sudo /etc/init.d/apache2 restart


Related articles: