Install apache2 + PhP5 + mysql5 + pureftp + FTP in Ubuntu

Source: Internet
Author: User
Tags gz file
Install apache2 + PhP5 + mysql5 + pureftp + FTP in Ubuntu

1. Install ubuntu7.04 Desktop

Ii. Install mysql5 manually in Ubuntu Linux

1. Download the Linux version of MySQL 5.
Address: http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.20.tar.gz/from/http://mirror.vmmatrix.net/mysql/

2. install necessary software such as gcct:
Run the command on the terminal (for Netcom users, use the source of Jiaotong University ):
Sudo apt-Get install gcc cpp g ++ libncurses5-dev
Sudo apt-Get install make Autoconf automake libtool

3. decompress the package:
Run tar zxvf * .tar.gz to decompress the * .tar.gz file;
Run tar jxvf * .tar.bz2 to decompress the * .tar.bz2 file.
Install MySQL, PHP, Apache, AND Gd in the/opt/directory to facilitate management.
For details, refer:
Copy the MySQL on the desktop to/tmp: CP desktop/mysql-5.0.20.tar.gz/tmp
Go to the/tmp directory: CD/tmp
Unzip and expand the tar zxvf mysql-5.0.20.tar.gz

4. Compile and install MYSQL:
Go to the decompressed MySQL directory:
CD mysql-5.0.20
Assume that my common user is xcg1688, enter the following command on the terminal:
. /Configure -- prefix =/opt/MySQL -- With-mysqld-user = xcg1688 -- With-extra-charsets = all -- With-Unix-socket-Path =/tmp/MySQL. sock

-- Prefix =/opt/MySQL to install the mysql-5.0.20 specified to the/opt/MySQL directory;
-- With-extra-charsets = all supports multiple languages;
-- With-Unix-socket-Path =/tmp/MySQL. Sock
This specifies the location and file name of the online socket file after the MySQL server is started. That is, if the MySQL server is started successfully
The MySQL. Sock file is displayed in the directory. If not, MySQL cannot start.
-- With-mysqld-user = xcg1688
This allows the MySQL server to enable the MySQL server as well as the common user xcg1688 in the system. The advantage of starting MySQL with a common user is that the MySQL process will die on its own.
Drop and exit automatically. Of course, the root user can do the same, but sometimes some MySQL processes are dead, but they will not automatically exit, and the root user cannot kill themselves. Therefore, common users have the following benefits:
The MySQL process is dead but will not exit;
When you see "thank you for choosing MySQL !" .

5. installation:
Sudo make
Sudo make install
It took 1 hour and 15 minutes to make on my c2.66 computer. It took about 40 minutes for the second time.

6. Configuration:
Sudo CP/opt/MySQL/share/MySQL/my-medium.cnf/etc/My. CNF
This is to copy the configuration file to the/etc directory to become my. CNF. You can select the configuration file as needed (the configuration file is in
/Opt/MySQL/share/MySQL/directory, there is a my-huge.cnf my-medium.cnf my-large.cnf
My-small.cnf of these ).
Run
Sudo/opt/MySQL/bin/mysql_install_db
This command is used to create the MySQL authorization table.

Sudo chmod 755/opt/MySQL/var // set the directory permission of/opt/MySQL/var to 755
Sudo chown-r xcg1688: xcg1688/opt/MySQL/var // if you want to use xcg1688 to start MySQL
Sudo/opt/MySQL/share/MySQL. Server start // start the MySQL Service
Sudo chown-r xcg1688: xcg1688/opt/MySQL // Add the/opt/MySQL directory to the user xcg1688.
Sudo/opt/MySQL/bin/mysqladmin-u Root Password 123456 // set the password of the root user to 123456
/Opt/MySQL/bin/MySQL-u root-P // try to see if MySQL can log on. \ Q exit.

7. Set MySQL environment variables:
CD // return to your user directory.
CP. bashrc. bashrc_bak // backup. bashrc
Gedit ~ /. Bashrc
Add: Export Path =/opt/MySQL/bin: $ path :.
Enter source ~ on the terminal ~ /. Bashrc # Make the modification take effect
Env // view environment variables
MySQL
The above modification is only for a user. You can also use another method: after adding the path to/etc/profile, you can log out and echo it again.

8. Set MySQL to start automatically:
Sudo CP/opt/MySQL/share/MySQL. Server/etc/rc2.d/s20mysql
In addition, sudo gedit/etc/init. d/MySQL // creates a shell script for the service. You can see it in the service.
Join
#! /Bin/sh
/Opt/MySQL/share/MySQL. Server start
Then
$ Sudo chmod 755/etc/init. d/MySQL
$ Sudo chmod + x/etc/init. d/MySQL
Finally, select it in the service.

