For novices, a big problem is where to download even the source code package , And then there are software dependencies
If the network card will not be configured , Please read my other articles
This is the basic source code package
http://pan.baidu.com/s/1kTxbN5X
And then there's the beginning
yum -y install gcc gcc-c++ autoconf nss_ldap libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel openldap-clients openldap-servers pcre pcre-devel make wget vim cmake gd gd-devel libevent libevent-devel zip unzip libtool
yum Basic rpm package After installation close selinux And the firewall service iptables stop chkconfig iptables off vi /etc/selinux/config hold SELINUX=enforcing It is amended as follows disabled centos7 yes iptables By firewalld Replaced the systemctl stop firewalld Remember after the change reboot Restart or just service iptables restart Source storage path :/usr/local/src yum install lrzsz cd /usr/local/src rz You can choose more than one This virtual machine is more convenient , If it's a real machine , After installing the system, you can directly wget To src Just in the file tar -zxvf Source package install httpd First installation apr tar -zxvf apr-1.5.1.tar.gz cd apr-1.5.1 ./configure --prefix=/usr/local/apr If you don't know if you're right , Please go straight ahead , If you are compiling httpd If you have problems, you can delete the folder , Compile again , Don't worry make && make install cd .. tar -zxvf apr-util-1.5.4.tar.gz cd cd apr-util-1.5.4 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make && make install tar -zxvf httpd-2.4.10.tar.gz cd httpd-2.4.10 ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewrite --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-most-shared=most --enable-mpms-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
Configuration file in /etc/httpd/httpd.conf make && make install cd /usr/local/apache bin/apachectl start AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message If the following problems arise vi /etc/httpd/httpd.conf First turn on the pid The document points to run below , This has nothing to do with the problem stay serveRoot="/usr/local/apche" apache Add... To the root directory of . If USR There's not a lot of directory space , OK, directory guide HOME Under the table of contents PidFile "/var/run/httpd.pid" Configure it look for ServerName and ServerAdmin Change to ServerAdmin localhost ServerName localhost:80 ESC :wq Save and exit netstat -tnlp kill 80 It's broken PID cd /usr/local/apache bin/apachectl start curl 127.0.0.1 It works!、 Input... On another machine IP, Just OK 了 Site root /usr/local/apache/htdocs below index.html It's the home page file Well httpd chkconfig mysqld on 1、 take apachectl File copy to /etc/rc.d/init.d in , And then in /etc/rc.d/rc5.d/ Add a link below . The order is as follows : cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd // If there are other versions of Apache There is , It can also be covered directly ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc5.d/S85httpd // Building links (85 The meaning of ) here Apache It will start automatically . 2、 function chkconfig --list, Found no linux In the list of services httpd, adopt chkconfig --add httpd To add , But the tip :httpd Service not supported chkconfig. You need to edit /etc/rc.d/init.d/httpd, Add the following comment information : Any position can be # chkconfig: 345 85 15 # description: Activates/Deactivates Apache Web Server first line 3 The meanings of the two numerical parameters are respectively : Which? Linux Level needs to be activated httpd(3,4,5); Start sequence number (85); Turn off the serial number (15). Execute... After saving :chkconfig --add httpd, Successful addition . stay rc3.d、rc4.d、rc5.d In the path S85httpd Link file for , In other run level paths K61httpd Link file for . 3、 function chkconfig --list httpd Next is mysql There's a big problem , Big files mysql The source code package is unusable rz command , Here's a tip You usually use ftp Tools Besides landing ftp outside , It can still be used root User login options sftp over ssh This can be used root The user login , Big files can be uploaded , No need to install samba And configuration cp /root/mysql-5.6.21-x86_64.tar.gz /usr/local/ tar -zxvf mysql-5.6.21-x86_64.tar.gz Create soft link Create a user portfolio user id groupadd -r -g 306 mysql
useradd -g 306 -r -u 306 mysql id mysql chown -R mysql.mysql /usr/local/mysql/* Change genus group mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
mkdir -p /usr/local/mysql
tar zxvf mysql-5.5.28.tar.gz
cd mysql-5.5.28

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci

 Compile options according to your own needs
make
make install
cd /usr/local/mysql
cp ./support-files/my-medium.cnf /etc/my.cnf scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql/data --user=mysql
chown -R mysql.mysql /data/mysql/data cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
chkconfig --list mysqld vi /etc/rc.d/init.d/mysqld basedir=/usr/local/mysql/
datadir=/data/mysql/data/
add
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile Well mysql Order to join source /etc/profile Start command ln -s /usr/local/mysql/lib/mysql /usr/local/lib64/mysql
ln -s /usr/local/mysql/include/mysql /usr/local/include/mysql service mysqld start mysql -uroot land The default password is empty
mysql> SET PASSWORD = PASSWORD('123456'); Set up root password
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.16.%' IDENTIFIED BY 'password' WITH GRANT OPTION;
Start Remote Access Please note when initializing
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql/data --user=mysql This place must put this 2 A basic address , If you need more initialization options, refer to the following options Otherwise, it will appear when the service is started
mysql The server quit without updating PID file
You start mysql It's a problem when you're in the middle of the world , There are many solutions online , But you need to be more specific data The error information in the directory
For example, you didn't specify
--basedir=/usr/local/mysql This option
localhost.localdomain.err This will prompt
Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
Because the default permission table is not in /usr/local/mysql Inside

There's another problem /etc/my.ini It's also the configuration file that ensures that the entire mysqld In the section basedir=/usr/local/mysql/
datadir=/data/mysql/data
this 2 It is and /usr/local/mysql/my.ini It's all the same inside
Here is the path to the error log , If the above problems still can't be solved . Please check the log

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

 Please refer to
Pay attention here , Many articles don't point out , You download mysql The source code package is made up of 2 in , One is decompression , direct 
scripts/mysql_install_db That bag of , Yes 200M about , Now? 5.6 It's almost 400M. Generally you don't see cmake If you want to compile , That's the bag
If your source code package is only 20M-30M, Your bag needs cmake compile , You first yum install cmake
Here's a demonstration of cmake Of Next is php Let's start with a couple of compilations php The dependency library for the compilation options for
libmcrypt
mhash
mcrypt
libiconv
The above source code package has cd /usr/local/src
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
/sbin/ldconfig
cd libltdl

./configure --enable-ltdl-install
make && make install
cd ../../
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make && make install
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
cd ../
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make && make install
cd ../
tar zxvf pcre-8.31.tar.gz
cd pcre-8.31
./configure –-prefix=/usr/local/pcre
make
make install
cd ../
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure –-prefix=/usr/local/libiconv This place is designated , Because of the compilation php You can't find this package when you search make && make install
cd ../
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make && make install
cd ../ Next is the point , Because there are many differences according to the requirements of your architecture , such as lamp Just use the default mode , If it is lnmp Use it if you want fastcgi
lanmp We also need to use fastcgi Pattern
Explain why you use lanmp Handle php hand apache Handle , Static files to nginx Handle , because nginx The ability to handle resource box concurrency is stronger ,nginx There are many advantages to being a reverse proxy
For example, the cluster rotation configuration is simple , Strong concurrency , At present, the best concurrency is not nginx It is lvs, But on the whole nginx The degree and ability of easy use are not inferior to that of LVS, If you really need big concurrent , Actually lanmp How to build
no way , I'll discuss it in detail later
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --with-ttf --with-xmlrpc --with-openssl --with-zlib --with-freetype-dir --with-gd --with-jpeg-dir --with-png-dir --with-iconv=/usr/local/libiconv --enable-short-tags --enable-sockets --enable-zend-multibyte --enable-soap --enable-mbstring --enable-static --enable-gd-native-ttf --with-curl --with-mcrypt This is the default working mode ,lanmp I recommend this ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts --with-curl --enable-fpm --enable-soap --with-iconv=/usr/local/libiconv  --with-mysqli=/usr/local/mysql/bin/mysql_config  --with-freetype-dir=/usr/local/freetype  --with-gd If it doesn't install gd perhaps libiconv Please refer to my other articles This is a fpm Pattern build lanmp necessary vi /etc/httpd/httpd.conf increase 2 One thing can be used
AddType application/x-httpd-php .php .php3 .htm .phtml .php4 AddType application/x-httpd-php-source .phps Support php File support Increasing support DirectoryIndex index.php index.html This is a global configuration. It is enabled by default index.php preservation , restart apache service httpd stop service httpd start test vi /usr/local/apache/htdocs/index.php <?php $con = mysql_connect('localhost','root',''); if($con){ echo "OK": }else{ echo "fuck"; } phpinfo(); ?> Shows OK and phpinfo Information about OK,php and mysql Open the php As a apache Module execution of , No need to start as a service Here's how to configure the virtual machine vi /etc/httpd/httpd.conf
Comment out
# DocumentRoot "/usr/local/apache/htdocs/"
Turn on the virtual machine host include "/etc/httpd/extra/httpd-vhost.conf" OK vi /etc/httpd/extra/httpd-vhosts.conf The default is on mod_log_config modular , Don't worry, just go by yourself vi /etc/httpd/httpd.conf Check Configuring virtual hosts has 2 A default configuration mkdir /www/{a.com,b.com} -pv
mkdir /var/log/httpd/ <VirtualHost *:80>
ServerName www.a.com
DocumentRoot "/www/a.com"
ErrorLog "/var/log/httpd/a.com-error_log"
CustomLog "/var/log/httpd/a.com-access_log" common
</VirtualHost> <VirtualHost *:80>
ServerName www.b.com
DocumentRoot "/www/b.com"
ErrorLog "/var/log/httpd/b.com-error_log"
CustomLog "/var/log/httpd/b.com-access_log" common
</VirtualHost> combined More rich log files In their own local hosts File mapping 192.168.0.206 www.a.com 192.168.0.206 www.b.com service httpd stop service httpd start Open it and you'll find You don't have permission to access / on this server Because from httpd2.4 rise , Each virtual host needs active configuration directory to access vi /etc/httpd/extra/httpd-vhosts.conf

<VirtualHost *:80>
ServerName www.a.com
DocumentRoot "/www/a.com"
<Directory "/www/b.com">
Options none
AllowOverride none
Require all granted
</Directory>
ErrorLog "/var/log/httpd/a.com-error_log"
CustomLog "/var/log/httpd/a.com-access_log" common
</VirtualHost>

<VirtualHost *:80>
ServerName www.b.com
DocumentRoot "/www/b.com"
<Directory "/www/b.com">
Options none
AllowOverride none
Require all granted
</Directory>
ErrorLog "/var/log/httpd/b.com-error_log"
CustomLog "/var/log/httpd/b.com-access_log" common
</VirtualHost> service httpd stop serveice httpd start OK. 了 install phpmyadmin cd /etc/local/src/ tar -zxvf phpMyAdmin-4.2.11-all-languages.tar.gz -C /www/a.com That's all right. , If you can't log in with an empty password mysqladmin -uroot password 'com' If prompted to use mysqli, Just go and compile it again php. Or extend other modules Here is nginx
groupadd nginx
useradd -r -g nginx nginx -s /sbin/nologin
id nginx tar -zxvf nginx-1.6.2
cd nginx-1.6.2
./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ make && make install vi /etc/init.d/nginxd #!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid # Source function library.
. /etc/rc.d/init.d/functions # Source networking configuration.
. /etc/sysconfig/network # Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0 nginx="/usr/sbin/nginx"
prog=$(basename $nginx) NGINX_CONF_FILE="/etc/nginx/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx make_dirs() {
# make required directories
user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
} start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
} stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
} restart() {
configtest || return $?
stop
sleep 1
start
} reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
} force_reload() {
restart
} configtest() {
$nginx -t -c $NGINX_CONF_FILE
} rh_status() {
status $prog
} rh_status_q() {
rh_status >/dev/null 2>&1
} case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac

groupadd -r -g 306 mysql


useradd -g 306 -r -u 306 mysql

chmod +x /etc/init.d/nginxd
chkconfig --add nginxd ## Let's enter the boot option
chkconfig nginxd on # Let it start automatically
chkconfig --list # Check whether the service is joined or not
service nginxd start # restart now nginx service
remember apache nginx The default ports are 80
yum -y install openssl-devel zlib-devel pcre-devel
yum groupinstall "Developement Tools" "Development Libraries" -yt
vi /etc/nginx/nginx.conf server {
listen 81; Port changed to 81 service nginxd start OK 192.168.0.206:81 You can see the welcome page This is php Of fpm Configuration of working mode lnmp To configure cd /usr/local/src/php-5.6/
cp php.ini-production /usr/local/php/etc/php.ini
cp php.ini-production /etc/php.ini
This is the default php.ini The path of cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf vi /usr/local/php/etc/php-fpm.conf
Enable the following options :
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 2
pm.max_spare_servers = 8
pid = run/php-fpm.pid
Modify according to the server configuration Just remove the comments in front of the blue part , Modified to complete , Try to start /usr/local/php/sbin/php-fpm Use... After starting netstat -tnlp see If there is a port as shown in the figure Test indicates normal start If you need to start the machine, it will start automatically Can be added to /etc/rc.d/rc.local in vim /etc/rc.d/rc.local chkconfig --add fpm chkconfig fpm on
chmod +x /etc/init.d/php-fpm vi /etc/nginx/fastcgi_params Replace it with fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200; vi /etc/nginx/nginx.conf First of all, will #user nobody;
Change it to user nginx; And then I found
Get rid of # location ~ \.php$ {
root /www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
} server nginxd start
stay nginx Under the root directory of Test code
vi index.php
<?php phpinfo();
?>
192.168.0.206/index.php You can see Server API The working mode of fpm This means lnmp The architecture has fpm Working mode working
But when nginx As a reverse proxy The configuration file used is still apache Of According to the php The working mode of the company is still php Has been working in modular mode
Server API Apache 2.0 Handler because php The documents were given to httpd Handle , According to the php Information or apache Of
Please pay attention at this time
Yours php-fpm Is it still running If appear
iconv.c:1350: undefined reference to `libiconv' error

tar -zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/libiconv
make
make install

--with-iconv=/usr/local/libiconv

php When you compile, you specify the path OK 了

./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts --with-curl --enable-fpm --enable-soap --with-iconv=/usr/local/libiconv  --with-mysqli=/usr/local/mysql/bin/mysql_config  --with-freetype-dir=/usr/local/freetype  --with-gd
This fpm Compile options for working mode Finally, a few more words ,php5.4 in the future pdo Itself is no longer php The branches of have merged The last is nginx Reverse proxy apache, stay nginx In the configuration file of , Well apache The authentication port of is changed to 8080
Definition server paragraph
server It can define location
Static file processing to nginx php Deal with it apache vi /etc/nginx/nginx.conf

location ~* \.(js|css|jpg|jpeg|gif|png)$ {
access_log off;
expires 1d;
}
location ~ ^(.+\.php)(.*)$ {
proxy_redirect off;
proxy_set_header HOST $host;
proxy_set_header SERVER_ADDR $server_addr;
proxy_set_header SERVER_PORT $server_port;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header REMOTE_PORT $remote_port;
proxy_pass http://127.0.0.1:8080;
}

service nginxd stop

service nginxd start

see phpinfo Information ,Server API Apache 2.0 Handler Now it's the proof of this mode ,php hand apache Processed

 Give Way nginx Reverse proxy apache When , Need to open apche Virtual machines and nginx virtual machine , stay nginx I also need to configure it on the Internet. For example, I'm in apache The monitor is 81, Then the reverse proxy is set to http://127.0.0.1:81
First configuration nginx virtual machine
vi /etc/nginx/nginx.conf

user nginx nginx; # Users and user groups
worker_processes 2;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;

events
{
use epoll;epoll Model
worker_connections 65535; maximum connection
}

http {

include mime.types;
default_type application/octet-stream;

# The main definition httpd

include /usr/local/nginx/vhost.conf;# The imported virtual machine configuration file can also be configured as ×.conf That is to read all the configuration files , You can also choose your own location

}

vi /usr/local/nginx/vhost.conf
fastcgi_param PATH_INFO $request_uri;
Realization path_info Support
 In this test apache Monitor is 81 Please note that 

server{
listen 80;
server_name www.b.com;
index index.php index.html;
root /www/b.com;


location ~ \.php$ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
"/usr/local/nginx/vhost.conf" 37L, 941C written
[root@localhost ~]# vi /usr/local/nginx/vhost.conf


server{
listen 80;
server_name www.a.com;
root /www/a.com;
index index.php index.html;

location ~ \.php$ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:81; }

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 1s;
}
location ~ .*\.(js|css)?$ {
expires 1s;
}

}

server{
listen 80;
server_name www.b.com;
index index.php index.html;
root /www/b.com;

location ~ \.php$ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:81; }

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 1s;
}
location ~ .*\.(js|css)?$ {
expires 1s;
}

}

a If you need to configure global nginx Yes, please 
/etc/nginx/nginx.conf Configuration, such as log format ,gzip, Various agent configurations
All over the bottom is apache The configuration file of is the same as the one above , It's just 

<VirtualHost *:81>
ServerName www.a.com
DocumentRoot "/www/a.com"
<Directory "/www/b.com">
Options none
AllowOverride none
Require all granted
</Directory>
ErrorLog "/var/log/httpd/a.com-error_log"
CustomLog "/var/log/httpd/a.com-access_log" common
</VirtualHost>




<VirtualHost *:81>
ServerName www.b.com
DocumentRoot "/www/b.com"
<Directory "/www/b.com">
Options none
AllowOverride none
Require all granted
</Directory>
ErrorLog "/var/log/httpd/b.com-error_log"
CustomLog "/var/log/httpd/b.com-access_log" common
</VirtualHost>




Compile and install manually lanmp centos6.5 64 More related articles of the bit

  1. Compilation and installation mysql(Ubuntu10 64 position )

    Choose a better compiler and better compiler options , This application improves performance 10-30%, This is very important for most programs Mysql Compilation of , Different versions have different configurations Refer to the configuration form of the old version This form mainly uses config ...

  2. CentOS6.0(64 position ) install Apache+PHP+Mysql course , install Magento( solve DOM,Mcrypt,GD problem ) Full tutorial

    CentOS6.0(64 position ) install Apache+PHP+Mysql course , install Magento( solve DOM,Mcrypt,GD problem ) Full tutorial 0   Posted by : Little black  On : 2012 year 9 ...

  3. Centos6.7 64 Bit installation configuration kvm virtualization

    First , Need our cpu Support virtualization , Some machines support it, but not in bios Turn on , This needs to be turned on in advance . 1. Dell R710 install centos6.7 64 position ,Dell R710 Press after power on F2 Get into BIOS,Pro ...

  4. centos vmware centos6.6 64 position kvm Virtualization installation configuration Lesson 42

    centos vmware centos6.6 64 position kvm Virtualization installation configuration      Lesson 42 The first half of the class The second half of the class f

  5. CentOS6.3(64 position ) Lower installation Oracle11gR2(64) The server

    Installation environment Linux The server :Centos6.3 64 position Oracle The server :Oracle11gR2 64 position System requirements 1.Linux install Oracle System requirements System requirements explain Memory Must be higher than 1G In Physics ...

  6. Linux in CentOS6.5 64 position Installation under system docker step

    CentOS6.5 64 position     (docker Currently only supported 64 position ) The kernel must be in 3.10 And above 1. uname -r  View kernel version 2. Upgrade the kernel to 3.10 edition ( belt aufs modular )    cd /etc ...

  7. CentOS Compile and install manually gcc

    Recently tried fedora.ubuntu.mint.debian.opensuse Many other kinds linux Distribution version , And CentOS After comparison, I still feel that I used it before CentOS Familiar with , More used . Now? CentOS The latest version of is ...

  8. LNAMP Server environment construction ( Compile and install manually )

    LNAMP Server environment construction ( Compile and install manually ) One . Prepare the material One Alibaba cloud host , operating system CentOS 6.5 64 position lnamp.zip package ( Contains all the software needed to build the environment ) http://123.56.144. ...

  9. Compile and install manually tmux

    tmux I don't want to say much about the benefits of , In a word, it's the artifact of multi screen management . Usually, we can install the system to tmux, But sometimes , The installation may not be the version we need , Or there's no software source with it tmux. At this time, you need to manually compile and install ...

Random recommendation

  1. MyBatis Of resultMap

    1. Let's learn MyBatis when , You may encounter the situation that the attribute of entity class is different from that of database field Such as : database    ------   Entity class stuname  ---->  name namely : In the database stuname Field pair ...

  2. @property sentence

    @property The form of the statement is : @property ( attributes ) type name; type and name It's clear at a glance ,attributes Describes how to write an accessor . One .assign ...

  3. log4j Some of the problems

    today , I'm learning log4j I found a little bit of a problem when I was at work , About level The problem of . log4j.rootLogger=error, console, file , fileerror log4j.logger.com ...

  4. ARM Processor registers ,ARM And Thumb state ,7 Run in mode 【 turn 】

    from :http://blog.chinaunix.net/uid-28458801-id-3494646.html ARM There are a total of 7 Kind of : USR  Pattern     Normal user mode , Normal procedure ...

  5. Linux/RedHat Compilation and installation GNU gcc 4.9.0 (g++)

    This is about compiling and installing ,yum/apt-get The installation method is relatively simple , Don't elaborate ! 1. Download the source code package :gcc.gnu.org 2. decompression : tar -xjvf gcc-4.9.0.tar.bz2 3. Download the required ...

  6. centos 6.4 install firefox The use of flashplayer plug-in unit

    1.centos After the installation, it didn't flash-plugin, Go to the official website to download and tell me that it has been installed , But firefox I really can't let it out flash video . 2.google once , Go to the official website to download tar.gz Format file . hold lib ...

  7. 2016021903 - Download, install and use Memory Analyzer

    Memory Analyzer What does it do ? analysis java Program analysis of memory leaks . 1. download Memory Analyzer Memory Analyzer Download address :http://www.eclipse. ...

  8. The most comprehensive Swift Social application text input optimization summary

    In most applications , There is a need for input , Facing so many users , They have different ideas , The input text content is also strange , Facing different inputs , How do we optimize the input experience ? This article will summarize Swift Social application text input optimization techniques . AD: One . Input phase ...

  9. python And Find the latest files in a directory

    Record this method , It feels very useful !>.< import os def find_newest_file(path_file): lists = os.listdir(path_file) li ...

  10. error C2039: 'SetWindowTextA' : is not a member of 'CString'

    m_OpenPath.SetWindowText(strPath);   The reason for the error : When you associate a control with a variable m_OpenPath when , Variable type selection error   terms of settlement :