This article describes how to build a LAMP + vsftpd environment on CentOS. This is also one of the most popular server configuration solutions. For more information, see
This article describes how to build a LAMP + vsftpd environment on CentOS. This is also one of the most popular server configuration solutions. For more information, see
VPS can be viewed as a server that only uses you (in fact, it is a virtual machine). You can install any software on it and have the maximum permissions. The larger the permission, the greater the responsibility, you need to install the Web server, database, PHP, and other maintenance work on your own.
Currently, most VPS provides Linux operating systems without a graphical interface. Only the SSH command line interface is provided. Therefore, some simple Linux Command lines are required. Linux has many releases. The best release may be Redhat, but it is commercial software and cannot be used for free. Fortunately, it also has a Community version CentOS, use the source code of Redhat, remove the LOGO of Redhat, replace it with your own, and remove some closed-Source Software. Therefore, the system function, performance, and stability are almost equivalent to Redhat.
Install Linux
For Linux installation, you can choose the distributions you are familiar with, such as Ubuntu, Debian, and Fedora. The service providers can install them by default in a minimal installation mode, the version I selected is CentOS 6.3. Considering that the VPS memory is small, the 32-bit version is installed.
After installation, log on as the root user and make necessary updates to the system. Linux and Mac both come with Terminal. For Windows, we recommend that you use PuTTY for SSH connection.
# Log on to the server ssh root@198.xxx.xxx.xxx as a root user... # system update yum update...
Install Apache
Apache is a free and open-source Web Server established on the Linux platform. It is said that more than half of the websites in the world are running on Apache. To install Apache, enter the following command in the command line:
Yum install httpd
Apache installed by default may not be the latest version, but it is indeed the most stable version tested on this Linux version. If you must install the latest version, you need to download the latest version from the Apache official website.
After installation, run the following command to start the Apache service:
Service httpd start
The default web page storage directory is located at/var/www/html/And then accessed in the browser. If a test page of Apache appears, it indicates that Apache has been installed successfully.
Install MySQL
MySQL is a very popular database software. It was initially developed by MySQL AB in Sweden and acquired by Sun. It is currently a product of Oracle. The command for installing MySQL is as follows:
Yum install mysql-server
Start the MySQL service:
Service mysqld start
Then you need to set a password for the root user of MySQL. Enter the following command:
/Usr/bin/mysql_secure_installation
If you execute the above command, MySQL will ask you to provide the current root User Password, because we just installed it, so the password is empty, directly press enter, and then set a new root user password.
Then there will be some security options for you to choose Y or N. For example, whether to remove Anonymous logon and whether to prevent root users from logging on remotely. If y is selected, root can only Log On As localhost, and whether to remove the test database and immediately refresh the permission table, the general situation is as follows:
[Root @ CentOS6 ~] #/Usr/bin/mysql_secure_installation
NOTE: running all parts of this script is recommended for all MySQLSERVERS in production use! Please read each step carefully! In order to log into MySQL to secure it, we'll need the currentpassword for the root user. if you 've just installed MySQL, andyou haven' t set the root password yet, the password will be blank, so you shoshould just press enter here. enter current password for root (enter for none): OK, successfully used password, moving on... setting the root password ensures that nobody can log into the MySQLroot user wi Thout the proper authorisation. Set root password? [Y/n] yNew password: Re-enter new password: Password updated successfully! Reloading privilege tables... Success! 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 shoshould remove them before moving into aproduction environment. remove anonymous users? [Y/n] y... Success! Normally, root shoshould 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 shocould 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 shoshould now be secure. Thanks for using MySQL!
Install PHP
PHP is a widely used open-source dynamic scripting language. To install PHP and work with MySQL, run the following command:
Yum install php-mysql
In this case, you need to test whether PHP works properly. You can create a test page.
# Switch to the Apache default webpage directory cd/var/www/html # create a php script file touch phpinfo. php # Write a small php script to the file and test the echo '<? Php phpinfo ();?> '> Phpinfo. php
# Because PHP has just been installed, do not forget to restart Apache. Otherwise, PHP will not work properly.
Service httpd restart
Then access it in the browser to see If PHP is working properly.
If the page displays server-related environment information, the LAMP environment is ready to work normally.
Install vsftpd
The easiest way to securely upload files to or download files from the server is to use FTP. Here we choose the popular "Very Secure FTPD" in Linux ", that is, very secure FTP:
Yum install vsftpd
After installation, some simple configurations are required: