Home Backend Development PHP Tutorial Analysis of the tutorial on configuring Apache+PHP+PHPmyadmin+MYsql_PHP in Alibaba Cloud ubuntu12.04 environment

Analysis of the tutorial on configuring Apache+PHP+PHPmyadmin+MYsql_PHP in Alibaba Cloud ubuntu12.04 environment

Jul 21, 2016 pm 03:02 PM
Down cloud Tutorial environment parse Configuration Ali

此教程中使用的相关IP等设置,在你的环境中要做相应修改。
使用之前更新apt-get,因为服务器基本上是一个裸系统
apt-get update;
apt-get upgrade;
1 我们使用root账户进行安装,首先切换到root账户,输入命令:
sudo su

2 安装 MySQL 5
输入命令:
apt-get install mysql-server mysql-client
安装过程中需要设置root账户密码,系统会作以下提示:
New password for the MySQL ”root” user:Repeat password for theMySQL ”root” user:

3 安装 Apache2
输入命令:
apt-get install apache2
在浏览器输入你服务器地址列入 http://192.168.0.100查看Apache2是否工作,如果显示(Itworks!),说明已经工作。
Apache 在 Ubuntu 中默认文档根目录为 /var/www,配置文件/etc/apache2/apache2.conf,额外配置存储子目录 /etc/apache2 例如/etc/apache2/mods-enabled (为 Apache 模块), /etc/apache2/sites-enabled(为虚拟主机 virtual hosts), 和 /etc/apache2/conf.d.

4 安装 PHP5
安装 PHP5 和 Apache PHP5 模块:
apt-get install php5 libapache2-mod-php5
(如果有安装的内容找不到,需要更新apt-get,执行apt-get update)
然后重启apache:
/etc/init.d/apache2 restart