9. Security:
Restart the computer. Enter MySQL under Terminal $ to directly enter mysql>, indicating that the user is empty. Solution: Exit \ Q first, and then:
Mysql-u root-P
Mysql> Delete from mysql. User where user = ''; # It is strongly recommended to delete empty users.
Mysql> flush privileges; # refresh the permission table so that the change can take effect immediately.
Mysql> \ q press enter to exit
Result: MySQL cannot be entered. The MySQL-u XXXX-P format must be used.

3. Install linux_apache2 + PhP5:

1. Install mysql5 first.
Switch to the source of Jiaotong University, and then sudo apt-Get update
For details, refer to: Quick configuration of http://wiki.ubuntu.org.cn website.

2. installation:
Sudo apt-Get install apache2 // install apache2
Sudo apt-Get install PhP5 // install PhP5
Sudo apt-Get install libapache2-mod-auth-mysql
Sudo apt-Get install php5-mysql
Sudo apt-Get install php5-gd

3. Configure PHP. ini:
1) because of GD support, you need to change it. By the way, MySQL. So is also mounted:
Sudo gedit/etc/PhP5/apache2/PHP. ini
FindCode: # Extension = mysql. So
# Extension = Gd. So
Check it. If there is a comment # above, just remove it and save it. If you want to change the size of the uploaded file and memory, you can change the size together.
2) Find the code: mysql. default_socket =
Changed to MySQL. default_socket = '/tmp/MySQL. Sock'

4. Install phpMyAdmin
Sudo apt-Get install phpMyAdmin

Test: http: // localhost/phpMyAdmin // The interface is displayed. Do not log on.
Note: Start: sudo/etc/init. d/apache2 start
Restart command: sudo/etc/init. d/apache2 restart
DELETE command (from the Internet without verification): sudo apt-Get remove -- purge APACHE-common

5. Modify/etc/PHPmyAdmin/config. Inc. php:
Terminal input: sudo gedit/etc/PHPmyAdmin/config. Inc. php
Find: # $ cfg ['servers'] [$ I] ['sockets '] = '';
Remove the previous # and change it to $ cfg ['servers'] [$ I] ['socket '] ='/tmp/MySQL. Sock ';

6. Change the password:
Terminal input: mysql-u root-P
Update mysql. User SET Password = old_password ('20140901') where host = 'localhost' and user = 'root ';
Cause: we have modified the MySQL Root Password because the hash encryption method of the MySQL password has changed as before, so this problem occurs. The original method is changed to old_password after mysql4.1 or later. We can just update the password again.

7. restart the computer ).
Open a browser and test: http: // localhost/PHPmyAdmin/
Enter root as the user name, and then enter the new password. OK.

8. Question reference:
Improper configuration may fail. Please check if no # in step 1 has been entered. In addition, check the my. CNF and PHP. ini files. For more information, see sudo find/-name.
File), pay attention to permissions when searching, generally add sudo. My. CNF files are generally stored in/etc/My. CNF, and PHP. ini files are usually stored in/etc/PHP. ini files.
The socket =/tmp/MySQL. Sock is the same.

4. Install pure-ftpd in Ubuntu Linux:

1. Preparations: Install Ubuntu, mysql5, apache2, and PhP5 first.
Download: ftp://ftp.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.21.tar.gz
For example, download to the desktop. We recommend that you create a down file in the user folder and place the downloaded software there. But for ease of instruction, put it on the desktop first.

2. Open the terminal
$ CD Desktop
$ Tar zxvf pure-ftpd-1.0.21.tar.gz
$ Pure-ftpd-1.0.21 CD
$ Sudo CP/opt/MySQL/lib/MySQL/*. */usr/lib
$./Configure \
-- With-mysql =/opt/MySQL \
With-rfc2640

$ Sudo make // compile
$ Sudo make install // install

3. Copy two basic configuration files:
For pure-ftpd, if MySQL is used for authentication, then the two most important files are pure-ftpd.conf and pureftpd-mysql.conf, installed with source code, these two files cannot be found on the installation target. He is only a sample in our source code.
We can copy the two of them to the/etc directory. You can also copy them elsewhere, but the configuration changes.
$ Sudo CP pureftpd-mysql.conf/etc
$ Sudo CP configuration-file/pure-ftpd.conf/etc

