A simple guide for building a LAMP + vsftpd environment on CentOS, centosvsftpd. A simple guide for building a LAMP + vsftpd environment on CentOS. centosvsftpdVPS can be seen as a server that only uses you (in fact, it is a virtual machine ), you can build a LAMP + vsftpd environment on CentOS as a simple guide, centosvsftpd
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 select the release version you are familiar with, such as Ubuntu, Debian, and Fedora. the service provider installs it 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 access the http://198.xxx.xxx.xxx 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 MySQL SERVERS 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 should 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 without 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 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!
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 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
Visit http://198.xxx.xxx.xxx/phpinfo.php in the browser to check whether PHP works 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:
# Edit the vsftpd configuration file vi/etc/vsftpd. conf... # Anonymous logon to anonymous_enable = NO # a local account can log on to local_enable = YES # write_enable = YES # All users can only access the home directory chroot_local_user = YES... # restart vsftpd or above to apply the service vsftpd restart
How can I access the server through FTP? we recommend FileZilla, an FTP client tool for Windows, Linux, and Mac OS.
Logon to vsftpd is generally performed in the Linux user area, but root users are not allowed to log on. Therefore, you need to create another Linux User:
# Add the user lichaoadduser lichao # set the password passwd lichao for lichao # for security reasons, you only want this user to log on to vsftpd. # instead of logging on to the server via ssh, you can disable ssh access to usermod-s/sbin/nologin lichao.
Now, you can use any FTP tool such as FileZilla to log on to vsftpd using the lichao user and the corresponding password. the default directory is/home/lichao.
Set Apache, MySQL, and vsftpd to start up
The command to set them to start at startup is as follows:
chkconfig httpd onchkconfig mysqld onchkconfig vsftpd on
PHP will be started with Apache.
So far, a basic and complete dynamic web server, database server, and FTP server have been installed.
VPS can be seen as a server that only you use (in fact, it is a virtual machine), you can on the above...