UBUNTU下安装APACHE+MYSQL+PHP的教程

install SSH Client and Server (for my remote access)
sudo apt-get install ssh

Install Database Server
sudo apt-get install mysql-server

Install Apache HTTP Server
sudo apt-get install apache2

Install PHP5 and Apache PHP5 module
sudo apt-get install php5 libapache2-mod-php5

Restart Apache
sudo /etc/init.d/apache2 restart

You might probably faced the same following error while you were restarting the Apache server on Ubuntu.

aslam@aslam:~$ sudo /etc/init.d/apache2 restart
* Restarting web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

To fix that problem, you need to edit the httpd.conf file. Open the terminal and type,

sudo apt-get install gedit
(install gedit)

sudo gedit /etc/apache2/httpd.conf
(edit httpd.conf)

By default httpd.conf file will be blank . Now, simply add the following line to the file.

ServerName localhost

Save the file and exit from gEdit.

Finally restart the server.

sudo /etc/init.d/apache2 restart

接下来,我们就在Web目录下面新建一个PHP文件来测试PHP是否能正常的运行,命令:

sudo gedit /var/www/phpinfo.php

然后输入:

<?php phpinfo(); ?>

接着保存文件,在浏览器里输入http://127.0.0.1/phpinfo.php,如果出现了一个显示PHP运行参数的页面,那就说明 PHP已经正常运行了。

Optionally, install phpMyAdmin
sudo apt-get install phpmyadmin

phpmyadmin 默认并不是安装在 /var/www下面的而是在 /usr/share/phpmyadmin你可以把phpmyadmin复制过去 或者 链接过去。

www目录在/var/www,phpmyadmin在/usr/share/phpmyadmin目录,所以就用命令:

sudo ln -s /usr/share/phpmyadmin /var/www

建立连接。

PS: 以下几个命令和位置需要牢记

sudo /etc/init.d/apache2 restart (重启 apache)

sudo gedit /etc/php5/apache2/php.ini (配置 php.ini)

sudo gedit /etc/apache2/apache2.conf (配置 apache2.conf)

/var/www/(主目录位置)

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注