Linux Server configuration (full Web site environment configuration)

Source: Internet
Author: User
Tags fpm

The last time I used a Web environment with Aliyun, I always couldn't find the document when I was working, and I put it back here:

The total directory is/root/build_site (remember not to delete)
1 below the Software directory/root/build_site
has three directories
Apache_site contains a script file that creates a site, manages a site, and deletes a site.
mysql_db inside, set up a database, manage the database, delete the database script files.
Conf contains a number of Web site configuration information files.
2) Site management:
Note: You need to enter the Apache_site directory, the site name is using the FTP user name, so the FTP user name can not be repeated.
1, create the site: Execute create_apache_site.sh script, enter the corresponding information (FTP username, ftp password, domain name, url, PHP version, etc.), we can create a site.
2, delete the site, execute the delete_apache_site.sh script, enter the appropriate FTP user name, you can delete the site.
3, switch version, execute change_php_version.sh script, enter the FTP name to modify, and you want to switch to the PHP version, you can.
4, modify the Site Directory: Execute change_apache_home.sh script, enter the site to modify the FTP name, and the site's new directory, it can be.
5, binding domain Name: Execute bind_apache_domain.sh script, enter the site FTP name to bind domain name, and need to bind domain name, note, domain name binding can not repeat.
6, the binding domain name: Execute unbind_apache_domain.sh script, enter to be able to bind the site FTP name, and need to bind domain name, on it.
7, List all sites: Execute the list_all_site.sh script to list all the sites you have established.
8, listing site information: Execute list_site_info.sh < site name > script, you can list the information of the site, you can find the site information you need.

3) database Management
We need to go into the mysql_db directory and execute the corresponding script.
1, create MySQL users and databases: Execute the create_database.sh script, enter the corresponding information, you can create a MySQL user and a corresponding MySQL database.
2, delete MySQL user and database: Execute delete_database.sh script, enter corresponding information, can delete MySQL user and corresponding script.
3, modify the MySQL user password: Execute change_passwd.sh script, enter the corresponding information, you can modify the MySQL user password.
4, modify the MySQL remote address: Execute the change_host.sh script, enter the corresponding information, you can modify the MySQL user's remote address.
4) Service restart
MySQL Services: Service MySQL (Start|stop|restart)
Apache Services: Service httpd (Start|stop|restart)
VSFTPD Services: Service VSFTPFD (Start|stop|restart)
PHP-FPM Service: An independent PHP-FPM service for each site. Here take the WWWFTP site for example:
Service PHP-FPM (Start|stop|restart) wwwftp
============================================

1, Software Installation and configuration file path
The A,apache installation directory is:
/usr/local/apache2
b,php installation path is
/usr/local/php5.2
/usr/local/php5.3
/usr/local/php5.4
/usr/local/php5.5
C,mysql installation path is
/usr/local/mysql
D:VSFTPD using Yum installation, the configuration file is
/etc/vsftpd/vsftpd.conf

2, service start, stop, restart operation
A,apache Service
Service httpd Start|stop|restart
B,mysql Service
Service MySQL Start|stop|restart
C,PHP-FPM Service
Each site is an independent PHP-FPM service. Requires you to enter the name of the site, and the corresponding FTP name, such as: wwwftp
Service PHP-FPM Start|stop|restart wwwftp

