Table of Contents
A simple guide to setting up a LAMP vsftpd environment on CentOS, centosvsftpd
Home Backend Development PHP Tutorial A simple guide to setting up a LAMP vsftpd environment on CentOS, centosvsftpd_PHP tutorial

A simple guide to setting up a LAMP vsftpd environment on CentOS, centosvsftpd_PHP tutorial

Jul 13, 2016 am 09:45 AM
centos lamp University

A simple guide to setting up a LAMP vsftpd environment on CentOS, centosvsftpd

VPS can be regarded as a server that only you use (in fact, it is a virtual machine) , you can install any software on it with maximum permissions. As the saying goes, with greater authority comes greater responsibility. You need to install the web server, database, PHP, and other maintenance work yourself.

The operating system provided by most VPS now is Linux, and it does not have a graphical interface. It only provides an SSH command line interface, so you need to know some simple Linux command lines. Linux has many distributions. The best distribution may be Redhat, but it is commercial software and cannot be used for free. Fortunately, it also has a community version CentOS, which completely uses the source code of Redhat and removes the Redhat LOGO. Replace it with your own and remove some closed source software, so the system functions, performance and stability are almost the same as Redhat, so I chose it.
Install Linux

For Linux installation, you can choose a distribution you are familiar with such as Ubuntu, Debian, Fedora, etc. The service provider will install it by default in a minimal installation mode. The version I chose is CentOS 6.3, taking into account the VPS memory Smaller, the 32-bit version is installed.

After installation, log in as the root user and allow the system to perform some necessary updates. Both Linux and Mac come with Terminal. If it is Windows, it is recommended to use PuTTY for SSH connection.

#以 root 用户登陆服务器
ssh root@198.xxx.xxx.xxx
...
#系统更新
yum update
...

Copy after login

Install Apache

Apache is an old free and open source web server on the Linux platform. It is said that more than half of the websites in the world run on Apache. To install Apache, enter the following command at the command line:

yum install httpd

Copy after login

The Apache installed by default may not be the latest version, but it is 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, execute the following command to start the Apache service:

service httpd start

Copy after login

The default web page storage directory is located in /var/www/html/, and then visit http://198.xxx.xxx.xxx in the browser. If a test page of Apache can appear, it means that Apache has been installed successfully. .
Install MySQL

MySQL is a very popular database software. It was originally developed by the Swedish company MySQL AB and was later acquired by Sun. It is currently a product of Oracle. The command to install MySQL is as follows:

yum install mysql-server

Copy after login

Start the MySQL service:

service mysqld start

Copy after login

Then you need to set a password for the MySQL root user. You can enter the following command:

/usr/bin/mysql_secure_installation

Copy after login

If you execute the above command, MySQL will ask you to provide the password of the current root user. Because we have just installed it, the password is empty. Just press Enter and set the new root user password.

There will then be some security options asking you to choose Y or N. For example, whether to remove anonymous login, whether to prevent root users from logging in remotely, if you select y, then root can only log in through localhost, and whether to remove the test database, refresh the permission table immediately, etc. The general situation is as follows:

[root@CentOS6 ~]# /usr/bin/mysql_secure_installation

Copy after login
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 current
password for the root user. If you've just installed MySQL, and
you 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 MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, 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. You should remove them before moving into a
production environment.

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

Normally, root should only be allowed to connect from 'localhost'. This
ensures 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 can
access. This is also intended only for testing, and should be removed
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 will ensure that 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
installation should now be secure.

Thanks for using MySQL!

Copy after login

Install PHP

PHP is a widely used open source dynamic scripting language. To install PHP and make it work with MySQL, you need to execute the following command:

yum install php php-mysql

Copy after login

At this time, you need to test whether PHP can work properly. You can create a test page.

#切换到 Apache 默认网页目录
cd /var/www/html
#创建一个 php 脚本文件
touch phpinfo.php
#向文件写入一小段 php 脚本,测试用
echo '<&#63;php phpinfo(); &#63;>' > phpinfo.php
<p># 因为刚刚安装了 PHP,所以别忘了重启一下 Apache,否则 PHP 不能正常工作<br />service httpd restart</p>
Copy after login

Then visit http://198.xxx.xxx.xxx/phpinfo.php in the browser to see if PHP is working normally.

If the page can display server-related environment information normally, it means that the LAMP environment is working normally.
Install vsftpd

To securely upload files to the server or download files from the server, the easiest way is to use FTP. Here we choose the very popular "Very Secure FTPD" under Linux, that is, very secure FTP:

yum install vsftpd

Copy after login

After installation, you still need to perform some simple configuration:

#编辑 vsftpd 配置文件
vi /etc/vsftpd/vsftpd.conf
...

#不允许匿名登陆
anonymous_enable=NO

#本地账户可以登陆
local_enable=YES

#可以写入
write_enable=YES

#所有用户只能访问其 home 目录
chroot_local_user=YES
...

#重启 vsftpd 以上设置才能生效
service vsftpd restart

Copy after login

