Debian7 Configure lamp environment and configure Web site steps

Source: Internet
Author: User
Tags mkdir create database install wordpress sub domain

Installation Environment: This article is used in the Debian7 32-bit.

First, install and configure the Apache Web server

Run the upgrade command to ensure that all aspects of our system components are up to date.
The code is as follows Copy Code
Apt-get Update
Apt-get Upgrade--show-upgraded
Install the current version of the Apache Web server (in the 2.x series), execute the following command:
The code is as follows Copy Code
Apt-get Install Apache2
Most application sites use the path rewrite (pseudo static) feature, the default Apache is not installed, we need to run script support rewrite
The code is as follows Copy Code
A2enmod rewrite
Start rewrite.
Edit/etc/apache2/apache2.conf file configuration to make system run more optimized (test machine is based on 1GB memory VPS)
The code is as follows Copy Code
<ifmodule mpm_prefork_module>
Startservers 2
Minspareservers 6
Maxspareservers 12
MaxClients 80
Maxrequestsperchild 3000
</IfModule>
This step we can also default, and so on the site to adjust the operation of the comparison is different, the old left now do not understand this parameter corresponding to the performance difference, I used to use MAPN environment when MySQL occupies too much, and then adjusted occupancy rate is much lower.
After the configuration is complete, we need to configure the domain name, the sub domain name to add the site below.

Second, configure the virtual host, bound domain name

In the/etc/apache2/sites-available/folder, used to store all sites of the site domain name profile, set up the site with the domain name. conf so many times when the site can also see the corresponding site. For example, to create 2 sites here, we need to configure 2 conf files, as follows:

Site A-/etc/apache2/sites-available/111cn.net.conf
The code is as follows Copy Code
<virtualhost *:80>
ServerAdmin admin@111cn.net
ServerName 111cn.net
Serveralias www.111cn.net
documentroot/srv/www/111cn.net/public_html/
Errorlog/srv/www/111cn.net/logs/error.log
Customlog/srv/www/111cn.net/logs/access.log combined
</VirtualHost>
Site B-/etc/apache2/sites-available/idcxen.com.conf
The code is as follows Copy Code
<virtualhost *:80>
ServerAdmin webmaster@idcxen.com
ServerName idcxen.com
Serveralias www.idcxen.com
documentroot/srv/www/idcxen.com/public_html/
Errorlog/srv/www/idcxen.com/logs/error.log
Customlog/srv/www/idcxen.com/logs/access.log combined
</VirtualHost>
According to the above demonstration, we have several sites to build a few. conf file, and then configure it for the path. We also need to create the same number of directories that are involved in the above.
The code is as follows Copy Code
Mkdir-p/srv/www/111cn.net/public_html
Mkdir/srv/www/111cn.net/logs
Mkdir-p/srv/www/idcxen.com/public_html
Mkdir/srv/www/idcxen.com/logs
Execute Command Start site
The code is as follows Copy Code
A2ensite 111cn.net.conf
A2ensite idcxen.com.conf
Start Apache
The code is as follows Copy Code
Service Apache2 Restart
Note: If we want to cancel this site run, then use this command to cancel this site
The code is as follows Copy Code
A2dissite 111cn.net.conf

Third, install and configure the MySQL database

A-Install MySQL

The code is as follows Copy Code
Apt-get Install Mysql-server
It is slightly more complicated to require us to enter the root user password for MySQL during execution. The database configuration file is in/etc/mysql/my.cnf, if we need to adjust as far as possible first back up one.
B-Configure MySQL to build a database
The code is as follows Copy Code
Mysql_secure_installation
We need to enter the MySQL database set above the root password to enter, the first entry will ask if you need to modify, as well as the various other settings, we choose the n/y option as needed.
The code is as follows Copy Code
Mysql-u root-p
Create Database laozuoorg;
Grant all on laozuoorg.* to ' Laozuouser ' identified by ' 111cn.net ';

Use root to enter the MySQL database, enter the password we have set before, then establish the laozuoorg database name, Laozuouser datasheet, and 111cn.net set the database password.

Enter quit to exit MySQL settings after creation.

Iv. Installing and setting up the PHP environment

The code is as follows Copy Code
Apt-get Install PHP5 php-pear
After installation we need to configure the php.ini file (/etc/php5/apache2/php.ini) can be changed by default
The code is as follows Copy Code
Max_execution_time = 30
Memory_limit = 128M
error_reporting = e_compile_error| e_recoverable_error| e_error| E_core_error
Display_errors = Off
Log_errors = On
Error_log =/var/log/php.log
Register_globals = Off
Max_input_time = 30
We also need to create a log directory and set permissions
The code is as follows Copy Code
mkdir/var/log/php
Chown www-data/var/log/php
If we need MySQL PHP support, then we must install the following command for the PHP5 MySQL package:
The code is as follows Copy Code
Apt-get Install Php5-mysql
Start Apache
The code is as follows Copy Code
Service Apache2 Restart
In this way, through the above four steps, you can build the site, database, we will only need to/srv/www/idcxen.com/public_html upload Web page program, and then install according to the prompts can be.
PS: Old left to install WordPress successful, the only need to note that the root directory permissions need to be writable. htaccess or manually create a pseudo static file so that the background fixed connection settings will not take effect.
The code is as follows Copy Code
Chown-r www-data:www-data/srv/www/

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.