Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Sunday, August 26, 2018

Build a webserver with CentOS 7, MySQL, PHP7.2 and use a existing wildcard SSL Certificate from Windows Server

Build a webserver with CentOS 7, MySQL, PHP7.2 and use a existing wildcard SSL Certificate from Windows Server
A.   Build a CentOS Linux server with minimum setup with developer options. After installed the CentOs, run yum -y update to upate the server to most update version
B.   Install Apache
Install Apache by yum yum install httpd
Start the httpd service systemctl start httpd.service
Let the httpd service start with the system systemctl enable httpd.service
C.   Configure the firewall
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
D.   Install MySQL
Install mysql by yum yum install mariadb-server mariadb
Start the httpd service systemctl start mariadb
Let the httpd service start with the system systemctl enable mariadb.service
Configure the MYSQL sudo mysql_secure_installation

The new password for the “root” of MySQL
E.   Install PHP7.2
     yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm  
yum install yum-utils
yum-config-manager --enable remi-php72
yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
     systemctl restart httpd.service
F.    Install phpMyAdmin
yum -y install phpmyadmin
vi /etc/httpd/conf.d/phpMyAdmin.conf to add the ip or ip range to allow access the phpMyAdmin, following example is added the subnet 192.168.3.0/24 and 192.168.168.0/24

G.  Copy website to following directory in Linux cd /var/www/html by using ftp (install ftp before use the ftp yum install -y ftp)
H.  Import tables to MySQL by using phpMyAdmin
l Launch the phpMyAdmin



l Create the database as the program required, here is “cfweb”

l Click on the “Import” tab to begin import the tables





 

I. Run following command openssl version, if the openssl was installed, the output should like OpenSSL 1.0.2k-fips  26 Jan 2017
J.    Install mod_ssl
Before configure the SSL, run following command to install the SSL module
yum -y install mod_ssl
K.   Export the PFX file from Windows Server
l Click Start, Run, then type “mmc” and hit enter.

l In the leftmost menu, choose “Add/Remove Snap In” under “File”.

l Click “Certificates”, then click “Add”, then OK.



l When the wizard starts, choose “Computer Account”, “Local Computer” and finish out the wizard.




l Once you’re finished, go back to the MMC and expand the “Certificates” node, then the “Personal” node.


l Click on the “Certificates” node under “Personal” and find your certificate in the right pane.




l Right click on the certificate and choose “All Tasks”, then “Export”.

l When the wizard starts, choose “Yes” for exporting the private key, you will also need to set a password and specify a file name and location for the PFX file, e.g. “ssl.pfx” and in c:\temp










l Once the PFX file has been saved, close out the MMC (don’t save the snap-in if it asks).
L.    Enable SSL in CentOS
l Copy the PFX to a directory (e.g. /ssl) under root directory of the Linux server, e.g. use ftp
l In Linux server, change to the directory ssl cd /ssl
l In /ssl directory, run openssl pkcs12 -in ssl.pfx -out ssl.pem
l Copy the ssl.pem to 2 files cp ./ssl.pem ./ssl.crt and cp ./ssl.pem ./ssl.key
l    In ssl.crt file, clear the content out of following
-----BEGIN CERTIFICATE-----  and  -----END CERTIFICATE-----
l    In ssl.key file, clear the content out of following
-----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY-----
l cp ./ssl.crt /etc/pki/tls/certs/ssl.crt
l cp ./ssl.key /etc/pki/tls/private/ssl.key
l vi /etc/httpd/conf.d/ssl.conf
l edit the two line in ssl.conf like this
  SSLCertificateFile /etc/pki/tls/certs/ssl.crt
  SSLCertificateKeyFile /etc/pki/tls/private/ssl.key
l systemctl restart httpd





Monday, September 16, 2013

IPTABLES Rule

# iptables -P INPUT ACCEPT
# iptables -F
# iptables -A INPUT -i lo -j ACCEPT
# iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# iptables -A INPUT -p udp --dport 53 -j ACCEPT
# iptables -P INPUT DROP
# iptables -P FORWARD DROP
# iptables -P OUTPUT ACCEPT
# iptables -L -v

# /sbin/service iptables save

Thursday, August 15, 2013

Howto disable or enable SElinux on Centos 6.4 Redhat RHEL 6.4

 vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
SELINUX=disabled 
# SELINUXTYPE= can take one of these two values:
# targeted – Targeted processes are protected,
# mls – Multi Level Security protection.
SELINUXTYPE=targeted

Friday, October 12, 2012

Install PHP 5.3 on CentOS 5

To install, first you must install the yum repository information:
rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm
Now you can install php by doing:
yum --enablerepo=webtatic install php
Or update an existing installation of php, which will also update all of the other php modules installed:
yum --enablerepo=webtatic update php

Wednesday, February 9, 2011

Slove Error Message in Lunix on Virtual machine

TSC appears to be running slowly. Marking it as unstable
Time: pit
clocksource has been installed
Add "clock: pit" to /boot/grub/menu.lst

Tuesday, January 4, 2011

Friday, December 31, 2010

Add SSL to CentOS

1. #install ssl realted program
yum install mod_ssl openssl
 
2. # generate private key
openssl genrsa -out ca.key 1024 

3. # generae CSR from private key
openssl req -new -key ca.key -out ca.csr

4. # generate self assign certificate
openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt

5. # Copy file to appropiate location
cp ca.crt /etc/pki/tls/certs
cp ca.key /etc/pki/tls/private/ca.key
cp ca.csr /etc/pki/tls/private/ca.csr
 
