System: CentOS 7 x86_64
NGINX: nginx-1.7.12
Database: mariadb-10.0.13
PHP: php-5.5.23
First, do some preparatory work, first replace centos7 firewall into iptables, can be found in the following links
centos7 changed iptables firewall
After the modified iptables iptables can clean the inside of the filtering rules, and then close the selinux service. Do not forget to remember to install gcc gcc-c ++ wget net-tools and so on, oh.
First install mariadb
It should take a long time to compile the database, so I was already here to download precompiled binary packages, the download version mariadb-10.0.13-linux-glibc_214-x86_64.tar.gz
1. Download the binary package to the next / usr / local / src directory:
[Root @ centos74 ~] # cd / usr / local / src /
[Root @ centos74 src] # wget http://ftp.osuosl.org/pub/mariadb/mariadb-10.0.13/bintar-quantal-amd64/mariadb-10.0.13-linux-glibc_214-x86_64.tar.gz
2, unpack the archive to / usr / local directory:
[Root @ centos74 src] # tar zvxf mariadb-10.0.13-linux-glibc_214-x86_64.tar.gz -C / usr / local /
3. Create mariadb data initialization directory / data / mysql:
[Root @ centos74 src] # mkdir -p / data / mysql
4, add the system user mysql, prohibit the landing system, while the mariadb initialization data directory belongs to the owner and group were changed to mysql:
[Root @ centos74 src] # useradd -r -s / sbin / nologin mysql; chown -R mysql.mysql / data / mysql /
5, rename the extract from the mariadb catalog:
[Root @ centos74 src] # mv /usr/local/mariadb-10.0.13-linux-x86_64/ / usr / local / mysql
6, enter the directory renaming, the initialization mariadb:
[Root @ centos74 src] # cd / usr / local / mysql /
[Root @ centos74 mysql] # ./scripts/mysql_install_db –datadir = / data / mysql –user = mysql
Installing MariaDB / MySQL system tables in ‘/ data / mysql’ …
140906 2:03:19 [Note] InnoDB: Using mutexes to ref count buffer pool pages
140906 2:03:19 [Note] InnoDB: The InnoDB memory heap is disabled
140906 2:03:19 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
140906 2:03:19 [Note] InnoDB: Compressed tables use zlib 1.2.3
140906 2:03:19 [Note] InnoDB: Using Linux native AIO
140906 2:03:19 [Note] InnoDB: Using CPU crc32 instructions
140906 2:03:19 [Note] InnoDB: Initializing buffer pool, size = 128.0M
………………………………………….. ………………….
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Support MariaDB development by buying support / new features from
SkySQL Ab. You can contact us about this at sales@skysql.com.
Alternatively consider joining our community based development effort:
http://mariadb.com/kb/en/contributing-to-the-mariadb-project/
Error: WARNING: The host ‘test4′ could not be looked up with resolveip.
Workaround: vim / etc / hosts in the last line add 192.168.1.242 test4
Error: ./ bin / mysqld: error while loading shared libraries: libaio.so.1: can not open shared object file: No such file or directory
Solution: yum -y install libaio-devel libaio
7. Copy the configuration file to the / etc directory covering before my.cnf:
[Root @ centos74 mysql] # cp support-files / my-large.cnf /etc/my.cnf
cp: whether to overwrite “/etc/my.cnf”? y
8, copy mysql startup script file to the /etc/init.d directory and rename it to mysqld:
[Root @ centos74 mysql] # cp support-files / mysql.server /etc/init.d/mysqld
At the same privileges to modify the startup script to 755:
[Root @ centos74 mysql] # chmod 755! $
chmod 755 /etc/init.d/mysqld
9, edit the startup script to define datadir path:
[Root @ centos74 mysql] # vim /etc/init.d/mysqld
Define data storage path:
datadir = / data / mysql
10, will mariadb comes commands in $ PATH
[Root @ localhost ~] # PATH = $ PATH: /etc/init.d/# currently active on the failure to restart the shell
[Root @ localhost ~] # echo “export PATH = $ PATH: /etc/init.d/” >> / etc / profile
[Root @ localhost ~] # echo “export PATH = $ PATH: / usr / local / mysql / bin /” >> / etc / profile
[Root @ localhost ~] # source! $
11, start mariadb:
[Root @ centos74 mysql] # /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
The second step, to start the installation php
Here first statement about the php installation for Nginx and apache for php installation is different, because the php Nginx is a way to combine the nginx fastcgi, nginx agent can be understood as the php fastcgi, and apache is the php as their own modules to call. The same, php official Download: http://www.php.net/downloads.php
Download php
[Rot @ localhost src] # cd / usr / local / src
[Root @ localhost src] # wget http://am1.php.net/distributions/php-5.5.23.tar.gz
Unzip php
[Root @ localhost src] # tar zxf php-5.5.23.tar.gz
Create relevant account
[Root @ localhost src] # useradd -s / sbin / nologin php-fpm
Configuring the Compile Options
[Root @ localhost src] # cd php-5.5.23
[Root @ localhost src] # yum -y install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel
[Root @ localhost php-5.5.23] # ./configure –prefix = / usr / local / php –with-config-file-path = / usr / local / php / etc –enable-fpm –with -fpm-user = php-fpm –with-fpm-group = php-fpm –with-mysql = mysqlnd –with-pdo-mysql = mysqlnd –with-mysqli = mysqlnd –with-libxml-dir – -with-gd –with-jpeg-dir –with-png-dir –with-freetype-dir –with-iconv-dir –with-zlib-dir –with-mcrypt –enable-soap – -enable-gd-native-ttf –enable-ftp –enable-mbstring –enable-exif –disable-ipv6 –with-pear –with-curl –enable-bcmath –enable-mbstring – enable-sockets –with-gd –with-libxml-dir = / usr / local –with-gettext
Error: configure: error:. Xml2-config not found Please check your libxml2 installation.
Solution: yum -y install libxml2-devel
Error: configure: error: Please reinstall the libcurl distribution -easy.h should be in <curl-dir> / include / curl /
Solution: yum -y install libcurl-devel
Error: configure: error: jpeglib.h not found.
Solution: yum -y install libjpeg-turbo-devel
Error: configure: error: png.h not found.
Workaround: um -y install libpng-devel
Error: configure: error: freetype-config not found.
Workaround: configure: error:. Mcrypt.h not found Please reinstall libmcrypt.
Error: configure: error:. Mcrypt.h not found Please reinstall libmcrypt.
Solution: yum -y install libmcrypt-devel
Install php
[Root @ localhost php-5.3.27] # make && make install
Each of the above steps, if not fully implemented correctly, the next step is not possible, the use of echo $? To see whether the result is “0”, and if not, is not performed correctly.
Modify the configuration file
cp php.ini-production /usr/local/php/etc/php.ini
vim /usr/local/php/etc/php-fpm.conf
The following contents are written to the file:
[Global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
[Www]
listen = /tmp/php-fcgi.sock
user = php-fpm
group = php-fpm
listen.owner = nobody
listen.group = nobody
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
After saving the configuration file, verify the configuration is the correct way to:
/ Usr / local / php / sbin / php-fpm -t
If words such as “test is successful”, explained the configuration is no problem.
Start php-fpm
cp /usr/local/src/php-5.5.23/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
service php-fpm start
If you want it to boot, execute:
chkconfig php-fpm on
Detection is started:
ps aux | grep php-fpm
See if there is a number of processes (probably over 20).
Install nginx
Download nginx
cd / usr / local / src /
wget http://nginx.org/download/nginx-1.7.12.tar.gz
Unzip nginx
tar zxvf nginx-1.7.12.tar.gz
Configuring the Compile Options
cd nginx-1.7.12
./configure \
–prefix = / usr / local / nginx \
–with-http_realip_module \
–with-http_sub_module \
–with-http_gzip_static_module \
–with-http_stub_status_module \
–with-pcre
Error: ./ configure: error: the HTTP rewrite module requires the PCRE library.
Solution: yum -y install pcre-devel
Error: ./ configure: error: the HTTP gzip module requires the zlib library.
Solution: yum install -y zlib-devel
Compile nginx
make
Install nginx
make install
Nginx started to write the script, and added to the system services
vim /etc/init.d/nginx
Write the following:
#! / Bin / bash
# Chkconfig: – 30 21
# Description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
NGINX_SBIN = “/ usr / local / nginx / sbin / nginx”
NGINX_CONF = “/ usr / local / nginx / conf / nginx.conf”
NGINX_PID = “/ usr / local / nginx / logs / nginx.pid”
RETVAL = 0
prog = “Nginx”
start () {
echo -n $ “Starting $ prog:”
mkdir -p / dev / shm / nginx_temp
daemon $ NGINX_SBIN -c $ NGINX_CONF
RETVAL = $?
echo
return $ RETVAL
}
stop () {
echo -n $ “Stopping $ prog:”
killproc -p $ NGINX_PID $ NGINX_SBIN -TERM
rm -rf / dev / shm / nginx_temp
RETVAL = $?
echo
return $ RETVAL
}
reload () {
echo -n $ “Reloading $ prog:”
killproc -p $ NGINX_PID $ NGINX_SBIN -HUP
RETVAL = $?
echo
return $ RETVAL
}
restart () {
stop
start
}
configtest () {
$ NGINX_SBIN -c $ NGINX_CONF -t
return 0
}
case “$ 1″ in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $ “Usage: $ 0 {start | stop | reload | restart | configtest}”
RETVAL = 1
esac
exit $ RETVAL
After saving changes 僿:
chmod 755 /etc/init.d/nginx
chkconfig –add nginx
If you want to boot, execute:
chkconfig nginx on
Nginx configuration change
First, the original configuration files emptied:
> /usr/local/nginx/conf/nginx.conf
“>” This symbol is redirected meaning, alone with it, you can put a text document quickly emptied.
vim /usr/local/nginx/conf/nginx.conf
Write the following:
user nobody nobody;
worker_processes 2;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 6000;
}
http
{
include mime.types;
default_type application / octet-stream;
server_names_hash_bucket_size 3526;
server_names_hash_max_size 4096;
log_format combined_realip ‘$ remote_addr $ http_x_forwarded_for [$ time_local]’
‘$ Host “$ request_uri” $ status’
‘”$ Http_referer” “$ http_user_agent”‘;
sendfile on;
tcp_nopush on;
keepalive_timeout 30;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size 256;
client_header_buffer_size 1k;
large_client_header_buffers 8 4k;
request_pool_size 4k;
output_buffers 4 32k;
postpone_output 1460;
client_max_body_size 10m;
client_body_buffer_size 256k;
client_body_temp_path / usr / local / nginx / client_body_temp;
proxy_temp_path / usr / local / nginx / proxy_temp;
fastcgi_temp_path / usr / local / nginx / fastcgi_temp;
fastcgi_intercept_errors on;
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 8k;
gzip_comp_level 5;
gzip_http_version 1.1;
gzip_types text / plain application / x-javascript text / css text / htm application / xml;
server
{
listen 80;
server_name localhost;
index index.html index.htm index.php;
root / usr / local / nginx / html;
location ~ \ .php $ {
include fastcgi_params;
fastcgi_pass unix: /tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME / usr / local / nginx / html $ fastcgi_script_name;
}
}
}
After you save the configuration, verify what the configuration file for errors exist:
/ Usr / local / nginx / sbin / nginx -t
If the display reads as follows, is configured correctly, or need to modify the configuration file according to the error message:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Start nginx:
service nginx start
If you can not start, see “/usr/local/nginx/logs/error.log” file, check whether nginx start:
ps aux | grep nginx
To see if there are processes.
Test whether to resolve php file
Create a test file:
vim /usr/local/nginx/html/2.php
It reads as follows:
<? Php echo phpinfo ();?>
Test:
[Root @ localhost nginx] # curl localhost / 2.php
Or use the browser to open http: //YourServerIPAddress/2.php
Important: If you can not resolve, check the log was found not connect php, my php version 5.5.23, a relatively new version, you need to add in php / etc / php-fpm.conf file
listen.owner = nobody
listen.group = nobody
These two lines, and then restart the service will be able to use the php
The reason is that this file does not have read permission /tmp/php-fcgi.sock
So far, the latest version of LNMP source compiler environment installed.
The post installation environment under LNMP – CentOS7 appeared first on VULTR Coupons.