基础环境安装
1 准备
1.1 gcc
gcc链接
(1)找到相应的版本目录进行下载
(2)运行
dpkg -i *.deb
(3)检测
gcc -v
1.2 g++
gcc链接
(1)找到相应的版本目录进行下载
(2)运行
dpkg -i *.deb
(3)检测
g++ -v
1.3 ngnix
1.3.1 编译ngnix
(1)安装包下载
Nginx安装包:http://nginx.org/en/download.html
openssl安装包:https://www.openssl.org/source/
pcre安装包:https://ftp.pcre.org/pub/pcre/
(2)首先要安装 PCRE
a.切换到相应的目录
[root@bogon src]# cd /usr/local/src/
b.解压安装包
[root@bogon src]# tar zxvf pcre-8.35.tar.gz
c.进入安装包
[root@bogon src]# cd pcre-8.35
d.编译安装
[root@bogon pcre-8.35]# ./configure
[root@bogon pcre-8.35]# make && make install
e.查看pcre版本
[root@bogon pcre-8.35]# pcre-config --version
(3) openssl安装
cd /home/src
tar -zxvf openssl.1.1.1.tar.gz
cd openssl.1.1.1a/
./config --prefix=/home/openssl
./config -t
make open
make install
(3)安装ngnix
a. 下载安装包并解压
[root@bogon src]# tar zxvf nginx-1.6.2.tar.gz
b. 进入安装包目录
[root@bogon src]# cd nginx-1.10.1
c. 编译安装
[root@iZgt88z6l1kvd7Z nginx-1.10.1]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-pcre=../pcre-8.39 --with-zlib=../zlib-1.2.8
(3)执行如下命令进行安装
[root@iZgt88z6l1kvd7Z nginx-1.10.1]# make
!!! 第一个报错
----分析原因
是将警告当成了错误处理,打开 nginx的安装目录 /objs/Makefile,去掉CFLAGS中的-Werror,再重新make
-Wall 表示打开gcc的所有警告
-Werror,它要求gcc将所有的警告当成错误进行处理
具体参考链接
[root@iZgt88z6l1kvd7Z nginx-1.10.1]# make install
(4)检查是否安装成功
[root@bogon nginx-1.6.2]# /usr/local/nginx/sbin/nginx -v
(5)测试
执行/usr/local/nginx/sbin/nginx
命令启动Nginx
/usr/local/nginx/sbin/nginx
Nginx 配置
创建 Nginx 运行使用的用户 www:
[root@bogon conf]# /usr/sbin/groupadd www
[root@bogon conf]# /usr/sbin/useradd -g www www
配置nginx.conf ,将/usr/local/nginx/conf/nginx.conf
替换为以下内容
[root@bogon conf]# cat /usr/local/webserver/nginx/conf/nginx.conf
user www www;
worker_processes 2; #设置值和CPU核心数一致
error_log /usr/local/webserver/nginx/logs/nginx_error.log crit; #日志位置和日志级别
pid /usr/local/webserver/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
events
{
use epoll;
worker_connections 65535;
}
http
{
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
#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;
#limit_zone crawler $binary_remote_addr 10m;
#下面是server虚拟主机的配置
server
{
listen 80;#监听端口
server_name localhost;#域名
index index.html index.htm index.php;
root /usr/local/nginx/html;#站点目录
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
{
expires 30d;
# access_log off;
}
location ~ .*\.(js|css)?$
{
expires 15d;
# access_log off;
}
access_log off;
}
}
检查配置文件nginx.conf的正确性命令:
[root@bogon conf]# /usr/local/nginx/sbin/nginx -t
启动 Nginx
Nginx 启动命令如下:
[root@bogon conf]# /usr/local/webserver/nginx/sbin/nginx
访问站点
从浏览器访问我们配置的站点ip:
Nginx 其他命令
以下包含了 Nginx 常用的几个命令:
/usr/local/webserver/nginx/sbin/nginx -s reload # 重新载入配置文件
/usr/local/webserver/nginx/sbin/nginx -s reopen # 重启 Nginx
/usr/local/webserver/nginx/sbin/nginx -s stop # 停止 Nginx
1.4 MySQL
vim /etc/apt/scource.list
#deb file:///data.copy/sql/ios juniper main
deb file:///data.copy/sql/ios pool main
apt-get insatll mysql*
1.5 常见问题
问题1 linux命令行中, 普通用户前面只显示一个$(即shell类型问题 sh/dash/bash)
参考链接
原因是创建的用户使用的shell是sh, 可以通过sudo vim /etc/passwd
中查看并修改
查看的结果是
alex:x:1000:1000::/home/alex:/bin/sh
将sh改成常用的bash即可.
问题2 外部网连接不了数据库
进入MySQL进行输入以下命令,进行设置外网连接权限。
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;
注意:youpassword修改成你mysql的密码。
然后刷新一下权限。
FLUSH PRIVILEGES
最后重启mysql就可以了。
systemctl restart mysql.service
问题3 修改MySQL中版本不同my.cnf的地方不同
vim /etc/mysql/mysql.conf.d/my.cnf
vim /etc/mysql/my.cnf