[Linux VPS] Guide to install Apache, MySQL, PHP to run 1 site

Thứ Hai, 26 tháng 5, 2014
Update VPS 
yum update
About LAMP 
LAMP stack is a group of open source software used to get up and running web servers. 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 up in the Furniture Initial Server Setup Tutorial in steps 3 and 4. 

One-Step Install Apache 
Apache is a free open source software đó runs over 50% of the world's web servers. 

To install apache, open a terminal and type in this command: 
sudo yum install httpd
Once it installs, you can start running apache 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 nên display the words "It works!" Like this. 

How to Find Your Server's IP address 
You need to run another command to Reveal những your server's IP address. 
ifconfig eth0 | grep inet | awk '{print $ 2}'
Two-Step Install MySQL 
MySQL is a powerful database management system used for organizing and lấy data on a virtual server 

To install MySQL, open a terminal and type in these commands: 
sudo yum install mysql-server 
sudo yum-y install php-mysql 
sudo yum install php-mbstring 
sudo 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 MySQL root 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 will not have one, than 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 thing is just to say Yes to all the options. At the end, MySQL will reload and implements the new changes. 

By default, a MySQL installation has an anonymous user, either, allowing anyone 
to log into MySQL without having to have a user account created for 
them. This is intended only for testing, and to make the installation 
go a bit smoother. Nên remove them before moving into a 
production environment. 

Remove anonymous users? [Y / n] y 
... Success! 

Normally, root nên only be allowed to connect from 'localhost'. This 
Furniture ensures someone can not 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 can 
access. This is am also intended only for testing, and removed nên 
before 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 Furniture Will Ensure all changes made so far 
will 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 MySQL 
nên now be secure installation. 

Thanks for using MySQL!
Three-Step Install PHP 
PHP is an open source scripting language web Furniture is widely used to build dynamic webpages. 

To install PHP On Your Virtual Private Server, open a terminal and type in this command: 
sudo yum install php php-mysql
Once you answer yes to the prompt PHP, PHP will be installed. 

PHP Modules 
Also PHP has a variety of useful libraries and modules Furniture you can add onto your server. You can see the libraries Furniture are available by typing:
yum search php-
Terminal will then display the list of Possible modules. The beginning looks like this: 
php-bcmath.x86_64: A module for PHP applications for using the bcmath library 
php-cli.x86_64: Command-line interface for PHP 
php-common.x86_64: Common files for PHP 
php-dba.x86_64: A database abstraction layer module for PHP applications 
php-devel.x86_64: Files needed for building PHP extensions 
php-embedded.x86_64: PHP library for embedding in applications 
php-enchant.x86_64: Human Language and Character Encoding Support 
php-gd.x86_64: A module for PHP applications for using the gd graphics library 
php-imap.x86_64: A module for PHP applications use IMAP Furniture
To see more details about what each module does, type The following command into the 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 the LAMP stack On Your droplet! 

We nên am also set the processes to automatically khi the server boots shaking (tremors will php Apache starts automatically once): 
sudo chkconfig httpd on 
sudo chkconfig mysqld on
Step Four-RESULTS: See PHP On Your Server 
Although LAMP On Your virtual server is installed, 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 theo line: 
<? Php 
phpinfo (); 
?>
Then Save and Exit. 

Furniture Restart apache than all of the changes take effect On Your virtual server: 
sudo service httpd restart
Finish up by visiting trình PHP info page (make sure you replace the example IP address with your Flickr correct one): http://12.34.56.789/info.php 

It nên look similar to this. 

[Linux VPS] Hướng dẫn cài đặt Apache, MySQL, PHP để chạy 1 trang web
Chia sẻ bài viết ^^
Other post

All comments [ 0 ]


Your comments