Finally, we installed LAMP with apt-get in Debian. Previously, we used CentOS for compilation and installation, which was faster than now, but the memory usage was not optimized, there is no time for further research... After installing yum, it is even more troublesome. you can use other methods. phpmyadmin cannot connect to the database... If you try N methods, you can only give up. Installed back to Debian --
Finally, we installed LAMP with apt-get in Debian. Previously, we used CentOS for compilation and installation, which was faster than now, but the memory usage was not optimized, there is no time for further research... After installing yum, it is even more troublesome,PhpmyadminCannot connect to the database... If you try N methods, you can only give up. Installed back to Debian --
Record your installation process for later use ~
1. update Debian:
Apt-get update
Apt-get updgrade
2. install Apache2:
Since the memory is only 360 MB, it is easy to use, so the prefork mode is used for installation:
Apt-get install apache2-mpm-prefork
3. installMysql
Apt-get install mysql-server-5.0 for mysql-common mysql-client
4. install php components and integrate mysql
Apt-get install php5-common php5-mysql php5-cgi php5-gdphp5-mcrypt libapache2-mod-php5 php5-memcache php5-imagickphp5-suhosin
If necessary, you can install
Apt-get install php5-common php-pear php5-curl php5-dev php5-gdphp5-idn php5-imap php5-mhash php5-ming php5-mysql php5-psphp5-pspell php5-recode php5-snmp php5-sqlite php5-tidyphp5-xsl
Note:
To delete a package, run the following command:
Apt-get remove
For example, deleting php-cgi
Apt-get remove php-cgi
If you do not know which installation packages are available, run the following command:
Apt-cache search
For example:
Apt-cache search apache2
5. set the Mysql account, password, and optimization:
Mysqladmin-u root password ''// enter the password in quotation marks
Log on to the MySQL database
Mysql-u root-p
Modify original account (mysql)
Mysql> use mysql;
Mysql> update user set user = "user-defined user name" where user = "root"; (change the root user name of mysqlCentosTo prevent brute force password cracking)
Mysql> select Host, User, Password, Select_priv, Grant_priv fromuser;
Mysql> delete from user where user = ''; (delete user)
Mysql> delete from user where password = ''; (delete a user)
Mysql> delete from user where host = ''; (delete a user)
Mysql> drop database test; (delete the default test database)
Mysql> flush privileges; (refresh the mysql cache to make the preceding settings take effect immediately)
Mysql> quit;
Modify the MySQL configuration file in/etc/mysql/my. cnf
Find # skip-innodb remove comment
Reload Mysql
/Etc/init. d/mysql reload
Or restart Mysql.
/Etc/init. d/mysql restart
6. set php
Modify the File:/etc/php5/apache2/php. ini
Find the following value and change it to the value you need.
Memory_limit
Post_max_size
Upload_max_filesize
Disable the following functions: Off
Enable_dl
Display_errors
7. Apache optimization and settings:
Modify the/etc/apache2/apache2.conf file
Timeout 300
Change
Timeout 60
KeepAliveTimeout 15
Change
KeepAliveTimeout 5
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
Change
StartServers 3
MinSpareServers 5
MaxSpareServers 10
MaxClients 50
MaxRequestsPerChild 2000
Find AddType application/x-gzip. gz. tgz and add the following content under it:
AddType application/x-httpd-php. php
AddType application/x-httpd-php-source. phps
Save and quit, and restart apache
/Etc/init. d/apache2 reload
/Etc/init. d/apache2 restart
Activate the deflate module (used for page compression) and enter the following on the SSH interface:
A2enmod deflate
Let the apache2 process load the new configuration module
/Etc/init. d/apache2 force-reload
Modify the/etc/apache2/apache2.conf file and add
Add the following content after the file:
DeflateCompressionLevel 6
AddOutputFilterByType DEFLATE text/html text/plain text/xmlapplication/x-httpd-php
AddOutputFilter DEFLATE css js
Activate mod rewrite (for pseudo-static connection addresses) and enter the following on the SSH interface:
A2enmod rewrite
Let the apache2 process load the new configuration module
/Etc/init. d/apache2 force-reload
Modify the/etc/apache2/apache2.conf file and add the following content at the end:
RewriteEngine> some people set this on the Internet, but many times the website is too much to control, and I have not added this last segment in apache2.conf.
Reload apache
/Etc/init. d/apache2 reload
Or restart apache.
/Etc/init. d/apache2 restart
8. set multiple domain names under Debian Apache5:
Set/etc/apache2/sites-available/default, change ServerAdmin to your own mailbox, and add a section before, as your space Root Directory domain name:
ServerName xxx.com
Change the/var/www/directory to/home/www/
Enter:
Chmod 755-R/home/www // Set the website root directory permission
Ls-lh // view the folder owner
Cd/home/www/
Chown-R www-data: www-data/home/www/
Save and exit default.
Create a new folder "1" in/home/www/and create a new file in the current directory "/sites-available/". suppose the file name is 1, open file 1, and enter the following content:
ServerName xxx.com // enter the domain name here
ServerAdmin
DocumentRoot "/home/www/1/" // Website Directory
// After this section is added, you can directly support. htaccess
Options FollowSymLinks
AllowOverride All
ErrorLog "/var/log/apache2/1-error.log"
CustomLog "/var/log/apache2/1-access.log" common
Save the file and enter:
A2ensite 1
At this time, the configured website domain name has been bound, and there will be a 1 shortcut in the/etc/apache2/sites-enabled/folder. After restarting Apache, you can operate the website:
/Etc/init. d/apache2 restart
Now you can use your browser to log on to your domain name ~
It is really a little difficult to separate settings, but the benefits are still great. for example, if I want to maintain website 1 separately, just enter the following command:
A2dissite silent
Restart it again.
/Etc/init. d/apache2 restart
Other websites will still operate normally and will not be affected ~
9. install phpmyadmin:
Because debian's php version is 5.2, you can use phpmyadmin3.1, which saves a lot of trouble. you can directly perform the following operations without installing apt-get:
Cd/usr/local/src
Wgethttp: // ncu.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-3.2.0-all-languages.tar.gz
Tar zxvf phpMyAdmin-3.2.0-all-languages.tar.gz
Cp-rf phpMyAdmin-3.2.0-all-languages/home/www/phpmyadmin
10. installSendmail:
Many people say that sendmail is not good, but I don't want an email server, but I only need support for sending emails. sendmail is enough for me ~
Apt-get install sendmail
11. install Zend Optimizer
Cd/usr/local/src
Wgethttp: // downloads.zend.com/optimizer/3.3.3/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
Tar xzvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
./ZendOptimizer-3.3.3-linux-glibc23-i386/install. sh
Follow the prompts to proceed step by step.
In a word. If your server environment does not require ZendOptimizer, you will not install it if you are unconcerned. Avoid conflicts with eaccelerator.
# Server
Install Apache Mysql PHP
Before installation, make sure that your version is up to date. Run the following command: ("#" indicates that you should run the command as a root user ).
# Aptitude update & aptitude upgrade
Run the following command to install mysql:
# Aptitude install mysql-server mysql-client
After installing the mysql server, you should change the root password. * This step is invalid for debianLenny, because during installation, you will be asked to enter the password of the mysql root user.
#/Usr/bin/mysqladmin-u root password 'enter-your-good-new-password-here'
To ensure security, you should not use the root account to run the database, but create an account to connect to your mysql database from a PHP script.
# Aptitude install apache2 apache2-doc
# Aptitude install php5 php5-mysql libapache2-mod-php5
Configure Apache Mysql PHP
Apache2 configuration file:/etc/apache2/apache2.conf
You can edit this configuration file as needed.
Test PHP
To test the php interface, edit the file/var/www/apache2-default/test. php:
# Nano/var/www/apache2-default/test. php
Insert the following