PHP on CentOS (LAMP) and wordpress
http://php.net/manual/zh/install.windows.php
https://www.unixmen.com/install-wordpress-centos-7-linux/ (Very useful)
https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp (Very useful)
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-centos-7
https://www.tipsandtricks-hq.com/how-to-uninstall-and-reinstall-wordpress-245 (update wp-config.php and then go to wp-admin/install.php page)
https://codex.wordpress.org/Using_Themes#Get_New_Themes
https://www.tipsandtricks-hq.com/how-to-fix-the-unable-to-create-directory-error-in-wordpress-5264 (this happend, and might also related to faliure to install themes online)
https://httpd.apache.org/docs/2.2/vhosts/examples.html
下载中文版: https://cn.wordpress.org/
To check whether PHP got installed on your machine:
# rmp -qa | grep -i php (looks it looking for installed packages containing "php")
Or
# locate php (looks like it's searching files with name containing "php" )
#Install Apache on CentOS
sudo yum -y install httpd sudo systemctl start httpd sudo systemctl enable httpd #Test Apache and use browser to check the default website by apache
sudo systemctl status httpd #installing MySql/MariaDB
sudo yum install mariadb-server mariadb
sudo systemctl start mariadb
sudo mysql_secure_installation #install PHP
sudo yum -y install php php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl #install Wordpress
sudo yum install zip unzip
sudo wget https://wordpress.org/latest.zip sudo unzip latest.zip
sudo cp -avr wordpress /var/www/html
sudo chmod -R 775 wordpress
sudo chown apache:apache wordpress
Quetions:
PHP configuratioin files?
Apache configuration files?
Answer: /etc/httpd/conf/httpd.conf
How to host multiple websites on apache in centos?
https://www.mysysadmintips.com/linux/servers/586-host-multiple-websites-on-apache-in-centos
This tutorial shows how to setup Apache Virtual Hosts in CentOS 7. This is useful if you want to host more than one website on a single CentOS web server. For instructions on how to setup Apache, PHP, and SQL database on CentOS 7, check this article.
Setup folder structure for your websites
We are going to create 2 folders for each website. The first will hold HTML and other content, second - log files.
/var/www/sites/domain1/html
/var/log/httpd/domain1
/var/www/sites/domain2/html
/var/log/httpd/domain2
/var/www/sites/domain3/html
/var/log/httpd/domain3
Log files will be stored in var/log/httpd/... subfolders, which is the default place to store log files in Linux. People often store Apache log files in /var/www/ subfolders, but in CentOS with SELinux enabled this can cause access denied errors. This can be fixed with chcon command, but I prefer to store all my log files in /var/logs...
You can also place index.html files with some sample text in each html directory which we'll use later for testing.
Create folder structure for virtual host files
Create folders:
/etc/httpd/sites-available
/etc/httpd/sites-enabled
sites-available will hold virtual host config files for websites that are configured, but not necessary enabled. These files are actually ignored when Apache starts, but this system allows to easily disable and enable websites without having to delete or create new virtual host files every time we want to take a site offline and put it back online.
sites-enabled will hold symbolic links to virtual host files inside sites-available that are enabled. They will be loaded when Apache starts.
Add sites-enabled to Apache config
Open file /etc/httpd/conf/httpd.conf and at the very end of the file add following text:
IncludeOptional sites-enabled/*.conf
This will tell Apache to look for virtual host files with extension .conf in sites-enabled directory.
Create Virtual Host files
In directory /etc/httpd/sites-available create config files for each website (domain1.conf, domain2.conf, etc.) with following content:
<VirtualHost *:80>
ServerName www.domain1.com
ServerAlias domain1.com
DocumentRoot /var/www/sites/domain1/html
ErrorLog /var/log/httpd/domain1/error.log
CustomLog /var/log/httpd/domain1/access.log combined
</VirtualHost>
Change domain1 to match your domain names and directories you created previously.
If Apache can't match the requested domain to any of the virtual hosts, the first (alphabetically) virtual host site will be loaded. If you want to have more control over this, you can create a dedicated virtual host (i.e. 00_default) that will be loaded only when no matching virtual host exist. ServerName and ServerAlias should not match any of your domains (i.e. example.com) The name starts with 00 so that it is always the first virtual hosts alphabetically. The site linked to this default virtual host could show an error message, redirect to another domain, etc.
Edit httpd.conf
Edit the main Apache configuration file /etc/httpd/conf/httpd.conf according to your requirements.
In my particular case, I made following changes:
Set webmaster email address:
ServerAdmin administrator@domain.com
Set main document root:
DocumentRoot "/var/www/sites"
Configure main document root:
<Directory "/var/www/sites">
AllowOverride All
Options FollowSymLinks
</Directory>
AllowOverride All - is required if you intend to use .htaccess files for directory level configuration. By default, this is set to None, in which case .htaccess overrides would be ignored.
Options -Indexes - prevents directory listing.
Enable Virtual Hosts
To enable websites, we need to create symbolic links in /etc/httpd/sites-enabled pointing to appropriate config files in sites-available. To do this, run:
ln -s /etc/httpd/sites-available/domain1.conf /etc/httpd/sites-enabled/domain1.conf
For changes to take effect we need to restart Apache:
systemctl restart httpd.service
To disable a particular website, simply delete relevant symbolic link (or change the extension) and restart Apache.
Before going live, you can test if everything is working locally. To do this, edit the hosts file on your client machine to point domains configured inside virtual hosts to the CentOS web server's IP address. If everything was setup properly, pointing your web browser to one of the domains should load index.html file from an appropriate /var/www/sites/... directory.
2015.01
CentOS 7
以下为最近学习小结:
问题一: 创建新用户并设置密码
解决方案:
创建新用户 adduser <username>
设置密码 passwd <username>
问题二:使用新用户登录,执行 "sudo yum update",没有sudo 权限,得到错误: “<user> is not in the sudoers file. This incident will be reported.”
解决方案:http://www.cnblogs.com/evasnowind/archive/2011/02/04/1949113.html
一、$whereis sudoers -------找出文件所在的位置,默认都是/etc/sudoers
二、 #chmod u+w /etc/sudoers 以超级用户登录su -root ,修改文件权限即添加文件拥有这的写权限 限,ls -al /etc/sudoers 可以查看原文件的权限。
三、vim /etc/sudoers 编辑文件,在root ALL=(ALL)ALL行下添加XXX ALL=(ALL)ALL,XXX为你的用户名。添加方法:找到root行,按下”i“键进入编辑模式添加即可!编辑好后esc键进入一般模式,“:wq"保存退出!
最后, #chmod u-w /etc/sudoers 回到文件的原权限!
问题三: 没有安装VIM
解决方案: # yum -y install vim*
操作4: Install MySQL on CentOS-7
https://www.linode.com/docs/databases/mysql/how-to-install-mysql-on-centos-7
操作5: 本机登录mysql创建帐户、密码及新的数据库
> mysql -u root
> create user '<username>'@'%';
> SET Password for '<username>'@'%' = Password('mypassword');
此时该用户已经可以远程登录了!
TODO: set password for mysql for root account.
> create database <db-name>;
> grant all privileges on <dbname>.* to '<user>'@'localhost';
> select current_user();
到此,数据库、连接用户名密码已经配置完成!
操作6:尝试直接使用IP或域名访问此服务器
[slin@iZwz9h33t7dnsizrtbp8yhZ www]$ wget http://www.linsw.com
--2017-06-14 10:52:14-- http://www.linsw.com/
Resolving www.linsw.com (www.linsw.com)... 120.77.38.243
Connecting to www.linsw.com (www.linsw.com)|120.77.38.243|:80... failed: Connection refused.
操作6-1: 尝试安装nodejs, 分别使用80与非80端口,来看一下服务器上的nodejs能否正常工作
> sudo yum install nodejs
准备以下内容给 nodetest /index.js文件:
var port = (process.env.port || 8080);
if (process.argv.length > 2) {
for (var i = 2; i < process.argv.length; i++) {
console.log(process.argv[i]);
var m = /port=(\d+)/.exec(process.argv[i]);
if (m) {
port = m[1];
}
}
}
var http = require('http');
var server = http.createServer(function(req, res, next){
console.log('got request:' + req.url);
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('hello world from shawn. NodeJS');
});
/*server.on('listen', function(){
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
console.log(bind);
});
*/
var port = 80;
server.listen(port);
server.on('error', function(err){
console.log(err);
});
console.log('server is listening on port: ' + port);
> sudo nodejs ~/www/nodetest/index.js
说明機器上沒有别的进程在使用80端口;那接下来应该需要安装apache httpd服务。
操作7:安装apache, php
http://www.cnblogs.com/swlin/p/PHP.html
> sudo yum -y install httpd
> sudo systemctl enable httpd
> sudo systemctl start httpd
至此,httpd服务成功安装,并可以通过域名成功访问,并显示一个默认的测试页面。
> sudo systemctl status httpd
操作7-2:
#install PHP
sudo yum -y install php php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl
#install Wordpress
sudo yum install zip unzip
sudo wget https://wordpress.org/latest.zip
sudo unzip latest.zip
sudo mkdir /var/www/websites/
sudo cp -avr wordpress /var/www/websites/mywebsite
sudo chmod -R 775 mywebsite
sudo chown apache:apache mywebsite
操作8: rewrite module
打开httpd.conf(在那里? APACHE目录的CONF目录里面),用文本编纂器打开后,查找
(1)
Options FollowSymLinks
AllowOverride None
改为
Options FollowSymLinks
AllowOverride All
(2)去掉下面的注释
LoadModule rewrite_module modules/mod_rewrite.so
(3) 修改文件 /etc/httpd/virutal_hosts/<your-host-file>.conf,在<VirtualHost *:80>节点里面增加如下内容
<Directory /var/www/websites/dev_gmpflex_com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
操作9:解决wordpress安装主题时一直提示需要FTP用户名及密码,其它完全不需要安装 FTP SERVER的:
解决方案:
http://jingyan.baidu.com/article/4f34706efc1237e387b56da4.html
第一,如果我们安装的是lnmp一键安装包,那可以使用。授权组来解决。
chown -R 775 /home/wwwroot/my-website-name(修改成网站域名目录)
第二,如果是其他的可以使用在wp-config.php文件中添加脚本方式。
define("FS_METHOD","direct");
define("FS_CHMOD_DIR", 0777);
define("FS_CHMOD_FILE", 0777);
上述脚本添加到文件最后面就可以。
但是,之后我又遇到问题: 安装失败,无法创建目录。
操作9-1: chmod -R 777 /var/www/ (这个搞定问题,但不知道直接到本人使用的/var/www/websites/行不行?)
=================
centos new user: slin/ABcd1234
如果您的.htaccess文件可写,我们即会自动帮您完成,但其目前不可写,所以以下是您需要加入您的.htaccess文件中的mod_rewrite规则。点击文本框并按CTRL + a来全选。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
http://blog.sina.com.cn/s/blog_6452c6b40100qr7m.html
PHP on CentOS (LAMP) and wordpress的更多相关文章
- centos lamp/lnmp阶段复习 以后搬迁discuz论坛不需要重新安装,只需修改配置文件即可 安装wordpress 安装phpmyadmin 定时备份mysql两种方法 第二十五节课
centos lamp/lnmp阶段复习 以后搬迁discuz论坛不需要重新安装,只需修改配置文件即可 安装wordpress 安装phpmyadmin 定时备份mysql两种方法 第二十五节 ...
- Centos 7使用docker部署LAMP搭建wordpress博客系统
0.简要概述 LAMP是目前比较流行的web框架,即Linux+Apache+Mysql+PHP的网站架构方案.docker是目前非常流行的虚拟化应用容器,可以为任何应用创建一个轻量级.可移植的容器. ...
- LAMP 搭建wordpress部署教程贴.
LAMP 搭建wordpress部署教程贴.这是一篇主要将LAMP,并且通过wordpress来进行验证,演示.如何去部署PHP CMS很多新手看到LAMP就很很头大,觉得很难搞,编译安装,搞了好几天 ...
- LAMP 建立 Wordpress 站点 Linux Apache MariaDB PHP
使用LAMP建立Wordpress, 要求如下: 准备工作: VMware 14 CentOS 7.4 最小化 安装镜像 Wordpress 安装包, 下载 预热: 使用VMware新建4台虚拟机, ...
- 于CentOS 6 安装 Wordpress
1.两种方式给Wordpress 首先,你可以去wordpress最新的官方网站看看wordpress多少下载.例wordpress 3.9.1下载地址: http://cn.wordpress.or ...
- LVS之-LAMP搭建wordpress
author:JevonWei 版权声明:原创作品 LVS搭建wordpress,涉及的知识点有DNS,LAMP,NFS及LVS 网络拓扑图 网络环境 NFS 192.168.198.130 mysq ...
- 【简书】在阿里云自带的CentOS + LAMP环境下部署一个Laravel项目
在阿里云自带的CentOS + LAMP环境下部署一个Laravel项目 作者 DonnieZero 关注 2017.07.29 22:02* 字数 2218 阅读 5556评论 3喜欢 1赞赏 1 ...
- 实战!基于lamp安装wordpress详解-技术流ken
简介 LAMP 是Linux Apache MySQL PHP的简写,其实就是把Apache, MySQL以及PHP安装在Linux系统上,组成一个环境来运行动态的脚本文件.现在基于lamp搭建wor ...
- centos LAMP第四部分mysql操作 忘记root密码 skip-innodb 配置慢查询日志 mysql常用操作 mysql常用操作 mysql备份与恢复 第二十二节课
centos LAMP第四部分mysql操作 忘记root密码 skip-innodb 配置慢查询日志 mysql常用操作 mysql常用操作 mysql备份与恢复 第二十二节课 mysq ...
随机推荐
- 如何设计一款优秀的短视频 SDK
2017 年,短视频成为了创业的新风口,各种短视频 App 如雨后春笋般先后上线,视频越来越像文字.图片一样,成为每一个 App 不可或缺的一部分. 1. 包体一定要尽可能小 如何做到尽可能的减小 S ...
- 经验之谈:Swing的开发工作会非常的累,而且这项技术正在走向没落。避免从事有这种特征的工作。
经验之谈:Swing的开发工作会非常的累,而且这项技术正在走向没落.避免从事有这种特征的工作. AWT也即将被取代. Module8—Module11所使用的技术都将被JSF技术所取代. JSF是 ...
- C_C++变量命名规则
变量命名规则是为了增强代码的可读性和容易维护性.以下为C++必须遵守的变量命名规则: 变量名只能是字母(A-Z,a-z)和数字(0-9)或者下划线(_)组成. 第一个字母必须是字母或者下划线开头. 不 ...
- Windows上使用telnet测试端口号
之前测试服务器某一端口开启开启情况一般在服务器上使用 netstat –ano|findstr "端口号"命令查看. 但是有时候端口在服务器上开通了,但是客户端并不一定可以访问到 ...
- Qt编写自定义控件11-设备防区按钮控件
前言 在很多项目应用中,需要根据数据动态生成对象显示在地图上,比如地图标注,同时还需要可拖动对象到指定位置显示,能有多种状态指示,安防领域一般用来表示防区或者设备,可以直接显示防区号,有多种状态颜色指 ...
- Excel条件格式
任务需求,将Excel中年龄为90后出生的人员筛选出来,并将重复的人员数据删除. 一.Excel去重 选中表格数据->数据->删除重复值 此时弹出对话框,选择去重列. 点击确定即可. 二. ...
- Content-Length mismatch, received 431737 bytes out of the expected 760836
可能原因是 composer 的安装包网址是国外镜像所致,被长城防火墙屏蔽了.可执行以下命令来解决:composer config -g repo.packagist composer https:/ ...
- codeforce R 491 (div2)
本来打完就想写的,,奈何舍友要睡了,我开个台灯感觉怪怪的,就没写. A题竟然一开始wa了...后来发现对于c和a还有c和b的关系没有判断,,丢掉了很多罚时. B题我的方法是 计算 sum,然后 ...
- poj2251_kuagnbin带你飞专题一
Dungeon Master Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 32684 Accepted: 12529 ...
- Web 自动化测试
Selenium 名字的来源 在这里,我还想说一下关于 Selenium 名字的来源,很有意思的 : > : Selenium 的中文名为 “ 硒 ” ,是一种化学元素的名字,它 对 汞 ( M ...