Build WEB + NFS + DNS in CentOS
This experiment uses two web, a php and mysql web1, 2 (172.16.31.30, 31.31) nfs 172.16.31.34
Php 172.16.31.32 mysql 172.16.31.32
Build
1. Set up web
First # mount-t nfs 172.16.31.34:/mydata mount nfs
The web version used in this compilation and the previous LAMP is the same.
1. Download the three packages of apr-1.5.0.tar.bz2 apr-util-1.5.3.tar.bz2 httpd-2.4.9.tar.bz2, extract them in turn,
# Tar xf apr-1.5.0.tar.bz2
# Cd apr-1.5.0
#./Configure -- prefix =/usr/local/apr
# Make & make install
2) Compile and install apr-util
# Tar xf apr-util-1.5.3.tar.bz2
# Cd apr-util-1.5.3
#./Configure -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr
# Make & make install
3) Compile and install httpd-2.4.9
# Tar xf httpd-2.4.9.tar.bz2
# Cd httpd-2.4.9
#. /Configure -- prefix =/usr/local/apache -- sysconfdir =/etc/httpd24 -- enable-so -- enable-ssl -- enable-cgi -- enable-rewrite -- with-zlib -- -pcre -- with-apr =/usr/local/apr -- with-apr-util =/usr/local/apr-util -- enable-modules = most -- enable-mpms-shared = all -- with-mpm = event
# Make & make install
Both of them perform this operation, and then modify the PATH environment variable.
Echo "export PATH =/usr/local/apach/bin: $ PATH">/etc/profile. d/httpd. sh
Make the PATH take effect in the current shell and start the service
Source/etc/profile. d/httpd. sh
Apachectl start
# Vim/etc/httpd. con
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so two modules to be enabled
LoadModule proxy_module modules/mod_proxy.so
ServerName www.caoshujia.com: 80
ProxyRequests off disable forward proxy
ProxyPassMatch ^/(. * \. php) $ fcgi: // 172.16.2.11: 9000/mydata/$1 any php file uses the fcgi protocol to proxy to the php server.
DocumentRoot "/mydata/" to change the root directory of the site to nfs
<Directory "/mydata/"> modify the control label for the root Directory of the site
DirectoryIndex index.html index. php add default request file
AddType application/x-httpd-php. php is added to the <IfModule mime_module> label to support php files.
AddType application/x-httpd-php-source. phps
# Httpd-t
# Apache restart
2 php compilation and Installation
1) install several packages in advance. If yes, no installation is required.
# Yum-y groupinstall "Desktop Platform Development"
# Yum-y install bzip2-devel
# Yum-y install libmcrypt-devel
2) Compile and install
# Tar xf php-5.4.26.tar.bz2
# Cd php-5.4.26
#. /Configure -- prefix =/usr/local/php -- with-mysql -- with-mysqli -- with-openssl -- enable-mbstring -- with-freetype-dir -- with-jpeg-dir -- with-png-dir -- with-zlib -- with-libxml-dir -- enable-xml -- enable-sockets -- enable-fpm -- with-bz2 -- with-config-file-path =/etc -- with-config-file-scan-dir =/etc/php. d -- with-mcrypt
# Make & make install
3) provide a configuration file for php:
# Cp php. ini-production/etc/php. ini
4) Configure php-fpm
Provide the SysV init script for php-fpm and add it to the service list:
# Cp sapi/fpm/init. d. php-fpm/etc/rc. d/init. d/php-fpm
# Chmod + x/etc/rc. d/init. d/php-fpm
# Chkconfig -- add php-fpm
# Chkconfig php-fpm on
Provide configuration files for php-fpm:
# Cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
Edit the configuration file of php-fpm:
# Vim/usr/local/php/etc/php-fpm.conf
Configure fpm related options for your required values and enable the pid file (the last line below ):
Pm. max_children = 50
Pm. start_servers = 5
Pm. min_spare_servers = 2
Pm. max_spare_servers = 8
Pid =/usr/local/php/var/run/php-fpm.pid
Specifies the location of the php PID file. This line must be written in the first line under [global], otherwise it will not take effect.
Next we can start php-fpm:
# Service php-fpm start
Detection listening port
# Netstat-tnlp | grep php-fpm
Tcp 0 0 127.0.0.1: 9000 0.0.0.0: * LISTEN 689/php-fpm
[Root @ localhost php-5.4.26] # service php start
[Root @ localhost php-5.4.26] # mkdir/mydata
[Root @ localhost php-5.4.26] # mount-t nfs 172.16.31.34:/mydata mount nfs to store php pages.
[Root @ localhost php-5.4.26] # chown-R nobody/mydata modify the owner of the webdata directory to nobody because nobody is the user running the php process.
3. mysql Configuration
Export to/usr/local
[Root @ localhost ~] # Tar xfmariadb-5.5.36-linux-x86_64.tar.gz-C/usr/local
2. File System for data storage preparation
A creates an sda3
[Root @ localhost ~] # Fdisk/dev/sda
Command (m for help): n
Commandaction
Eextended
Pprimary partition (1-4)
P
Partitionnumber (1-4): 3
Firstcylinder (7859-13054, default 7859 ):
Usingdefault value 7859
Lastcylinder, + cylinders or + size {K, M, G} (7859-13054, default 13054): + 20G
Command (m for help): t
Partitionnumber (1-4): 3
Hex code (type L to list codes): 8e (the file system is LVM)
Changedsystem type of partition 3 to 8e (Linux LVM)
Command (m for help): w
B. Reading data into the disk
[Root @ localhost ~] # Kpartx-af/dev/sda
Device-mapper: reload ioctl on sda1failed: Invalid argument
Create/reload failed on sda1
Device-mapper: reload ioctl on sda2failed: Invalid argument
Create/reload failed on sda2
Device-mapper: reload ioctl on sda3failed: Invalid argument
Create/reload failed on sda3
[Root @ localhost ~] # Partx-a/dev/sda
BLKPG: Device or resource busy
Error adding partition 1
BLKPG: Device or resource busy
Error adding partition 2
BLKPG: Device or resource busy
Error adding partition 3 (indicates that it has been read to the disk)
C. Create a logical volume and mount it to a specific directory. Set the directory to/mydata.
[Root @ localhost ~] # Pvcreate/dev/sda3
Physical volume "/dev/sda3" successfully created
[Root @ localhost ~] # Vgcreate myvg/dev/sda3
Volume group "myvg" successfully created
[Root @ localhost ~] # Lvcreate-L 10G-nmydata myvg
Logical volume "mydata" created
[Root @ localhost ~] # Mke2fs-t ext4-LMYDATA-B 4096-m 3/dev/myvg/mydata
And can be mounted on the boot device. Edit the fastab file.
/Dev/mapper/vg0-root/ext4 ults 1 1
UUID = 90ebd4cf-95c1-4338-b0dd-19b2b1cb943d/boot ext4 ults 1 2
/Dev/mapper/vg0-usr/usr ext4 defaults 1 2
/Dev/mapper/vg0-var/var ext4 defaults 1 2
/Dev/mapper/vg0-swap swap defaults 0 0
Tmpfs/dev/shm tmpfs defaults 0 0
Devpts/dev/pts devpts gid = 5, mode = 620 0 0
Sysfs/sys sysfs defaults 0 0
Proc/proc defaults 0 0
LABEL = MYDATA/mydata ext4 defaults 0 0
(BOOT mounting)
D. Create a user to run the process securely and create a link
[Root @ localhost ~] # Groupadd-r mysql
[Root @ localhost ~] # Useradd-g mysql-r mysql
[Root @ localhost ~] # Idmysql
Uid = 496 (mysql) gid = 493 (mysql) groups = 493 (mysql)
[Root @ localhost ~] # Chown-R mysql. mysql/mydata/data/
[Root @ localhost ~] # Ll-a/mydata/data/
Total 8
Drwxr-xr-x 2 mysql mysql4096 Aug 11 20:15.
First go to the/usr/local directory
[Root @ localhost local] # ln-sv mariadb-5.5.36-linux-x86_64 mysql
Lrwxrwxrwx1 root 27 Aug 11 20: 18 mysql-> mariadb-5.5.36-linux-x86_64
E. Provide the primary configuration file for mysql.
Cd/usr/local/mysql/
Mkdir/etc/mysql creates a directory, because there is a my. cnf under/etc
Cpsupport-files/my-large.cnf/etc/mysql/my. cnf
Vim/etc/mysql/my. cnf
Port = 3306
Socket =/tmp/mysql. sock
Skip-external-locking
Key_buffer_size = 256 M
Max_allowed_packet = 1 M
Table_open_cache = 256
Sort_buffer_size = 1 M
Read_buffer_size = 1 M
Read_rnd_buffer_size = 4 M
Myisam_sort_buffer_size = 64 M
Thread_cache_size = 8
Query_cache_size = 16 M
# Try number of CPU's * 2 for thread_concurrency
Thread_concurrency = 8
Datadir =/mydata/data (specify the storage location of mysql data Files)
Start Initialization
[Root @ localhostmysql] # scripts/mysql_install_db -- user = mysql -- datadir =/mydata/data/
(This must be in the mysql directory. If you want to initialize it in scripts, an error will be reported)
F. Provide the sysv service script for mysql.
[Root @ localhostmysql] # cp support-files/mysql. server/etc/rc. d/init. d/mysqld
Then add it to the service list.
[Root @ localhost mysql] # chkconfig -- addmysqld
[Root @ localhost mysql] # chkconfig -- list mysqld
Mysqld 0: off1: off2: on3: on4: on5: on6: off
Start the service
Root @ localhost mysql] # service mysqld start
Starting MySQL... [OK]
[Root @ localhost mysql] # ss-tnl
StateRecv-Q Send-QLocal Address: PortPeer Address: Port
LISTEN0 128 *: 52971 *:*
LISTEN0 128: 50732 :::*
LISTEN0 128: 111 :::*
LISTEN0 128 *: 111 *:*
LISTEN0 128: 22 :::*
LISTEN0 128 *: 22 *:*
LISTEN0 128 127.0.0.1: 631 *:*
LISTEN0 128: 1: 631 :::*
LISTEN0 100: 1: 25 :::*
LISTEN0 100 127.0.0.1: 25 *:*
LISTEN0 128 127.0.0.1: 6010 *:*
LISTEN0 128: 1: 6010 :::*
LISTEN 050 *: 3306 *: * (Port 3306 is enabled)
Set permissions
[Root @ localhostmysql] # chmod + x/etc/rc. d/init. d/mysqld
G. Edit the environment variable.
[Root @ localhost ~] # Vim/etc/profile. d/mysql. sh
ExportPATH =/usr/local/mysql/bin: $ PATH
H. Export the header file and Library File
Ln-sv/usr/local/mysql/include/usr/include/mysql
[Root @ localhost ~] # Vim/etc/ld. so. conf. d/mysql. conf (new)
/Usr/local/mysql/lib
Reload the system
[Root @ localhost ~] # Ldconfig-v | grep mysql
/Usr/local/mysql/lib:
Libmysqld. so.18-> libmysqld. so.18
Libmysqlclient. so.18-> libmysqlclient_r.so.18.0.0
/Usr/lib64/mysql:
Libmysqlclient. so.16-> libmysqlclient. so.16.0.0
Libmysqlclient_r.so.16-> libmysqlclient_r.so.16.0.0
[Root @ localhost ~] # Mysql
MariaDB [(none)]> use mysql
MariaDB [mysql]> grant all on discuz. * to disadmin@172.16.31.32 identified by 'root'; Authorize Database User disadmin to log on to host 172.16.31.32 with the password root
Configuration complete.
This article is from the "Linux" blog, please be sure to keep this source http://clarence.blog.51cto.com/8161461/1541302