设为首页 收藏本站
查看: 1084|回复: 0

How To Install LAMP (Linux, Apache, MySQL, PHP) On Ubuntu 11.04/11.10/12.04

[复制链接]

尚未签到

发表于 2015-11-15 16:21:22 | 显示全部楼层 |阅读模式
How To Install LAMP (Linux, Apache, MySQL, PHP) On Ubuntu 11.04/11.10/12.04
Do you like this story?
Ifyou develop web applications and scripts, it will be nice testing them locally in your own computer before launching them online. This will require the installation of a webserver on your computer.

LAMP (Linux,Apache, MySQL, PHP) is one of the easiest and perfect environment where you can test all your PHP codes. In this tutorial, we will help you install the LAMP webserver on Ubuntu 12.04/11.10; can also be installed on older distributions of Ubuntu (11.04/10.10/10.04).

LAMPInstallation

The LAMP webserver can be installed easily with this command (the caret (^)is required, don't exclude it):

sudoapt-get install lamp-server^

During the installation, you will be asked to enter a new root password for the MySQL database, submit it and press Enter:You will be prompted to enter the password again for confirmation. Wait now until the installation is complete. You have now installed the LAMP webserver on Ubuntu 11.04/11.10. Let's now go to the next step.

TestingApache

Launch your web browser (Firefox, Google Chrome, etc.) and open one of these addresses:

http://localhost/
or
http://127.0.0.1/

If you get this page, then Apache isstarted:Otherwise try to restart Apache with this command:

sudo/etc/init.d/apache2 restart

Then give it another try.

TestingPHP

Let's now test PHP. You need to create an empty PHP file in /var/www  andinsert this snippet of code into it:

<?phpphpinfo(); ?>

You can easily do it with these two commands via the terminal:

echo&quot;<?php phpinfo(); ?>&quot; | sudo tee /var/www/test.php
sudo /etc/init.d/apache2 restart


Then open this address:

http://localhost/test.php

You should see a page like this:ConfiguringMySQL

Since you are using the LAMP webserver locally, your MySQL database must uses the same IP address of your localhost which is: 127.0.0.1.Via the Terminal, run this command to verify it:

cat/etc/hosts | grep localhost

Here is the correct output you must get:

~$cat /etc/hosts | grep localhost
127.0.0.1 localhost
::1     ip6-localhost ip6-loopback


Also verify that the bind address is set correctly by running this command:

cat/etc/mysql/my.cnf | grep bind-address

You should get this output:

~$cat /etc/mysql/my.cnf | grep bind-address
bind-address = 127.0.0.1


If you get a different IP address, then edit the my.cnf filewith this command:

sudogedit /etc/mysql/my.cnf

Search for the line containing &quot;bind-address&quot;and correct its address by replacing it with 127.0.0.1.

phpMyAdminInstallation

If you want an easy GUI for managing your MySQL databases, you can installphpMyAdmin withthis command:

sudoapt-get install libapache2-mod-auth-mysql phpmyadmin

During the installation you will be asked to select a web server that will be configured automatically to run phpMyAdmin. Select apache2 usingyour spacebar and press Enter:You will be asked next to configure a database for phpmyadmin with dbconfig-common,select Yes andpress Enter:In the next screen, enter the MySQL password you have submitted before and press Enter:Congratulation! phpMyAdmin is now installed in your system. To test it, open simply this address via your web browser:

http://localhost/phpmyadmin/

Login to phpMyAdmin using root asusername and the password you created earlier:You have now successfully installed LAMP on your system. All your projects and files must be placed in /var/www sothat you can run them.

RemovingLAMP & phpMyAdmin

To uninstall the LAMP web server and phpMyAdmin, open the terminal and run this command:

forpkg in `dpkg -l *apache* *mysql* phpmyadmin | grep ^ii | awk '{ print $2 }'`; do sudo apt-get -y purge --auto-remove $pkg; done;

That's it!

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-139613-1-1.html 上篇帖子: Ubuntu 14.04环境搭建LAMP(Linux/Apache/MySQL/PHP)建站环境 下篇帖子: Ubuntu环境下安装LAMP组件
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表