3, create the site
For example: FTP user name is: wwwftp, directory is/home/wwwftp, domain name is: www.wwwftp.com,php PHP-FPM Port 9001
1), create an FTP user
Add user, execute command: useradd-g ftp-d/home/wwwftp-s/sbin/nologin wwwftp-m
Directory owner: Execute command: Chown wwwftp.ftp/home/wwwftp-r
Set password, execute command: passwd wwwftp (password input two times)
Add the last line to the/etc/vsftpd/chroot_list, which reads: WWWFTP
2), Apache Create site
Create a file under the/usr/local/apache2/conf/vhosts directory wwwftp.conf
<virtualhost *:80>
Documentroot/home/wwwftp
ServerName www.wwwftp.com
Serveralias www.wwwftp.com
DirectoryIndex index.htm index.html index.shtml index.php
Customlog "|/usr/local/apache2/bin/rotatelogs-l/usr/local/apache2/logs/wwwftp_access%y%m%d.log 10M" common
Proxypassmatch ^/(. *.php) $ fcgi://127.0.0.1:9001/home/wwwftp/$1
<Directory/home/wwwftp>
Options FollowSymLinks Includes
AllowOverride All
Order Allow,deny
Allow from all
</Directory>
</virtualHost>
3), Establish PHP-FPM service:
1, add a file under the/USR/LOCAL/PHP-FPM directory name is wwwftp
The file content is the site's PHP path; (Note that there are no line breaks, etc.)
such as:/usr/local/apache2/php5.2
And then/usr/local/php-fpm/tmp (if not exist on the Create, permission 777, the owner and the group are FTP) to establish a directory named Wwwftp. The permission is set to 777, the owner and the genus Group are wwwftp and FTP.
2, establish PHP-FPM service,
Enter the ETC directory corresponding to the PHP version directory. For example: PHP version 5.2, for/usr/local/apache2/php5.2
Copy php-fpm.conf is wwwftp.conf, the following modifies the configuration of the file.
When the version is 5.2
A, modify the PID file directory, in the file node configuration–>section–>value[@name = "Pid_file"] node content is:
/usr/local/php5.2/logs/wwwftp.pid
b, modify the startup user and start user group
The contents of the node configuration–>workers–>section–>value[@name = "User" node are: wwwftp
configuration–>workers–>section–>value[@name = "Group" node in node content is: FTP
C, modify the PHP-FPM service port:
In node configuration–>workers–>section–>value[@name = "listen_address"] Node
Content is: 127.0.0.1:9001
D, set the qualification directory:
Add three nodes under the node configuration–>workers–>section–>value[@name = "Php_defines"] node.
<value name= "Open_basedir" >/home/wwwftp:/usr/local/php-fpm/tmp</value>
<value name= "Upload_tmp_dir" >/usr/local/php-fpm/tmp</value>
<value name= "Session.save_path" >/usr/local/php-fpm/tmp</value>
When the version is 5.3,5.4,5.5
A, modify the PID file directory, find the node value of global PID = row. (If you have to remove the front part of the good)
PID =/usr/local/php5.4/var/run/wwwftp.pid
b, modify the startup user and start user group
Under the WWW section, modify the User,group value
user = Wwwftp
Group = FTP
C, modify the PHP-FPM service port:
Under the WWW section, modify the Listen section value
Listen = 127.0.0.1:9001
D, set the qualification directory:
Add three lines to the end of the file
Php_admin_value[open_basedir] =/home/wwwftp:/usr/local/php-fpm/tmp
Php_admin_value[session.save_path] =/usr/local/php-fpm/tmp
Php_admin_value[upload_tmp_dir] =/usr/local/php-fpm/tmp
Can start the PHP-FPM service
Service PHP-FPM Start wwwftp
Restart the Apache service
Service httpd Restart

4, bind, unbind domain name, to site name wwwftp, domain name www.wwwftp.com,
In the/usr/local/apache2/conf/vhosts/wwwftp.conf file
Add a row in <virtualhost *:80>, or delete a row
Serveralias www.wwwftp.com
5, modify the site path, the site is wwwftp, the new path for/HOME/WWWFTP1
Modify the FTP Web site Directory
usermod-d/HOME/WWWFTP1 wwwftp
Modify Apache Site Directory
In the/usr/local/apache2/conf/vhosts/wwwftp.conf file
Modify: The following three places path.
Documentroot/home/wwwftp1
Proxypassmatch ^/(. *.php) $ fcgi://127.0.0.1:9001/home/wwwftp1/$1
<Directory/home/wwwftp1>
Modify
The wwwftp.conf file below the ETC directory in the corresponding version directory of the website
Directories in Open_basedir (added directory restrictions when creating sites)
Be aware of; Restart Service
6, switch the PHP version of the site: for example: Switch to 5.5
Close the previous PHP-FPM service
Service PHP-FPM Stop Wwwftp
Under the old PHP version directory below the ETC directory, delete the corresponding PHP-FPM configuration wwwftp.conf
Create a PHP-FPM service below the new PHP version directory (see Create PHP-FPM Service for site)
Note: Do not forget to modify the/USR/LOCAL/PHP-FPM directory wwwftp files to the corresponding PHP version of the directory below. Otherwise, restarting the service will fail.
7, delete the site
A, remove the FTP user
Userdel wwwftp
Note: should stop php-fpm wwwftp service first, otherwise will prompt the user to have logged in
Delete the Wwwftp user's line in the/etc/vsftpd/chroot_list file
b, delete the site
Deletes the/usr/local/apache2/conf/vhosts/wwwftp.conf file.
C, delete the PHP-FPM service:
Stop Service
Delete the service profiles in etc in the corresponding PHP version directory, wwwftp.conf
Deletes the wwwftp file in the/USR/LOCAL/PHP-FPM.
Remove the service from the/etc/rc.d/rc.loacl file from startup.

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.