编译安装最新稳定版LNMP平台

2023年 7月 15日 28.4k 0

php-5.3.27.tar.gz Nginx-1.8.0 Mariadb-5.5.45

Mariadb-5.5.45编译安装1,安装开发组件

yum groupinstall "Development Tools" "Server Platform Development" –y

2,安装cmake

yum -y install cmake

3,创建mysql组

groupadd -r -g 306 mysql
useradd -r -g 306 -u 306 mysql

4,下载mariadb包

wget http://mirrors.opencas.cn/mariadb/mariadb-5.5.45/source/mariadb-5.5.45.tar.gz

5,解压

tar xf mariadb-5.5.44.tar.gz
cd mariadb-5.5.44

6,使用cmake编译

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb-5.5.44 
-DMYSQL_DATADIR=/mydata/data 
-DSYSCONFDIR=/etc  
-DWITH_INNOBASE_STORAGE_ENGINE=1 
-DWITH_ARCHIVE_STORAGE_ENGINE=1 
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 
-DWITH_READLINE=1 
-DWITH_SSL=system 
-DWITH_ZLIB=system 
-DWITH_LIBWRAP=0 
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock 
-DDEFAULT_CHARSET=utf8 
-DDEFAULT_COLLATION=utf8_general_ci
make
make install

7,修改属组属主

cd /usr/local/Nmariadb-5.5.44/
chown -R root.mysql ./*

8,建立软连接,方便使用

ln -sv /usr/local/Nmariadb-5.5.44 mysql

9,创建数据库目录

# mkdir /mydata/data -pv
mkdir: created directory `/mydata'
mkdir: created directory `/mydata/data'

10,修改属组属主

chown mysql.mysql /mydata/data/
cd /usr/local/mysql/

11,初始化数据库,指定用户和安装路径

scripts/mysql_install_db --user=mysql --datadir=/mydata/data

12,创建配置文件目录

mkdir /etc/mysql
cp support-files/my-large.cnf /etc/mysql/my.cnf

13,修改配置文件

# vim /etc/mysql/my.cnf
[mysqld]
datadir=/mydata/data
innodb_file_per_table = NO
skip_name_resolve = NO

14,复制启动脚本,修改权限,并且开机启动

cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld star

数据库初始化,和修改密码

/usr/local/Nmariadb-5.5.44/bin/mysql_secure_installation
/usr/local/Nmariadb-5.5.44/bin/mysql -uroot -p

Nginx-1.8.0编译安装

1,下载nginx-1.8.0包

wget http://nginx.org/download/nginx-1.8.0.tar.gz
tar xf nginx-1.8.0.tar.gz

2,创建软连接ln -sv nginx-1.8.0 nginxcd nginx3,开始编译

./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
make
make install

4,创建配置文件配置一个启动脚本 /etc/init.d/nginx

5,保存后,更改权限

chmod 755 /etc/init.d/nginx
chkconfig --add nginx

如果想开机启动,请执行:# chkconfig nginx on

6,更改nginx配置首先把原来的配置文件清空: /usr/local/nginx/conf/nginx.conf

7,创建nginx.conf文件 vim /usr/local/nginx/conf/nginx.conf 写入如下内容:

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 ; 
 '$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; 
   } 

} 

} 

8,检查配置文件

# /usr/local/nginx/sbin/nginx  ;-t 
# service nginx start 
# ps aux |grep nginx 

php-fpm install

1,安装依赖包

useradd -s /sbin/nologin php-fpm
rpm -ivh "http://www.aminglinux.com/bbs/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm
yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel libcurl-devel libcurl libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt-devel libmcrypt libtool-ltdl-devel</pre>
 
wget http://am1.php.net/distributions/php-5.3.27.tar.gz 
tar xf php-5.3.27.tar.gz 

2,开始编译

# ./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=/usr/local/mysql  
--with-mysql-sock=/tmp/mysql.sock  
--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  
--enable-zend-multibyte  
--disable-ipv6  
--with-pear  
--with-curl  
--with-openssl 
 
make 
make install 

3,创建配置文件

cp php.ini-production /usr/local/php/etc/php.ini

vim /usr/local/php/etc/php-fpm.conf 加入以下内容

[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 
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 

4,配置检查

# /usr/local/php/sbin/php-fpm -t 
[08-Oct-2015 22:31:33] NOTICE: configuration file /usr/local/php/etc/php- 
 
fpm.conf test is successful 

5,复制启动脚本

#cp /usr/local/src/php-5.3.27/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm 
# chmod 755 /etc/init.d/php-fpm ; 
# chkconfig php-fpm on 
# service php-fpm start 

最好进行测试

1,创建一个php文件

echo "test php ok"; > /usr/local/nginx/html/2.php
# vim /usr/local/nginx/html/3.php 
<?php 
 ;phpinfo(); 
?>; 

2,重启nginx service nginx restart3,访问测试 curl 192.168.40.133/2.phptest php ok

浏览器:输入192.168.40.133/3.php

相关文章

LeaferJS 1.0 重磅发布:强悍的前端 Canvas 渲染引擎
10分钟搞定支持通配符的永久有效免费HTTPS证书
300 多个 Microsoft Excel 快捷方式
一步步配置基于kubeadmin的kubevip高可用
istio全链路传递cookie和header灰度
REST Web 服务版本控制

发布评论