6. #Edit Apache SSL configuration file
vi +/SSLCertificateFile /etc/httpd/conf.d/ssl.conf
 
7.#Edit following lines 
SSLCertificateFile /etc/pki/tls/certs/ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
 
8. #Restart Apache server
service httpd restart
 
9. #create directory for SSL virtual host
cd /var/www
mkdir html
cd /var
mkdir www-ssl
cd www-ssl
mkdir html

10. # To configure HTTPS over port 443 
vi /etc/httpd/conf.d/ssl.conf

11. # Example HTTPS  configuration

     SSLEngine on
     SSLCertificateFile /etc/pki/tls/certs/ca.crt
     SSLCertificateKeyFile /etc/pki/tls/private/ca.key
   
     AllowOverride All
   
     DocumentRoot /var/www-ssl/html
     ServerName FQDN of web server


12. #Restart Apache server
service httpd restart
 
13. #Put html file to /var/www-ssl/html
 
 

Sunday, December 19, 2010

Monday, March 23, 2009

CentOS用yum安裝php+mysql+apache

1. 安裝Apahce, PHP, Mysql, 以及php連接mysql庫組件。
yum -y install httpd php mysql mysql-server php-mysql php-mcrypt
2. 配置開機啓動服務
/sbin/chkconfig httpd on [設置apache服務器httpd服務開機啓動] /sbin/chkconfig –add mysqld [在服務清單中添加mysql服務] /sbin/chkconfig mysqld on [設置mysql服務開機啓動]
/sbin/service httpd start [啓動httpd服務,與開機啓動無關] /sbin/service mysqld start [啓動mysql服務,與開機無關]
3.設置mysql數據庫root帳號密碼。
mysqladmin -u root password ‘newpassword’ [引號內填密碼]
4. 讓mysql數據庫更安全
mysql -u root -p
mysql> DROP DATABASE test; [刪除test數據庫]mysql> DELETE FROM mysql.user WHERE user = ”; [刪除匿名帳戶]mysql> FLUSH PRIVILEGES; [重載權限]
5. 按照以上的安裝方式, 配置齣來的默認站點目錄為/var/www/html/新建一個php腳本:
6. 新建一個數據庫﹐添加一個數據庫用戶﹐設置用戶權限。寫個php腳本測試一下數據庫連接吧。
mysql> CREATE DATABASE my_db;mysql> GRANT ALL PRIVILEGES ON my_db.* TO ‘user’@'localhost’ IDENTIFIED BY ‘password’; //安裝apache擴展yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql//安裝php的擴展yum install php-gdyum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc//安裝mysql擴展yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

Wednesday, March 4, 2009

MYSQL跟phpMyAdmin 的安裝

因為最近公司新的主機需要使用mysql還有讓開發人員便於管理的phpMyAdmin所以便研究了一下MYSQL跟phpMyAdmin
一開始想說使用偉大的yum來安裝,但是卻不是那麼順利
1.yum可以安裝mysql沒問題2.CentOS5.2的yum沒有phpMyAdmin,如果Fedora就可以用yum安裝phpMyAdmin
好現在從頭一步一步來講解怎麼做安裝 MySQL+phpMyAdmin1.#yum install mysql-server mysql php-mysql php-mbstring libmcrypt php-mcrypt
2.到phpMyAdmin網頁下載最新的套件http://www.phpmyadmin.net/home_page/index.php將下載回來的tar檔解開#tar zxvf phpMyAdmin-2.11.8.1-all-languages.tar.gz再將解壓縮的資料夾改名並移動到網頁的根目錄(預設為/var/www/html)#mv ./phpMyAdmin-2.11.8.1-all-languages /var/www/html/phpMyAdmin
設定再來就是將剛剛安裝好的與phpMyAdmin做個簡單的設定mysql安裝完最重要的就是將mysql內的管理者帳號root設定密碼等會登入phpMyAdmin時就需要這帳號與密碼.
MYSQL先將mysql的服務啟動#chkconfig mysqld on#service mysqld start
以下範例為將預設的空密碼改為"my1234"#mysqladmin -u root password my1234如果你是要將舊密碼改為"my1234"#mysqladmin -u root -p password my1234Enter password: <==這裡請輸入舊的密碼 phpMyAdmin先到phpmyadmin的目錄裡面#cd /var/www/html/phpMyAdmin產生config.inc.php設定檔預設是沒有這個檔案的,要先將config.sample.inc.php複製成config.inc.php#cp ./config.sample.inc.php ./config.inc.php將認證方式改為http或是cookie還有修改hostname 如果你要以http認證只要修改2個地方#vi ./config.inc.php$cfg['Servers'][$i]['auth_type'] = 'http'; <==改為http$cfg['Servers'][$i]['host'] = 'example.com.tw'; <==改成你的電腦名稱 如果你要以cookie認證方式那你還要多設一個地方#vi ./config.inc.php$cfg['blowfish_secret'] = 'gtry356dfgejdkv42jnl5'; <==隨便輸入亂數的字讓cookie做密碼加密演算,最多46個字$cfg['Servers'][$i]['auth_type'] = 'cookie'; <==改為cookie$cfg['Servers'][$i]['host'] = 'example.com.tw'; <==改成你的電腦名稱 做完以上2個設定就完成了因為之前有安裝一些php的套件,所以要重起httpd#service httpd restart到瀏覽器輸入以下網址http://localhost/phpMyAdmin/使用mysql的root與密碼就可以登入phpMyAdmin管理MYSQL了

Prevent or Prohibit Server Drives From Being Visible to Users

  To make changes to this policy for one of the seven default values: Start the Microsoft Management Console. On the Console menu, click  Ad...