4. modify/etc/pure-ftpd.conf
$ sudo gedit/etc/pure-ftpd.conf
here list part of the important, note that there is # before, if you think of it, please remove.
chrooteveryone yes # locking a user in the main directory is not expected. A1 users can enter the A2 directory
createhomedir yes # automatically create a user main directory based on the records in the data, automatically create a user directory
anonymouscancreatedirs yes # Allow anonymous users to create a new directory?
maxclientsnumber 200 # maximum number of users that can be connected, please decide.
maxload 100 # The number of system connections exceeds this value, prohibit anonymous download
maxclientsperip 8 # maximum number of connections from an IP address, know some sites, why is there only one thread?
maxidletime # maximum idle time after Client Connection
antiwarez yes # downloading files whose owner is "ftp" is not allowed. For example, files uploaded by anonymous users that are not verified by the local administrator.
mysqlconfigfile/etc/pureftpd-mysql.conf # key part, go, mySQL integration depends on it.
prohibitdotfileswrite yes # prohibit modification of hidden files
prohibitdotfilesread yes # prohibit reading of hidden files. Yes is recommended for these two items, otherwise, you accidentally put. you may have problems with your users if you have lost or changed the starting part (hidden file.
filesystemcharset UTF-8 # server-side UTF-8
clientcharset gb2312 # What the client sees is gb2312
according to your own requirements to set, note that you must open mysqlconfigfile and createhomedir.

5. Modify/etc/pureftpd-mysql.conf
$ Sudo gedit/etc/pureftpd-mysql.conf
Some important items are listed here. Note that there is # above. If you think of it, remove it.
# Optional: MySQL server name or IP. don't define this for Unix sockets.
Mysqlserver localhost # SQL runs on the local machine, of course localhost
# Optional: MySQL port. don't define this if a local UNIX socket is used.
Mysqlport 3306 # It was logged out. We can open it without actually opening it. The system will be OK by default.
# Mandatory: user to bind the server.
Mysqluser root # Here mysqluser and mysqlpassword are used by pureftpd to query the account database. I will use root. You can also specify them, but they must be specified in the mysql. User table.
Mysqlpassword 123456
MySQLDatabase ftpusers # This is an Authentication database we want to establish in MySQL
Configuration complete.

6. Create an FTP user directory
$ Sudo groupadd ftpgroup-G 10000 # create an ftpgroup group with a gid of 10000. Remember to use 10000 here.
$ Sudo useradd ftpuser-G ftpgroup-u 10000 # create an ftpuser user, which belongs to the ftpgroup group and uid is 10000.
$ Sudo mkdir/var/ftpdir
$ Sudo chown-r ftpuser. ftpgroup/var/ftpdir # Set the user and group to the/var/ftpdir directory and the following directory.