How to access the server using FTP protocol? Here we recommend the FTP client tool FileZilla, which is available in Windows, Linux and Mac OS versions.

Login to vsftpd usually uses the Linux user area to log in, but the root user is not allowed to log in, so you need to create a new Linux user:

#添加用户 lichao
adduser lichao

#为 lichao 设置密码
passwd lichao

#如果出于安全考虑,这个用户你只想它能登陆 vsftpd,
#而不能以 ssh 方式登陆服务器,可以禁止其 ssh 登陆
usermod -s /sbin/nologin lichao

Copy after login

At this point, you can use any FTP tool such as FileZilla to log in to vsftpd with the user lichao and the corresponding password. The default directory is /home/lichao
Set up Apache, MySQL and vsftpd services to start at boot

The command to set them up at startup is as follows:

chkconfig httpd on
chkconfig mysqld on
chkconfig vsftpd on

Copy after login

PHP will be started with Apache.

At this point, a basically complete dynamic web server, database server, and FTP server are installed.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1041627.htmlTechArticleA simple guide to setting up a LAMP vsftpd environment on CentOS, centosvsftpd VPS can be regarded as a machine that only you can use server (actually it is a virtual machine) on which you can...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to input Chinese in centos How to input Chinese in centos Apr 07, 2024 pm 08:21 PM

Methods for using Chinese input in CentOS include: using the fcitx input method: install and enable fcitx, set shortcut keys, press the shortcut keys to switch input methods, and input pinyin to generate candidate words. Use iBus input method: Install and enable iBus, set shortcut keys, press the shortcut keys to switch input methods, and input pinyin to generate candidate words.

How to read USB disk files in centos7 How to read USB disk files in centos7 Apr 07, 2024 pm 08:18 PM

To read U disk files in CentOS 7, you need to first connect the U disk and confirm its device name. Then, use the following steps to read the file: Mount the USB flash drive: mount /dev/sdb1 /media/sdb1 (replace "/dev/sdb1" with the actual device name) Browse the USB flash drive file: ls /media/sdb1; cd /media /sdb1/directory; cat file name

How to enter root permissions in centos7 How to enter root permissions in centos7 Apr 02, 2024 pm 08:57 PM

There are two ways to enter the root authority of CentOS 7: use the sudo command: enter sudo su - in the terminal and enter the current user password. Log in directly as the root user: Select "Other" on the login screen, enter "root" and the root password. Note: Operate carefully with root privileges, perform tasks with sudo privileges, and change the root password regularly.

What to do if you forget your password to log in to centos What to do if you forget your password to log in to centos Apr 07, 2024 pm 07:33 PM

Solutions for forgotten CentOS passwords include: Single-user mode: Enter single-user mode and reset the password using passwd root. Rescue Mode: Boot from CentOS Live CD/USB, mount root partition and reset password. Remote access: Use SSH to connect remotely and reset the password with sudo passwd root.

SCP usage tips-recursively exclude files SCP usage tips-recursively exclude files Apr 22, 2024 am 09:04 AM

One can use the scp command to securely copy files between network hosts. It uses ssh for data transfer and authentication. Typical syntax is: scpfile1user@host:/path/to/dest/scp -r/path/to/source/user@host:/path/to/dest/scp exclude files I don't think you can when using scp command Filter or exclude files. However, there is a good workaround to exclude the file and copy it securely using ssh. This page explains how to filter or exclude files when copying directories recursively using scp. How to use rsync command to exclude files The syntax is: rsyncav-essh-

What should I do if I forget my centos username and password? What should I do if I forget my centos username and password? Apr 02, 2024 pm 08:54 PM

After forgetting your CentOS username and password, there are two ways to restore access: Reset the root password: Restart the server, edit the kernel command line in the GRUB menu, add "rw init=/sysroot/bin/sh" and press Ctrl+x ;Mount the root file system and reset the password in single-user mode. Use rescue mode: Start the server from the CentOS installation ISO image, select rescue mode; mount the root file system, copy the chroot environment from the ISO image, reset the password, exit the chroot environment and restart the server.

How to enable root permissions in centos7 How to enable root permissions in centos7 Apr 07, 2024 pm 08:03 PM

CentOS 7 disables root permissions by default. You can enable it by following the following steps: Temporarily enable it: Enter "su root" on the terminal and enter the root password. Permanently enabled: Edit "/etc/ssh/sshd_config", change "PermitRootLogin no" to "yes", and restart the SSH service.

What should I do if I forget my centos7 password? What should I do if I forget my centos7 password? Apr 02, 2024 pm 08:51 PM

Three solutions for forgotten passwords in CentOS 7: Single-user mode: Restart the system, edit the kernel options, change ro to rw init=/sysroot/bin/sh, and use the passwd command to reset the root password. Rescue mode: Boot from the installation media, select rescue mode, mount the root file system, chroot to the root file system, and use the passwd command to reset the root password. Grub2 command line: Restart the system, press c to enter the command line, load the kernel, mount the root file system, chroot to the root file system, and use the passwd command to reset the root password.

See all articles