Centos7安装LAMP+PHPmyadmin

1、更新Centos7下载源
更新之前记得备份!!!
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
参考:http://mirrors.aliyun.com/help/centos
163的源参考:http://mirrors.163.com/.help/centos.html
2、更新本地缓存
yum clean all
yum makecache
3、安装网络工具
yum install net-tools
如果你要用ifconfig等命令的话
4、关闭firewall
systemctl stop firewalld.service
systemctl disable firewalld.service
5、关闭selinux
vi /etc/selinux/config
注释#SELINUX=enforcing
注释#SELINUXTYPE=targeted
添加SELINUX=disabled
保存退出:wq
setenforce 0#关闭selinux
6、安装apache
yum install httpd
7、安装Mariadb
yum install mariadb mariadb-server
拷贝配置文件覆盖原配置文件
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
8、安装PHP
yum install php php-mysql php-gd php-odbc php-pear php-mbstring php-mcrypt
9、下载PHPmyadmin
wget https://files.phpmyadmin.net/phpMyAdmin/4.0.0/phpMyAdmin-4.0.0-all-languages.zip
解压到/var/www/html/phpmyadmin

10、配置站点
vi /etc/httpd/conf/httpd.conf
文件最后加入

Include vhost/*.conf
mkdir /etc/httpd/vhost
touch test.conf

DocumentRoot /var/www/html/test
ServerName test

Options FollowSymLinks
AllowOverride All


touch phpmyadmin.conf

DocumentRoot /var/www/html/phpmyadmin
ServerName phpmyadmin

Options FollowSymLinks
AllowOverride All


重启apache和mariadb
11、安装epel源
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
如果版本不一样就去这里找http://dl.fedoraproject.org/pub/epel/
rpm -ivh rpm epel-release-7-8.noarch.rpm
yum clean all
yum update
以下步骤都是在安装了epel源下进行的
12、安装mcrypt扩展
yum install php-mcrypt
13、安装redis、memcache以及扩展
yum install redis
vi /etc/redis.conf
daemonize yes#守护进程运行
redis-server /etc/redis.conf
yum install php-redis
yum install memcached
yum install php-memcached

附录:
启动|停止|重启apache systemctl start|stop|restart httpd.service
开机启动apache systemctl enable httpd.service
启动|停止|重启mariadb systemctl start|stop|restart mariadb.service
开启启动mariadb systemctl enable mariadb.service

Nginx搭建Https服务器

mkdir -p /etc/nginx/ssl
生成私钥
openssl genrsa -des3 -out server.key 1024
提示输入密码和确认密码
生成证书
openssl req -new -key server.key -out server.csr
提示输入密码,国家,省份,城市,组织等信息
生成无密码私钥
openssl rsa -in server.key -out public.key
颁发证书
openssl x509 -req -days 365 -in server.csr -signkey public.key -out server.crt
配置nginx站点

server {
    listen 443;
    ssl on;
    ssl_certificate  /etc/nginx/ssl/server.crt;
    ssl_certificate_key  /etc/nginx/ssl/public.key;
    server_name test.phpfs.com;
    root /data/html/test.phpfs.com/;
    location / {
       autoindex on;
    }
}

配置apache站点
提示:Invalid command ‘SSLEngine’, perhaps misspelled or defined by a module not included in the server configuration
Action ‘configtest’ failed.
需要启用sudo a2enmod ssl


	ServerName test.phpfs.com
	DocumentRoot /var/www/html/test
	SSLEngine on
    SSLCertificateFile /etc/nginx/ssl/server.crt
    SSLCertificateKeyFile /etc/nginx/ssl/public.key



nginx-https-1

Nginx前端,apache后端获取真实IP

http://www.stderr.net/apache/rpaf/download/

需要使用apxs命令(这个命令在httpd-devel,可以使用yum install httpd-devel)
1、执行apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c

2、 编辑vi /etc/httpd/conf/httpd.conf
添加如下代码
LoadModule rpaf_module modules/mod_rpaf-2.0.so
<IfModule mod_rpaf.c>
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 127.0.0.1 192.168.1.187#nginx服务器IP
RPAFheader X-Forwarded-For
</IfModule>

3、定义日志格式

LogFormat “%{X-Forwarded-For}i %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”” varnishcombined

4、开启日志
CustomLog logs/access_log varnishcombined
5、程序获取客户端真实IP
$user_IP = isset($_SERVER[‘HTTP_X_FORWARDED_FOR’]) ? $_SERVER[‘HTTP_X_FORWARDED_FOR’] : $_SERVER[“REMOTE_ADDR”];

Apache配置403和404留住用户

1、如果你的服务器支持htaccess文件

在htaccess配置添加:

ErrorDocument 403 /error/403.html#当然,你必须要确定error以及403和404页面存在

ErrorDocument 404 /404.html#当然你也可以写http://www.03377joyous.com/404.html

注意:千万不要直接把404或者403跳转成首页(这样会有可能会让蜘蛛丢掉你的首页抓取

htaccess功能不仅如此,还可以加上文件夹禁止访问以及密码保护等。慢慢摸索去吧~

2、在虚拟主机中配置

<Directory /web/docs>
ErrorDocument 404 /404.htm
</Directory> #说明这个是配置web/docs目录下404返回,你问是不是不同的文件夹可以定制不同的404?明确的回答你,是可以的

有人又问了,那为何要配置403和404页面呢?

seo中404的作用