7. pureftp management:
There are many management software for pureftp. Here we choose this:
Http://machiel.generaal.net/files/pureftpd/ftp_v2.1.tar.gz
Assume that you go down to the desktop,
$ Cd
$ CD Desktop
$ Sudo tar zxvf ftp_v2.1.tar.gz # decompress and expand. A folder named FTP is added to the desktop.
$ Sudo mv ftp/var/www/FTP # Move the FTP folder to the Apache server home directory. In this article, it is/var/www.
The following configuration is installed. If there is any problem, please http: // localhost/PHPmyAdmin/, delete the database ftpusers, and then perform the following operations again.
Open your browser and enter http: // localhost/FTP/install. php
Step 1) follow Step 2 # in this step, use chmod to grant permissions if the config. php permission is insufficient.
Step 2) Click the "new installation," link;
Step 3) set "hostname" to 127.0.0.1, "username" to root, password to 123456, and connect,
All are OK and press "continue ". In another dialog box, except for the three items above, set "Database" to "ftpusers" and press
Refresh, all OK, and press "Step 4 ". If the problem is corrected, verify by "refresh.
Step 4) Select Chinese as the language, and change the FTP address to your IP address: 21, "Default User ID", and "default group
ID "is 10000. To control the traffic and upload/download ratio, select the last two items. Click "save" and save it to config. php. Step 5.
Step 5) change the administrator password and press "Step 6". Select a user with sufficient permissions to make the change take effect. Select root.
Step 6) If there is nothing to say, follow Step 7. Finished.
$ Sudo gedit/var/www/FTP/index. php
Find the following line and go to the previous.
// Echo ("<input type = \" text \ "name = \" dir_box \ "size = \" 40 \ "maxlength = \" 128 \ "value = \" $ dir \ "> \ n ");
Locate the following line and add //
Echo ("<input type = \" Hidden \ "name = \" dir_box \ "value = \" $ dir \ "> \ n ");
Find two. MD5 ($ _ post ['password _ box']). "'
Change all to. $ _ post ['password _ box']. "'

Open the browser and enter http: // localhost/FTP/
Create an account named a password A, home directory/var/ftpdir/A (how can it be called home directory? It is home !). If you are interested, you can check that directory A does not exist. Log On via FTP and A will be automatically created.

8. Run the test:
We have to run pureftp again, we can use the pureftp source code to extract the directory/configuration-file/pure-config.pl script to control, note that this is written in Perl. If Perl is not installed, install one. Input:
$ Cd
$ CD Desktop
$ CD pure-ftpd-1.0.21 # first go to the folder you decompress
$ Sudo chmod U + x configuration-file/pure-config.pl
$ Sudo CP configuration-file/pure-config.pl/etc # put here to find
$ Sudo/etc/pure-config.pl/etc/pure-ftpd.conf # Run the pureftpd Server
If the following information is displayed, the operation is successful.
Running:/usr/local/sbin/pure-ftpd-a-C200-B-C8-D-fftp-H-i15
-Lmysql:/etc/pureftpd-mysql.conf-l2000: 8-m-M100-S-u133: 022-u100
-X-J-K99-z-8utf-8-9utf-8
Next:
$ FTP localhost
Connected to localhost. localdomain.
220 ---------- welcome to pure-ftpd ----------
220-you are user number 1 of 200 allowed.
220-local time is now. server port: 21.
220-ipv6 connections are also welcome on this server.
220 you will be disconnected after 15 minutes of inactivity.
Name (localhost: xcg1688): A # User Name
331 user a OK. Password required
Password: # Password
230-User A has group access to: ftpgroup
230 OK. Current restricted directory is/
Remote system type is UNIX.
Using binary mode to transfer files.
Ftp> quit
221-goodbye. You uploaded 0 and downloaded 0 Kbytes.
221 logout.

9. Set pure-ftpd to serve the system:
$ Sudo gedit/etc/init. d/pure-ftpd
Content:
#! /Bin/sh
/Etc/pure-config.pl/etc/pure-ftpd.conf
Then:
$ Sudo chmod 755/etc/init. d/pure-ftpd
$ Sudo chmod + x/etc/init. d/pure-ftpd
Finally, select it in the service. Restart the system (to set the name anonymous, do not restart the system first, and go to step 2 ).

10. upload and download anonymously:
$ Sudo mkdir/var/ftpdir/anonymous # create a directory with a random name. Use it below and remember to unify it.
$ Sudo useradd FTP-G ftpgroup # Add a user named "ftp", which belongs to the above ftpgroup as well as other ftp users.
$ Sudo usermod-D/var/ftpdir/anonymous FTP # change the Home Directory of the user "FTP.
$ Sudo chmod + 777/var/ftpdir/anonymous # enables users with anonymous upper-level directories to delete files in the anonymous Directory Anonymous.
$ Sudo chown ftp: ftpgroup/var/ftpdir/Anonymous

Modify/etc/pure-ftpd.conf terminal: $ sudo gedit/etc/pure-ftpd.conf
Locate: anonymouscantupload no. You are not allowed to upload new files by anonymous users (NO = upload is allowed)

It is easy to use after restart.
Others:
The FTP client can be gftp. Enter sudo apt-Get install gftp on the terminal.

5. Pure-ftpd user permission allocation policy:

After the preceding settings, the permissions are as follows: The registered users have full permissions on their own folders and cannot view each other. Anonymous Users have the upload and Folder creation permissions on the anonymous folder, but do not have the permission to delete the folder. In actual work, this allocation scheme cannot meet the requirements. The following is an improvement:

1. Requirement Analysis:
Ftpmanager: full permission on all FTP files.
Registered users: the permissions remain unchanged and their respective files are fully isolated from each other.
Anonymous Users: they have the permission to download files in anonymous and upload and create directories under Anonymous/upload. They do not have the permission to delete files.

2. Implementation:
Http: // localhost/FTP/index. php
Create a user ftpmanager, enter the password, and change the main directory to/var/ftpdir. Change the upload/download speed.
$ Sudo chmod + 755/var/ftpdir/anonymous # The Write Permission for anonymous directories is restricted to the owner (also called the owner ).
$ Sudo chown ftpuser: ftpgroup/var/ftpdir/anonymous # change the owner of the anonymous directory to ftpuser.
$ Sudo usermod-D/var/ftpdir/anonymous FTP # The anonymous user's home directory is in anonymous. If you do this step by step, you do not have to do this step.
$ Sudo mkdir/var/ftpdir/Anonymous/upload
$ Sudo chmod + 755/var/ftpdir/Anonymous/upload # The write permission of the upload directory is restricted to the owner and group.
$ Sudo chown ftp: ftpgroup/var/ftpdir/Anonymous/upload # change the owner of the upload directory to FTP (anonymous account ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.