5 测试 PHP5 / 可以建立一个探针页面
vi /var/www/info.php
输入下面的内容:
phpinfo();
?>
然后打开浏览器访问 (http://127.0.0.1/info.php):
你可以看到一些已经支持的模块。

6 为PHP5取得 MySQL 支持
我们需要安装 php5-mysql,先查看一下php5的模块
apt-cache search php5-mysql
php5-mysql - MySQL module for php5
php5-mysqlnd - MySQL module for php5 (Native Driver)
然后安装所需模块,例如下面的命令:
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

差什么php5的模块,就安装php5的模块,ubuntu的php5安装module还是很方便的
以下模块自己选择安装,有些模块不一定正确
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
重启 Apache2:
/etc/init.d/apache2 restart
然后刷次你 http://127.0.0.1/info.php 查看模块支持是不是已经增加了。

7 phpMyAdmin
安装phpmyadmin来管理mysql:
apt-get install phpmyadmin
phpmyadmin设置:
在安装过程中会要求选择Web server:apache2或lighttpd,选择apache2,按tab键然后确定。然后会要求输入设置的Mysql数据库密码连接密码Password of the database's administrative user。
然后将phpmyadmin与apache2建立连接,以我的为例:www目录在/var/www,phpmyadmin在/usr/share /phpmyadmin目录,所以就用命令:sudo ln -s /usr/share/phpmyadmin /var/www建立连接。
phpmyadmin测试:在浏览器地址栏中打开http://localhost/phpmyadmin。
Phpmyadmin访问地址:http://127.0.0.1/phpmyadmin/

以上LAMP的基本组件就安装完毕了,下面我们再来看一些其他的设置:
设置Ubuntu文件执行读写权限
LAMP组建安装好之后,PHP网络服务器根目录默认设置是在:/var/www。由于Linux系统的安全性原则,改目录下的文件读写权限是只允许root用户操作的,所以我们不能在www文件夹中新建php文件,也不能修改和删除,必须要先修改/var/www目录的读写权限。在界面管理器中通过右键属性不能修改文件权限,得执行root终端命令:sudo chmod 777 /var/www。然后就可以写入html或php文件了。如果对777表示的文件权限不是很清楚可参考chmod命令。

配置Apache
1启用mod_rewrite模块
终端命令:sudo a2enmod rewrite
重启Apache服务器:sudo /etc/init.d/apache2 restart
Apache重启后我们可以测试一下,在/var/www目录下新建文件test.php,写入代码:保存,在地址栏输入http://127.0.0.1/test.php或http://localhost/test.php,如果正确出现了php配置信息则表明LAMP Apache已经正常工作了(记得重启Apache服务器后再测试)。

2 Set Apache support .htm .html .php
sudo gedit /etc/apache2/apache2.conf
Add AddType application/x-httpd-php .php .htm .html.

Configuring Mysql test
The above PHP and Apache have been tested. Let's test whether the Mysql database has been correctly enabled.
Create a new mysql_test.php in the /var/www directory:

Copy the code The code is as follows:
$link = mysql_connect("localhost","root","020511");
if (!$link)
{
die('Could not connect: ' . mysql_error() );
}
else echo "Mysql has been configured correctly";
mysql_close($link);
?>

Save and exit, enter http in the address bar ://127.0.0.1/mysql_test.php, if "Mysql has been configured correctly" is displayed, it means OK. If not, restart the Apache server and try again.

Configure php5
sudo gedit /etc/php5/apache2/php.ini to modify the maximum allowed memory, find
memory_limit = 8M and modify it to
memory_limit = 32M
Modify the maximum allowed upload size, find
upload_max_filesize = 2M and change it to
upload_max_filesize = 8M
Allow mysql and gd modules, check whether the file contains the following code at the end, if not add it. (By default, it is added at the end of the configuration file, check it just in case)
extension=mysql.soextension=gd.so Save and close the file.

If garbled characters appear, the solution is as follows: Configure apache character encoding:

sudo gedit /etc/apache2/conf.d/charset
Change the content inside to AddDefaultCharset UTF-8

Configure php character encoding:
sudo gedit /etc/php5/apache2/php.ini
Find
code:
default_charset = "iso-8859 -1″
changed to
Code:
default_charset = “UTF-8″
Then restart apache:
Code:
sudo /etc/init.d/apache2 restart t

http://www.bkjia.com/PHPjc/327889.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327889.htmlTechArticleThe relevant IP and other settings used in this tutorial must be modified accordingly in your environment. Update apt-get before use, because the server is basically a bare system apt-get update; apt-get upgrad...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Alibaba Cloud announced that the 2024 Yunqi Conference will be held in Hangzhou from September 19th to 21st. Free application for free tickets Alibaba Cloud announced that the 2024 Yunqi Conference will be held in Hangzhou from September 19th to 21st. Free application for free tickets Aug 07, 2024 pm 07:12 PM

According to news from this website on August 5, Alibaba Cloud announced that the 2024 Yunqi Conference will be held in Yunqi Town, Hangzhou from September 19th to 21st. There will be a three-day main forum, 400 sub-forums and parallel topics, as well as nearly four Ten thousand square meters of exhibition area. Yunqi Conference is free and open to the public. From now on, the public can apply for free tickets through the official website of Yunqi Conference. An all-pass ticket of 5,000 yuan can be purchased. The ticket website is attached on this website: https://yunqi.aliyun.com/2024 /ticket-list According to reports, the Yunqi Conference originated in 2009 and was originally named the First China Website Development Forum. In 2011, it evolved into the Alibaba Cloud Developer Conference. In 2015, it was officially renamed the "Yunqi Conference" and has continued to successful move

Tutorial on how to use Dewu Tutorial on how to use Dewu Mar 21, 2024 pm 01:40 PM

Dewu APP is currently a very popular brand shopping software, but most users do not know how to use the functions in Dewu APP. The most detailed usage tutorial guide is compiled below. Next is the Dewuduo that the editor brings to users. A summary of function usage tutorials. Interested users can come and take a look! Tutorial on how to use Dewu [2024-03-20] How to use Dewu installment purchase [2024-03-20] How to obtain Dewu coupons [2024-03-20] How to find Dewu manual customer service [2024-03-20] How to check the pickup code of Dewu [2024-03-20] Where to find Dewu purchase [2024-03-20] How to open Dewu VIP [2024-03-20] How to apply for return or exchange of Dewu

Tutorial on how to turn off the payment sound on WeChat Tutorial on how to turn off the payment sound on WeChat Mar 26, 2024 am 08:30 AM

1. First open WeChat. 2. Click [+] in the upper right corner. 3. Click the QR code to collect payment. 4. Click the three small dots in the upper right corner. 5. Click to close the voice reminder for payment arrival.

Experts teach you! The Correct Way to Cut Long Pictures on Huawei Mobile Phones Experts teach you! The Correct Way to Cut Long Pictures on Huawei Mobile Phones Mar 22, 2024 pm 12:21 PM

With the continuous development of smart phones, the functions of mobile phones have become more and more powerful, among which the function of taking long pictures has become one of the important functions used by many users in daily life. Long screenshots can help users save a long web page, conversation record or picture at one time for easy viewing and sharing. Among many mobile phone brands, Huawei mobile phones are also one of the brands highly respected by users, and their function of cropping long pictures is also highly praised. This article will introduce you to the correct method of taking long pictures on Huawei mobile phones, as well as some expert tips to help you make better use of Huawei mobile phones.

In summer, you must try shooting a rainbow In summer, you must try shooting a rainbow Jul 21, 2024 pm 05:16 PM

After rain in summer, you can often see a beautiful and magical special weather scene - rainbow. This is also a rare scene that can be encountered in photography, and it is very photogenic. There are several conditions for a rainbow to appear: first, there are enough water droplets in the air, and second, the sun shines at a low angle. Therefore, it is easiest to see a rainbow in the afternoon after the rain has cleared up. However, the formation of a rainbow is greatly affected by weather, light and other conditions, so it generally only lasts for a short period of time, and the best viewing and shooting time is even shorter. So when you encounter a rainbow, how can you properly record it and photograph it with quality? 1. Look for rainbows. In addition to the conditions mentioned above, rainbows usually appear in the direction of sunlight, that is, if the sun shines from west to east, rainbows are more likely to appear in the east.

Analysis of new features of Win11: How to skip logging in to Microsoft account Analysis of new features of Win11: How to skip logging in to Microsoft account Mar 27, 2024 pm 05:24 PM

Analysis of new features of Win11: How to skip logging in to a Microsoft account. With the release of Windows 11, many users have found that it brings more convenience and new features. However, some users may not like having their system tied to a Microsoft account and wish to skip this step. This article will introduce some methods to help users skip logging in to a Microsoft account in Windows 11 and achieve a more private and autonomous experience. First, let’s understand why some users are reluctant to log in to their Microsoft account. On the one hand, some users worry that they

PHP Tutorial: How to convert int type to string PHP Tutorial: How to convert int type to string Mar 27, 2024 pm 06:03 PM

PHP Tutorial: How to Convert Int Type to String In PHP, converting integer data to string is a common operation. This tutorial will introduce how to use PHP's built-in functions to convert the int type to a string, while providing specific code examples. Use cast: In PHP, you can use cast to convert integer data into a string. This method is very simple. You only need to add (string) before the integer data to convert it into a string. Below is a simple sample code

Analysis of the meaning and usage of midpoint in PHP Analysis of the meaning and usage of midpoint in PHP Mar 27, 2024 pm 08:57 PM

[Analysis of the meaning and usage of midpoint in PHP] In PHP, midpoint (.) is a commonly used operator used to connect two strings or properties or methods of objects. In this article, we’ll take a deep dive into the meaning and usage of midpoints in PHP, illustrating them with concrete code examples. 1. Connect string midpoint operator. The most common usage in PHP is to connect two strings. By placing . between two strings, you can splice them together to form a new string. $string1=&qu

See all articles