Last update time: 2012.3.21
========================
Step 1: Apache installation (updated to 2.2.22)
========================
Download Go to http://www.apache.org to find a new one yourself
http://httpd.apache.org/
There are many mirror points in China such as “Everyone” and “163”
http://labs.renren.com/
Pay attention to find httpd, because there are many projects under apache, among which httpd is the web server
http://labs.renren.com/ English documentation: http://httpd.apache.org/docs/2.2/
Chinese documentation: http://www.php100.com/manual/apache2/index.html
————————————————–
#wget http://labs.renren.com/apache-mirror/httpd/httpd-2.2.22.tar.gz
#tar zxvf httpd-2.2.22.tar.gz
#cd ./httpd-2.2.22
#./configure –prefix=/usr/local/apache2/ –enable-proxy
–enable-ssl –enable-cgi –enable-rewrite –enable-so
–enable-module=so
#make
#make install
Explanation: If make fails, then configure fails. For example, if you lack ssl components, you can remove
–enable-ssl
———————————————–
If “No recognized SSL/TLS toolkit
detected” error
#yum -y install openssl openssl-devel
————————
If Make: command not found
Check if make is not installed
# rpm -qa|grep make
If there is no information, it means that make is not installed
#yum install make
——————-
Start manually
# /usr/local/apache2/bin/apachectl start
reboot
# /usr/local/apache2/bin/apachectl restart
If an error is reported:
Could not reliably determine the server’s fully
qualified domain name, using 127.0.1.1 for ServerName
Need to modify /usr/local/apache2/conf/httpd.conf in
#serverName www.example.com:80
Change this location to:
serverName localhost:80
————————–
Startup of YUM automatic installation
#service httpd restart
Entering this will prompt an error httpd is not recognized service
Please see another introduction of this blog
————————-
This means the installation was successful.
Enter in the browser yourself: http://localhost/
This means success!
——————————————
Firewall Configuration
Note that if you want to access the web page of the virtual machine on a local machine such as xp, if it is centos6 you need to modify the firewall to start port 80
/etc/sysconfig
[root@centos6 ~]# vim
/etc/sysconfig/iptables
Add the following line to open port 80 in the firewall:
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j
ACCEPT
restart firewall
#/etc/init.d/iptables restart
View CentOS firewall information: /etc/init.d/iptables status
Close the CentOS firewall service: /etc/init.d/iptables stop
————————
Add auto-start service at startup
Edit rc.local file
#vi /etc/rc.d/rc.local
Add the following startup command
/usr/sbin/apachectl start
/etc/rc.d/init.d/mysqld start
/etc/rc.d/init.d/smb start
/usr/local/subversion/bin/svnserve -d
Note: My path is the path obtained by yum to install these services. When filling in, you should follow your own installation path. If you can’t find it, you can use the whereis command, mainly to find apachectl
, mysqld, smb these three startup files.
——————————————
Add permission and file format conversion (otherwise apache will report no permission to execute the file)
#chmod +x file
#dos2unix documents
—————————————-
ab test
#ab -n 1000 -c 10 http://localhost/
——————————————
Uninstall apache
If it is source code installation
#rm -rf your apache installation path
Same for other
============================
httpd enable virtual host
#Include conf/extra/httpd-vhosts.conf
httpd-vhosts.conf
ServerAdmin [email protected]
DocumentRoot “/www/”
#Reject all requests
# Deny from all
#Whether to display the list
# Options Indexes FollowSymLinks
# Whether to enable rewrite
# AllowOverride all
============================
Installed by YUM, uninstall it like this: #yum remove httpd
Otherwise use
#rpm-d5
functions
from OpenSSL library. You can either disable the module by
using
–without-http-cache option, or install the OpenSSL library into
the system,
or build the OpenSSL library statically from the source with nginx
by using
–with-http_ssl_module –with-openssl= options.
Solution:
yum -y install openssl openssl-devel
Summary:
yum -y install pcre-devel openssl openssl-devel
./configure –prefix=/usr/local/nginx
make
make install
Start nginx
#/usr/local/nginx/sbin/nginx -c
/usr/local/nginx/conf/nginx.conf
Successful installation page
Stop operation
The stop operation is by sending a signal to the nginx process (for what is a signal, please refer to the linux document
chapter) to carry out
Step 1: Query the nginx main process number
ps -ef | grep nginx
Find the master process in the process list, and its number is the master process number.
Step 2: Send the signal
Stop Nginx gracefully:
kill -QUIT main process ID
Quick stop Nginx:
kill -TERM main process number
Force stop Nginx:
pkill -9 nginx
in addition,
If the pid file storage path is configured in nginx.conf, the file stores the Nginx main process number, and if not specified, it is placed in the nginx logs directory. With pid text
file, we don’t need to query the main process number of Nginx first, but directly send a signal to Nginx, the command is as follows:
kill – signal type ‘/usr/nginx/logs/nginx.pid’
Graceful restart
If you change the configuration, you need to restart Nginx. Do you need to close Nginx first and then open it? No, you can send a signal to Nginx to restart gracefully.
Graceful restart command:
kill -HUP enter name or process number file path
or use
/usr/nginx/sbin/nginx -s reload
Note that after modifying the configuration file, it is best to check whether the modified configuration file is correct.
To avoid Nginx errors affecting the stable operation of the server after restarting. The command to judge whether the Nginx configuration is correct is as follows:
nginx -t -c /usr/nginx/conf/nginx.conf
or
/usr/nginx/sbin/nginx -t
Smooth upgrade
If the server is running Nginx to upgrade, add or delete modules, we need
It is necessary to stop the server and make corresponding modifications, so that the server will stop serving for a period of time, and Nginx can perform various upgrade actions without affecting the server operation without stopping.
Step 1:
If you upgrade the Nginx program, first replace the old program file with the new program, and compile and install the new program directly into the Nginx installation directory.
Step 2: Execute the command
kill -USR2 The main process number or process file name of the old version of the program
At this time, the old Nginx main process will rename its own process file to .oldbin, and then execute the new version
Nginx. The old and new Nginx will run together to process requests together.
At this time, to gradually stop the old version of Nginx, enter the command:
kill -WINCH old moderator process ID
Gradually, the old work process will exit as the task is completed, and the work process of the new version of Nginx will gradually replace the old work process.
At this point, we can decide to use the new version or revert to the old version.
Start new/old worker processes without reloading configuration
kill -HUP old/new moderator process ID
Gracefully close old/new processes
kill -QUIT old/new main process ID
If an error is reported at this time, indicating that there are still processes that have not ended, use the following command to close the old/new working process first, and then close the main process ID:
kill -TERM old/new worker process number
In this way, if you want to restore to the old version, you only need the above few steps
The steps are to operate the process number of the new moderator. If you want to use the new version, just operate the process number of the old moderator in the above steps.
The above are some basic operations of Nginx. I hope that Nginx will have a better way to handle these operations in the future.
It’s better to be an Nginx command instead of sending a system signal to the Nginx process.