If we are new to start learning and use the Linux vps/server to build the site and project environment, if due to time and effort Limited, we can choose one-click Package or Web panel easy to get started. If we want to optimize the system later, and even need to learn how to maximize the use of vps/server, then we can learn how to manually compile the site environment.
Linux Debian System Configuration lamp (Apache, MySQL, PHP) website Environment detailed
In many environments, most of our users are still accustomed to using the Apache Web site, and as a small and medium-sized website, Apache and Litespeed are still very good. In this article, Lao Jiang will spend a little time detailing this Debian-based version of the lamp site environment deployment, all using manual compilation, without a key package, rely on us to maximize the use of resources, and we can learn the environment of the deployment of the need for the process.
First, deploy and update the environment pack
In this article, Lao Jiang uses the Debian7 version, and other versions of Debian are similar. We need to install the system first, have SSH permissions, and then log in to SSH to deploy the update source and package.
Apt-get Update
Apt-get Upgrade--show-upgraded
This allows us to ensure that all components and software of the system are up-to-date.
Second, install the Apache web-driven environment
Apt-get Install Apache2
Most of the sites need to use pseudo-static function, many people think it is Apache-specific, in fact, the default is not, we need to install.
A2enmod rewrite
If necessary, we need to restart Apache execution Service apache2 restart. Here we should need to configure the/etc/apache2/apache2.conf file, so as to optimize the system performance of the site, we do not operate here temporarily, the latter can be resolved uniformly, according to our system memory and the actual usage of the adjustment.
PS: All the prompts to continue y/n during the installation process, we will enter Y, then enter.
Third, configure and create the site Directory
So far our site environment is perfect, we will first configure the site to be built. Add the configuration file first. conf, in the/etc/apache2/sites-available/directory, we need to create the corresponding configuration file.
A-Create A itbulu.com site configuration file
/etc/apache2/sites-available/itbulu.com.conf
We can manually configure or add the VI directly.
<virtualhost *:80>
ServerAdmin [email protected]
ServerName itbulu.com
Serveralias www.itbulu.com
documentroot/var/www/itbulu.com/public_html/
Errorlog/var/www/itbulu.com/logs/error.log
Customlog/var/www/itbulu.com/logs/access.log combined
</VirtualHost>
The script is configured according to its own website domain name so that it is not wrong.
B-Add a site in imitation banwagong.cn
/etc/apache2/sites-available/banwagong.cn.conf
Then add the configuration script.
<virtualhost *:80>
ServerAdmin [email protected]
ServerName banwagong.cn
Serveralias www.banwagong.cn
documentroot/var/www/banwagong.cn/public_html/
Errorlog/var/www/banwagong.cn/logs/error.log
Customlog/var/www/banwagong.cn/logs/access.log combined
</VirtualHost>
Similarly, if we need to add other sites, the same can be done to modify the file. The site configuration file is set up, so we're going to go right up to the folder that corresponds to the configuration file that is used to store Web site files and logs.
Mkdir-p/var/www/itbulu.com/public_html
Mkdir/var/www/itbulu.com/logs
Mkdir-p/var/www/banwagong.cn/public_html
Mkdir/var/www/banwagong.cn/logs
This is the 2 sites that I have shown above, and we need to create a corresponding folder of two sites to store the Web site files and log logs. If there are other sites, add them similarly. The folder should not be mistaken, because this must be consistent with the configuration file in order to bind the domain name directory.
A2ensite itbulu.com.conf
A2ensite banwagong.cn.conf
This is used to create the directory with the configuration file in effect, based on execution. Then you need to restart Apache.
Service Apache2 Reload
Restart before it can take effect. If we need to ban a site, then use A2dissite
Iv. installing the MySQL Database
Apt-get Install Mysql-server
Perform the installation of the MySQL database if you have encountered whether to continue entering Y enter to continue.
Installing the MySQL Database
Here you need to set the root user password, enter two times to continue the return.
After installation, if we need to adjust the database configuration file for the system's memory and configuration, the configuration file should be backed up before/etc/mysql/my.cnf. Here, our MySQL has been created.
We'd better throw in the mysql_secure_installation command to configure the database securely. Prompted to enter the root password, there are several security issues to solve, we look at the input Y or N to enter. This MySQL security configuration, Old Chiang back is shared separately.
Installation of the PHP environment
So far, the Web environment, the database has been installed, then we need to install PHP environment in order to execute PHP files.
Apt-get Install PHP5 php-pear
After installation, we also need to configure the php.ini file.
/etc/php5/apache2/php.ini
Modify the file to set the configuration
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/error.log
Register_globals = Off
Max_input_time = 30
At the same time, we also need to create log files and permission settings for the PHP directory.
mkdir/var/log/php
Chown www-data/var/log/php
If we need to get MySQL to support PHP, we still need to run
Apt-get Install Php5-mysql
After the installation is complete, perform service apache2 restart restart Apache.
Create a MySQL site database build station deployment
So far, our entire lamp environment has been installed, we now only need to create the corresponding site of the MySQL database users, and upload the corresponding directory site program in the past can install the site. Let's try it together!
A-Create A database
We can learn "Litespeed website Environment add virtual host build station binding domain name attached to install phpMyAdmin" article to the environment to install phpMyAdmin Management database, here Lao Jiang does not install, directly with the command operation to create the database and users, because with the compilation environment, You can install less and install fewer things.
Mysql-u root-p
Log in to the MySQL operator interface and enter the root password
Create Database Itbulu;
Grant all on itbulu.* to ' Itbulu_user ' identified by ' itbulu.com ';
Enter the command above, add the database (Itbulu) and User (Itbulu_user), and set the database password (itbulu.com). We modify it according to our own needs. Then enter quit to exit the database link interface.
This way, we can install the program. Lao Jiang is installed WordPress, all smooth without problems. And there's no problem with pseudo-static.
Linux Debian System Configuration lamp (Apache, MySQL, PHP) website Environment detailed