From the virtual host to the vps/server over, for ordinary non-technical webmaster users may have some difficulties, wheat suggested that if we can in the virtual host environment to meet the needs of the site, or with a virtual host is better. Unless we really need to or want to go from the virtual host to the vps/server, after all, the latter's degree of freedom is relatively large, some projects require characteristics of the environment support.
In this article, the wheat will share our common lamp environment deployment, I prefer to use the method of compiling scripts, because the compilation script can be more than the Web panel and a key package exposed by the site, of course, for novice users, the Web panel and a large number of user-proven one-key package is also better, such as LNMP, LLSMP, is still a good one-button package. In this article, wheat will be based on the Ubuntu environment to deploy the LAMP environment, lamp=linux+apache+mysql+php.
First, the preparatory work
Install the Ubuntu 14.04 Environment version of our Linux environment, this version is a more mature release version.
Apt-get Update
Apt-get Upgrade
Update and upgrade the current latest version package.
Second, install the Apache Web environment
Apt-get Install Apache2
Execute the above command to install the Apache Web environment.
Third, edit the Apache configuration file
/etc/apache2/apache2.conf
Edit the apache2.conf file for the path above. Modify the "<ifmodule mpm_prefork_module>" section as follows to optimize Apache.
<ifmodule mpm_prefork_module>
Startservers 2
Minspareservers 6
Maxspareservers 12
MaxClients 30
Maxrequestsperchild 3000
</IfModule>
This is based on our VPS configuration to adjust, my VPS is 1GB of memory.
IV. Create a virtual host
/etc/apache2/sites-available/
In this directory above, if we do not have this directory we create this directory, then we need to set up the configuration file that we need to establish the site host. Conf. For example, I need to add yd631.com site here.
/etc/apache2/sites-available/yd631.com.conf
We need to add the yd631.com.conf file in the above directory, and use the domain name to mark the table good memory. Do not recognize errors when there are many sites.
<virtualhost *:80>
ServerAdmin [email protected]
ServerName yd631.com
Serveralias www.yd631.com
documentroot/var/www/html/yd631.com/public_html/
Errorlog/var/www/html/yd631.com/logs/error.log
Customlog/var/www/html/yd631.com/logs/access.log combined
<Directory/path/to/public/website/>
Require all granted
</Directory>
</VirtualHost>
Add the above configuration script to the file and adjust the name according to our site. Similarly, if there are other sites, we continue to add the. conf configuration file for the other domain names in the sites-available directory.
Create a Web site file and log store directory
Mkdir-p/var/www/html/yd631.com/public_html
Mkdir/var/www/html/yd631.com/logs
We need to create a directory, a file to put the website program, a log. This should be consistent with the configuration above, so that the website can be opened correctly.
Six, start the site
A2ensite yd631.com.conf
If there are other sites, the same starts.
VII, start Apache
Service Apache2 Reload
Eighth, install MySQL database and configuration
Apt-get Install Mysql-server
As prompted, we need to enter the MySQL database root password two times. If we need to optimize and set the security of the database, execute the mysql_secure_installation command, and then follow the prompts to remove some default database table options. Or the root password is more complex to set up.
Ninth, create MySQL database and table
Because we need to build stations, most of them are MySQL databases, so we need to create tables and users.
Create database;
Grant all on database. * to ' database user ' identified by ' database password ';
Based on the above hints, we modify it to our own needs, such as what I created here:
Create Database yd631;
Grant all on yd631.* to ' Yd631_user ' identified by ' yd631.com ';
The wheat is just a demonstration and we need to set it up a little more complex. Enter quit after the creation is complete.
Tenth, install PHP
Apt-get Install PHP5 php-pear
11th, configure the php.ini file
/etc/php5/apache2/php.ini
edit this file.
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
We found the corresponding parameter to modify, I this is the configuration with 1GB memory scheme.
12th, create and set up PHP log directory
mkdir/var/log/php
Chown www-data/var/log/php
13th, the implementation of MySQL and PHP compatible with the effective
Apt-get Install Php5-mysql
Finally, we restart the Apache environment Service Apache2 Reload so that we can upload the Web file program in the directory created above, and then enter the database parameter information that has been created, based on the site's build-in deployment prompts. In this way, our lamp environment is deployed, is it very simple? Much more convenient than a key pack, and save resources. For FTP, wheat recommends using the SFTP tool, which does not require a separate installation of the FTP environment because it is unsafe.
The original address of this article:http://www.yd631.com/ubuntu-lamp/reprint note.
Linux Ubuntu 14.04 installation lamp (apache+mysql+php) Site environment