1.安装nginx:
安装依赖库:yum -y install zlib zlib-devel openssl openssl-devel pcre-devel
官网下载源码包 wget http://nginx.org/download/nginx-1.9.10.tar.gz
解压: tar xf nginx-1.9.10.tar.gz
编译安装,这里只安装到/usr/local/nginx-1.9,其它选项可在源码包目录执行./configure --help查看
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_realip_module --with-pcre && make && make install
出错:./configure: error: SSL modules require the OpenSSL library.
明显缺少openssl-devel 安装:yum install -y openssl-devel
添加运行用户和用户组:
useradd -M -s /sbin/nologin www
chgrp www www
chown www:www/usr/local/nginx
修改nginx配置文件:vim /usr/local/nginx/conf/nginx.conf
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;
#fastcgi_intercept_errors on;
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"‘;
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;
}
启动前先检查nginx配置是否有错:
[root@localhost nginx]# /usr/local/nginx/sbin/nginx -t
./sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
出错:解决方法:添加软链接:
ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1
前面在一般的linux上可以解决此问题.
注: 在有的操作系统上面,安装pcre后,安装的位置为/usr/local/lib/*pcre*
在redhat 64位机器之上有这样的情况.
在redhat 64位机器上, nginx可能读取的pcre文件为/lib64/libpcre.so.1文件.
所以64位机器添加软链接:
ln -s /usr/local/lib/libpcre.so.1 /lib64/
再次检测:
[root@localhost nginx]# ./sbin/nginx -t
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
启动nginx:
/usr/local/nginx/sbin/nginx -s reload
设置开机启动mysql:
echo /usr/local/nginx/sbin/nginx >> /etc/rc.d/rc.local
[root@zhiwenwei nginx]# netstat -tlunp|grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 26752/nginx
mysql版本5.5以上编译安装时需要用到软件cmake,cmake特性是独立于源码编译,编译工作可以在另外一个目录中而非源码目录中进行,好处是可以保证源码目录不受任何一次编译的影响。估计以后的版本也会采用这种方式,所以特地记录一下安装步骤及过程,以供参考
安装依赖软件库:yum -y install cmake bison ncurses-devel
解压mysql源码包并进入源码包目录进行编译安装:
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.17.tar.gz
解压进行编译安装:tar xf mysql-5.7.17.tar.gz
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
出现报错:CMake Error: Internal CMake error, TryCompile configure of cmake failed
解决:
查询没有安装gcc-c++
yum install -y gcc-c++
如果报错,请除缓存再使用以上命令
make clean
rm -rf CMakeCache.txt
创建用户和用户组与赋予数据存放目录权限
useradd -M -s /sbin/nologin mysql
groupadd mysql
chown -R mysql:mysql /usr/local/mysql
在启动MySQL服务时,会按照一定次序搜索my.cnf,先在/etc目录下找,找不到则会搜索"$basedir/my.cnf,这里复制配置文件到etc目录下并改名为my.conf
cp support-files/my-medium.cnf /etc/my.cnf
初始化数据库,执行前 需要chmod 755 scripts/mysql_install_db 赋给文件执行权限
cd /usr/local/mysql
chmod 755 scripts/mysql_install_db
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
添加服务,拷贝服务脚本到init.d目录,并设置开机启动
cp support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig mysql on
或者:echo /usr/local/mysql/support-files/mysql.server start >> /etc/rc.d/rc.local
启动数据库:
support-files/mysql.server start
查看 端口:
[root@localhost mysql]# netstat -launtp|grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 22131/mysqld
设置MySql数据库root用户的密码:
/usr/local/mysql/bin/mysqladmin -u root password 密码 (不能加单引号)
root登录数据库:/usr/local/mysql/bin/mysql -u root -p
错误:Starting MySQL.. ERROR! The server quit without updating PID file (/data/mysql_data/localhost.localdomain.pid).
解决:指定数据库保存路径有误
Starting MySQL.170103 17:13:31 mysqld_safe error: log-error set to ‘/data/log/mysql/error.log‘, however file don‘t exists. Create writable for user ‘mysql‘.
解决:
[root@iZ2zef0e6br88incakir9rZ mysql]# touch /data/log/mysql/error.log
[root@iZ2zef0e6br88incakir9rZ mysql]# chown msyql:mysql /data/log/mysql/error.log
设置mysql密码出错,
/usr/local/mysql/bin/mysqladmin: connect to server at ‘localhost‘ failed
error: ‘Access denied for user ‘root‘@‘localhost‘ (using password: NO)‘
参考地址:http://blog.163.com/canxingliushi@126/blog/static/34001923201243174022977/
3.php安装
我的另一篇文章有关于php的安装记录:
http://www.cnblogs.com/wenwei-blog/p/6261637.html