从零开始在阿里云上搭建服务器(CentOS 6.8系统)

本文详细介绍了如何在阿里云的CentOS 6.8系统上从零开始搭建服务器,包括创建新用户、安装图形界面、配置LNMP环境(Nginx、MySQL和PHP)。在安装过程中,提到了内存不足导致的问题以及解决方法,通过设置交换分区顺利完成了MySQL的编译。最后,成功创建了PHP测试页面,验证了LNMP环境的正常运行。
摘要由CSDN通过智能技术生成

一.登陆后创建一个新用户(例如 mirror)

useradd mirror

passwd mirror

输入两次密码

二.安装图形界面:

yum groupinstall "Desktop" "X Window System" "Chinese Support" "Internet Browser" "Fonts"

vi /etc/inittab

将3改成5

reboot

用mirror登陆

三.配置LNMP环境

1.基础设置:

1)关闭SELINUX

修改配置文件,重启服务后永久生效。

# sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config

命令行设置立即生效。

# setenforce 0

2)安全组设置

在ECS安全组放行需访问的端口和访问白名单,下面的示例表示允许所有IP访问服务器的80端口。您可以根据实际情况放行允许访问的客户端IP。

图片1


2.安装nginx

1)添加运行nginx服务进程的用户

 
 
 
  1. # groupadd -r nginx
  2. # useradd -r -g nginx nginx

2)下载源码包解压编译。

 
 
 
  1. # wget http://nginx.org/download/nginx-1.10.2.tar.gz
  2. # tar xvf nginx-1.10.2.tar.gz -C /usr/local/src
  3. # yum groupinstall "Development tools"
  4. # yum -y install gcc wget gcc-c++ automake autoconf libtool libxml2-devel libxslt-devel perl-devel perl-ExtUtils-Embed pcre-devel openssl-devel
  5. # cd /usr/local/src/nginx-1.10.2
  6. # ./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --user=nginx --group=nginx --with-pcre --with-http_v2_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-threads --with-stream --with-stream_ssl_module
  7. # make && make install
  8. # mkdir -pv /var/tmp/nginx/client

3)添加SysV启动脚本。

 
 
 
  1. # vim /etc/init.d/nginx
  2. #!/bin/sh
  3. #
  4. # nginx - this script starts and stops the nginx daemon
  5. #
  6. # chkconfig: - 85 15
  7. # description: Nginx is an HTTP(S) server, HTTP(S) reverse \
  8. # proxy and IMAP/POP3 proxy server
  9. # processname: nginx
  10. # config: /etc/nginx/nginx.conf
  11. # config: /etc/sysconfig/nginx
  12. # pidfile: /var/run/nginx.pid
  13. # Source function library.
  14. . /etc/rc.d/init.d/functions
  15. # Source networking configuration.
  16. . /etc/sysconfig/network
  17. # Check that networking is up.
  18. [ "$NETWORKING" = "no" ] && exit 0
  19. nginx="/usr/sbin/nginx"
  20. prog=$(basename $nginx)
  21. NGINX_CONF_FILE="/etc/nginx/nginx.conf"
  22. [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
  23. lockfile=/var/lock/subsys/nginx
  24. start()
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值