在centos6中安装LAMP(超级简单实用)
来源:互联网 发布:电子章制作软件 编辑:程序博客网 时间:2024/05/29 14:19
本文来自:https://www.digitalocean.com/community/articles/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-6
About LAMP
LAMP stack is a group of open source software used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. Since the server is already running CentOS, the linux part is taken care of. Here is how to install the rest.
Set Up
The steps in this tutorial require the user on the virtual private server to have root privileges. You can see how to set that up in the Initial Server Setup Tutorial in steps 3 and 4.Step One—Install Apache
Apache is a free open source software which runs over 50% of the world’s web servers.
To install apache, open terminal and type in this command:
sudo yum install httpd
Once it installs, you can start apache running on your VPS:
sudo service httpd start
That’s it. To check if Apache is installed, direct your browser to your server’s IP address (eg. http://12.34.56.789). The page should display the words “It works!" like this.
How to find your Server’s IP address
You can run the following command to reveal your server’s IP address.
ifconfig eth0 | grep inet | awk '{ print $2 }'
Step Two—Install MySQL
MySQL is a powerful database management system used for organizing and retrieving data on a virtual server
To install MySQL, open terminal and type in these commands:
sudo yum install mysql-serversudo service mysqld start
During the installation, MySQL will ask you for your permission twice. After you say Yes to both, MySQL will install.
Once it is done installing, you can set a root MySQL password:
sudo /usr/bin/mysql_secure_installation
The prompt will ask you for your current root password.
Since you just installed MySQL, you most likely won’t have one, so leave it blank by pressing enter.
Enter current password for root (enter for none): OK, successfully used password, moving on...
Then the prompt will ask you if you want to set a root password. Go ahead and choose Y and follow the instructions.
CentOS automates the process of setting up MySQL, asking you a series of yes or no questions.
It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.
By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] y ... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] y... Success!By default, MySQL comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] y ... Success!Cleaning up...All done! If you've completed all of the above steps, your MySQLinstallation should now be secure.Thanks for using MySQL!
Step Three—Install PHP
PHP is an open source web scripting language that is widely used to build dynamic webpages.
To install PHP on your virtual private server, open terminal and type in this command:
sudo yum install php php-mysql
Once you answer yes to the PHP prompt, PHP will be installed.
PHP Modules
PHP also has a variety of useful libraries and modules that you can add onto your server. You can see the libraries that are available by typing:
yum search php-
Terminal then will display the list of possible modules. The beginning looks like this:
php-bcmath.x86_64 : A module for PHP applications for using the bcmath libraryphp-cli.x86_64 : Command-line interface for PHPphp-common.x86_64 : Common files for PHPphp-dba.x86_64 : A database abstraction layer module for PHP applicationsphp-devel.x86_64 : Files needed for building PHP extensionsphp-embedded.x86_64 : PHP library for embedding in applicationsphp-enchant.x86_64 : Human Language and Character Encoding Supportphp-gd.x86_64 : A module for PHP applications for using the gd graphics libraryphp-imap.x86_64 : A module for PHP applications that use IMAPTo see more details about what each module does, type the following command into terminal, replacing the name of the module with whatever library you want to learn about.
yum info name of the module
Once you decide to install the module, type:
sudo yum install name of the module
You can install multiple libraries at once by separating the name of each module with a space.
Congratulations! You now have LAMP stack on your droplet!
We should also set the processes to run automatically when the server boots (php will run automatically once Apache starts):
sudo chkconfig httpd onsudo chkconfig mysqld on
Step Four—RESULTS: See PHP on your Server
Although LAMP is installed on your virtual server, we can still take a look and see the components online by creating a quick php info page
To set this up, first create a new file:
sudo nano /var/www/html/info.php
Add in the following line:
<?phpphpinfo();?>
Then Save and Exit.
Restart apache so that all of the changes take effect on your virtual server:
sudo service httpd restart
Finish up by visiting your php info page (make sure you replace the example ip address with your correct one): http://12.34.56.789/info.php
It should look similar to this.
See More
After installing LAMP, you can go on to do more with MySQL (A Basic MySQL Tutorial),Create an SSL Certificate, or Install an FTP Server.- 在centos6中安装LAMP(超级简单实用)
- LAMP yum安装在Centos6.0
- Centos6.6中LAMP的安装
- CentOS6下安装LAMP
- CentOS6.4 lamp安装
- centos6.* 安装lamp环境
- centos6.6 lamp 安装
- centos6.5 安装lamp
- centos6.7搭建lamp超级全教程
- centos6.3 lamp环境安装
- 安装LAMP(CentOS6.6)
- CentOS6.4 YUM 安装LAMP
- Centos6.5 源码安装LAMP
- CentOS6.5安装LAMP+Redis
- centos6.5 yum安装lamp
- centos6源码编译安装lamp
- linux centos6 yum 安装lamp
- CentOS6.9编译安装LAMP
- Ubuntu“无法解析或打开软件包的列表或是状态文件”的解决办法
- 数据挖掘中要避免的11大错误
- 读一本跟技术无关的书籍
- org.apache.commons.lang.StringUtils的用法实例
- Linux 文件系统崩溃修复
- 在centos6中安装LAMP(超级简单实用)
- 传智播客才是最好的广州网页平面设计学校
- 参加广州PHP培训,,传智播客让你竞争一拔头筹
- 顺序点
- vim的保存文件和退出命令
- 广州.NET培训之.NET开发中什么是三层架构
- mysql的介绍 其他数据库的简单介绍
- android智能指针学习
- Android 屏幕适配问题