前几天砸蛋中奖了,心情不错,在此分享下我的阿里云服务器配置细节
我也是菜鸟,如果有错误欢迎大家来指正。
首先用 putty 登录服务器 什么?不会登录! 我建议你还是别用Centos | RedHat 了
登录后首先要更改密码了,默认密码又长又不好记!
框起来的都是要执行的命令,下面就不单独说了
passwd root
根据提示输入新的密码,密码改完后我们来创建一下基本的目录
先简单把要创建的目录写出来
/web
/web/www 网站数据
/web/soft 常用程序安装目录
/web/data Mysql数据库和程序配置文件
/web/backup 网站备份 程序备份
/web/backup/soft 程序安装包备份
/web/backup/www 网站备份
/webbackup/code 网站源码包(dz、pw等,我平时要建的网站比较多,方便安装)
/webbackup/mysql 数据库备份
好了,基本就这么多 我们现在一口气把它们建立好
cd /
mkdir /web
mkdir /web/www
mkdir /web/soft
mkdir /web/data
mkdir /web/backup
mkdir /web/backup/soft
mkdir /web/backup/www
mkdir /web/backup/code
mkdir /web/backup/mysql
让我们来看下服务器硬盘有多大
df -h
什么?容量少了大半 ,被骗了? 赶紧看下是否有未挂载的硬盘
fdisk -l
原来是阿里云的centos | RedHat系统初始没有挂载硬盘
那我们只好手动挂载下了
先进行创建分区(依次输入)
fdisk /dev/xvdb
n
p
1
回车两次
wq
分区完成后格式化
mkfs.ext3 /dev/xvdb1
-------------------------
-------------------------
mount /dev/xvdb1 /web/
echo "/dev/xvdb1 /web/ ext3 defaults 0 0" >> /etc/fstab
umount 挂载点设备
如: umount /mnt
rpm --import http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS-Base-163.repo
sed -i '/mirrorlist/d' CentOS-Base-163.repo
sed -i 's/\$releasever/5/' CentOS-Base-163.repo
yum clean metadata
yum makecache
-------------------------
vim /etc/yum.conf
exclude=kernel*
:wq
-------------------------
sudo -s
LANG=C
yum -y install gcc gcc-c autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers lsof unzip
-------------------------
-------------------------
cd /web/backup/soft
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local
make
make install
cd ../
-------------------------
cd /web/backup/soft
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../
-------------------------
cd /web/backup/soft
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
-------------------------
cd /web/backup/soft
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../
-------------------------
cd /web/backup/soft
tar zvxf cmake-2.8.10.1.tar.gz
cd cmake-2.8.10.1
./bootstrap
make && make install
cd ../
-------------------------
cd /web/backup/soft
tar zvxf libunwind-1.1.tar.gz
cd libunwind-1.1
./configure --enable-shared
make && make install
cd ../
-------------------------
cd /web/backup/soft
tar zvxf gperftools-2.0.tar.gz
cd gperftools-2.0
./configure --enable-shared --enable-frame-pointers
make && make install
cd ../
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
/sbin/ldconfig
-------------------------
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
mkdir -p /web/data/mysql
chown -R mysql:mysql /web/data/mysql
su - root
cd /web/backup/soft
tar zvxf mysql-5.5.28.tar.gz
cd mysql-5.5.28
cmake -DCMAKE_INSTALL_PREFIX=/web/soft/mysql -DMYSQL_DATADIR=/web/data/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc/ -DWITH_SSL=yes -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=on
make && make install
ln -s /web/soft/mysql/lib/lib* /usr/lib/
cd /web/soft/mysql
./scripts/mysql_install_db --basedir=/web/soft/mysql/ --datadir=/web/data/mysql/ --user=mysql
cp ./support-files/my-large.cnf /etc/my.cnf
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 345 mysqld on
vim /etc/rc.d/init.d/mysqld
basedir=/web/soft/mysql
datadir=/web/data/mysql
service mysqld start
cd /web/soft/mysql/
./bin/mysql_secure_installation
ln -s /web/soft/mysql/bin/mysql /bin
vim /web/soft/mysql/bin/mysqld_safe
export LD_PRELOAD=/usr/local/lib/libtcmalloc.so
service mysqld restart
lsof -n | grep tcmalloc
-------------------------
cd /web/backup/soft
tar zxvf pcre-8.31.tar.gz
cd pcre-8.31/
./configure
make && make install
cd ../
cd /lib64/
ln -s libpcre.so.0.0.1 libpcre.so.1
-------------------------
groupadd www
useradd -g www www
mkdir -p /web/www
chmod w /web/www
chown -R www:www /web/www
mkdir -p /tmp/tcmalloc/
chown -R www:www /tmp/tcmalloc/
cd /web/backup/soft
tar zvxf nginx-1.3.8.tar.gz
cd nginx-1.3.8
vim ./src/core/nginx.h
./configure --user=www --group=www --prefix=/web/soft/nginx --with-http_stub_status_module --with-http_ssl_module --with-google_perftools_module
make && make install
cd ../
vim /web/soft/nginx/conf/nginx.conf
user www www;
worker_processes 4;
error_log logs/error.log crit;
pid logs/nginx.pid;
google_perftools_profiles /tmp/tcmalloc/;
events {
use epoll;
worker_connections 65535;
}
cd /web/soft/nginx
./sbin/nginx -t
./sbin/nginx
ps au|grep nginx
lsof -n | grep tcmalloc
cd /etc/init.d
vim nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/web/soft/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/web/soft/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
killall -9 nginx
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
chmod 755 /etc/init.d/nginx
chkconfig --add nginx
chkconfig --level 345 nginx on
/web/soft/nginx/sbin/nginx -s stop
service nginx start
-------------------------
ln -s /web/soft/mysql/lib/libmysqlclient.so.18 /lib/
cp -frp /usr/lib64/libldap* /usr/lib/
ln -s /web/soft/mysql/lib/libmysqlclient.so.18 /lib64/
mkdir ext/phar/phar.phar
cd /web/backup/soft
tar zvxf php-5.4.8.tar.gz
cd php-5.4.8
./configure --prefix=/web/soft/php --with-config-file-path=/web/soft/php/etc --with-mysql=/web/soft/mysql --with-mysqli=/web/soft/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --disable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --disable-fileinfo
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-production /web/soft/php/etc/php.ini
cd ../
cd /web/backup/soft
tar zvxf memcache-2.2.7.tgz
cd memcache-2.2.7
/web/soft/php/bin/phpize
ldconfig
./configure --with-php-config=/web/soft/php/bin/php-config
make && make install
vim /web/soft/php/etc/php.ini
extension_dir = "/web/soft/php/lib/php/extensions/no-debug-non-zts-20100525/"
extension = "memcache.so"
cd /web/backup/soft
tar zvxf eaccelerator-eaccelerator-42067ac.tar.gz
cd eaccelerator-eaccelerator-42067ac
/web/soft/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/web/soft/php/bin/php-config
make && make install
vim /web/soft/php/etc/php.ini
zend_extension="/web/soft/php/lib/php/extensions/no-debug-non-zts-20100525/eaccelerator.so"
eaccelerator.shm_size="32"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.log_file = "/web/soft/php/var/log/eaccelerator_log"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
mkdir -p /tmp/eaccelerator
-------------------------
cd /web/backup/soft
tar zvxf libevent-2.0.20-stable.tar.gz
cd libevent-2.0.20-stable
./configure
make
make install
cd ../
ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
-------------------------
cd /web/backup/soft
tar zvxf memcached-1.4.15.tar.gz
cd memcached-1.4.15
./configure
make
make install
cd ../
/usr/local/bin/memcached -d -m 100 -p 11211 -u root
vim /etc/rc.d/rc.local
/usr/local/bin/memcached -d -m 100 -p 11211 -u www
-------------------------
ln -s /web/soft/mysql/include/* /usr/local/include/
cd /web/backup/soft
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/web/soft/php/bin/phpize
./configure --with-php-config=/web/soft/php/bin/php-config --with-pdo-mysql=/web/soft/mysql
make
make install
cd ../
vim /web/soft/php/etc/php.ini
extension="pdo_mysql.so"
cp /web/soft/php/etc/php-fpm.conf.default /web/soft/php/etc/php-fpm.conf
vim /web/soft/php/etc/php-fpm.conf
[global]
pid = run/php-fpm.pid-p
error_log = log/php-fpm.log
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 5s
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_children = 20
vim /web/soft/nginx/conf/nginx.conf
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
cp /web/backup/soft/php-5.4.8/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 700 /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig --level 345 php-fpm on
service php-fpm restart
reboot
-------------------------
-------------------------
mkdir /web/data/config
mkdir /web/data/logs
vim /web/soft/nginx/conf/nginx.conf
include /web/data/config/*.conf;
service nginx reload
-------------------------
cd /web/backup/code
tar zxvf phpMyAdmin-3.5.3-all-languages.tar.gz -C /web/www/
cd /web/www
mv phpMyAdmin-3.5.3-all-languages/ phpmyadmin
创建nginx配置文件
vim /web/data/config/phpmyadmin.conf
输入以下内容(
代码里的www.phpmyadmin.com 改为自己要绑定的网址)
server {
listen 80;
client_max_body_size 10M;
server_name www.phpmyadmin.com;
index index.php index.html index.htm;
root /web/www/phpmyadmin;
autoindex off;
location ~ .*\.(php|php5|php4|shtml|xhtml|phtml)?$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
}
location ~ .*\.(ico|gif|jpg|jpeg|png|bmp|swf|js|css)$
{
expires 5d;
access_log off;
}
access_log /web/data/logs/phpmyadmin.log;
}
service nginx reload
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。