CentOS 6.5 Installation and Deployment Environment LNMP
Before installing the deployment, ensure that you have the necessary dependencies installed, including gcc
and gcc-c++
. To verify, use the following commands:
[Root @ zww ~] # cat /etc/redhat-release
CentOS release 6.5 (Final)
[Root @ zww ~] # uname -r
2.6.32-573.22.1.el6.x86_64
1. Install Nginx
To install Nginx, you need to install the dependent libraries first:
yum -y install zlib zlib-devel openssl openssl-devel pcre-devel
Download the source package from the official website:
wget http://nginx.org/download/nginx-1.9.10.tar.gz
Decompress the package:
tar xF nginx-1.9.10.tar.gz
Compile and install Nginx:
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_realip_module --with-pcre
make
make install
Error Handling
If you encounter an error during the compilation process, you may need to install the openssl-devel
package:
yum install -y openssl-devel
Adding Users and Groups
To run Nginx, you need to add a user and group:
useradd -M -s /sbin/nologin www
Modifying Nginx Configuration
Modify the Nginx configuration file:
vim /usr/local/nginx/conf/nginx.conf
Add the following configuration:
user www;
worker_processes 2;
error_log /usr/local/nginx/logs/error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
log_format '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" $http_user_agent $http_x_forwarded_for $request_length $status $request_time"';
log_format access '- $remote_addr - - $time_local "$request" $http_referer $http_user_agent $body_bytes_sent $http_x_forwarded_for $request_length $status $request_time"';
include /usr/local/nginx/conf/vhosts/*.conf;
}
Testing Nginx Configuration
Before starting Nginx, test the configuration:
/usr/local/nginx/sbin/nginx -t
Error Handling
If you encounter an error during the testing process, you may need to create a soft link:
ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1
Starting Nginx
Start Nginx:
/usr/local/nginx/sbin/nginx -s reload
2. Install MySQL
To install MySQL, you need to install the dependent libraries first:
yum -y install cmake bison ncurses-devel
Create a user and group for MySQL:
useradd -M -s /sbin/nologin mysql
chown -R mysql:mysql /usr/local/mysql
Download the source package from the official website:
wget https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.17.tar.gz
Decompress the package:
tar xf mysql-5.7.17.tar.gz
Compile and install MySQL:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DMYSQL_DATADIR=/usr/local/mysql/data
make
make install
Error Handling
If you encounter an error during the compilation process, you may need to download the Boost libraries:
wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
tar xf boost_1_59_0.tar.gz
Clear the cache and re-compile:
make clean
rm -rf CMakeCache.txt
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DMYSQL_DATADIR=/usr/local/mysql/data -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/opt/boost_1_59_0
make
make install
Initializing MySQL
Initialize the MySQL database:
/usr/local/mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
Starting MySQL
Start the MySQL service:
cp support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig mysql on
3. Install PHP
You can refer to another article about PHP installation: http://www.cnblogs.com/wenwei-blog/p/6261637.html
This article is involved with Tencent Cloud’s media-sharing plan, and you are welcome to join and share together.